babylon.module.d.ts 5.1 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154
  1. declare module "babylonjs/types" {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /** @hidden */
  41. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  42. }
  43. /** @hidden */
  44. /** @hidden */
  45. type DeepImmutableObject<T> = {
  46. readonly [K in keyof T]: DeepImmutable<T[K]>;
  47. };
  48. }
  49. declare module "babylonjs/Misc/arrayTools" {
  50. /**
  51. * Class containing a set of static utilities functions for arrays.
  52. */
  53. export class ArrayTools {
  54. /**
  55. * Returns an array of the given size filled with element built from the given constructor and the paramters
  56. * @param size the number of element to construct and put in the array
  57. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  58. * @returns a new array filled with new objects
  59. */
  60. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  61. }
  62. }
  63. declare module "babylonjs/Maths/math.scalar" {
  64. /**
  65. * Scalar computation library
  66. */
  67. export class Scalar {
  68. /**
  69. * Two pi constants convenient for computation.
  70. */
  71. static TwoPi: number;
  72. /**
  73. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  74. * @param a number
  75. * @param b number
  76. * @param epsilon (default = 1.401298E-45)
  77. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  78. */
  79. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  80. /**
  81. * Returns a string : the upper case translation of the number i to hexadecimal.
  82. * @param i number
  83. * @returns the upper case translation of the number i to hexadecimal.
  84. */
  85. static ToHex(i: number): string;
  86. /**
  87. * Returns -1 if value is negative and +1 is value is positive.
  88. * @param value the value
  89. * @returns the value itself if it's equal to zero.
  90. */
  91. static Sign(value: number): number;
  92. /**
  93. * Returns the value itself if it's between min and max.
  94. * Returns min if the value is lower than min.
  95. * Returns max if the value is greater than max.
  96. * @param value the value to clmap
  97. * @param min the min value to clamp to (default: 0)
  98. * @param max the max value to clamp to (default: 1)
  99. * @returns the clamped value
  100. */
  101. static Clamp(value: number, min?: number, max?: number): number;
  102. /**
  103. * the log2 of value.
  104. * @param value the value to compute log2 of
  105. * @returns the log2 of value.
  106. */
  107. static Log2(value: number): number;
  108. /**
  109. * Loops the value, so that it is never larger than length and never smaller than 0.
  110. *
  111. * This is similar to the modulo operator but it works with floating point numbers.
  112. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  113. * With t = 5 and length = 2.5, the result would be 0.0.
  114. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  115. * @param value the value
  116. * @param length the length
  117. * @returns the looped value
  118. */
  119. static Repeat(value: number, length: number): number;
  120. /**
  121. * Normalize the value between 0.0 and 1.0 using min and max values
  122. * @param value value to normalize
  123. * @param min max to normalize between
  124. * @param max min to normalize between
  125. * @returns the normalized value
  126. */
  127. static Normalize(value: number, min: number, max: number): number;
  128. /**
  129. * Denormalize the value from 0.0 and 1.0 using min and max values
  130. * @param normalized value to denormalize
  131. * @param min max to denormalize between
  132. * @param max min to denormalize between
  133. * @returns the denormalized value
  134. */
  135. static Denormalize(normalized: number, min: number, max: number): number;
  136. /**
  137. * Calculates the shortest difference between two given angles given in degrees.
  138. * @param current current angle in degrees
  139. * @param target target angle in degrees
  140. * @returns the delta
  141. */
  142. static DeltaAngle(current: number, target: number): number;
  143. /**
  144. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  145. * @param tx value
  146. * @param length length
  147. * @returns The returned value will move back and forth between 0 and length
  148. */
  149. static PingPong(tx: number, length: number): number;
  150. /**
  151. * Interpolates between min and max with smoothing at the limits.
  152. *
  153. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  154. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  155. * @param from from
  156. * @param to to
  157. * @param tx value
  158. * @returns the smooth stepped value
  159. */
  160. static SmoothStep(from: number, to: number, tx: number): number;
  161. /**
  162. * Moves a value current towards target.
  163. *
  164. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  165. * Negative values of maxDelta pushes the value away from target.
  166. * @param current current value
  167. * @param target target value
  168. * @param maxDelta max distance to move
  169. * @returns resulting value
  170. */
  171. static MoveTowards(current: number, target: number, maxDelta: number): number;
  172. /**
  173. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  174. *
  175. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  176. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  177. * @param current current value
  178. * @param target target value
  179. * @param maxDelta max distance to move
  180. * @returns resulting angle
  181. */
  182. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  183. /**
  184. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  185. * @param start start value
  186. * @param end target value
  187. * @param amount amount to lerp between
  188. * @returns the lerped value
  189. */
  190. static Lerp(start: number, end: number, amount: number): number;
  191. /**
  192. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  193. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  194. * @param start start value
  195. * @param end target value
  196. * @param amount amount to lerp between
  197. * @returns the lerped value
  198. */
  199. static LerpAngle(start: number, end: number, amount: number): number;
  200. /**
  201. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  202. * @param a start value
  203. * @param b target value
  204. * @param value value between a and b
  205. * @returns the inverseLerp value
  206. */
  207. static InverseLerp(a: number, b: number, value: number): number;
  208. /**
  209. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  210. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  211. * @param value1 spline value
  212. * @param tangent1 spline value
  213. * @param value2 spline value
  214. * @param tangent2 spline value
  215. * @param amount input value
  216. * @returns hermite result
  217. */
  218. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  219. /**
  220. * Returns a random float number between and min and max values
  221. * @param min min value of random
  222. * @param max max value of random
  223. * @returns random value
  224. */
  225. static RandomRange(min: number, max: number): number;
  226. /**
  227. * This function returns percentage of a number in a given range.
  228. *
  229. * RangeToPercent(40,20,60) will return 0.5 (50%)
  230. * RangeToPercent(34,0,100) will return 0.34 (34%)
  231. * @param number to convert to percentage
  232. * @param min min range
  233. * @param max max range
  234. * @returns the percentage
  235. */
  236. static RangeToPercent(number: number, min: number, max: number): number;
  237. /**
  238. * This function returns number that corresponds to the percentage in a given range.
  239. *
  240. * PercentToRange(0.34,0,100) will return 34.
  241. * @param percent to convert to number
  242. * @param min min range
  243. * @param max max range
  244. * @returns the number
  245. */
  246. static PercentToRange(percent: number, min: number, max: number): number;
  247. /**
  248. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  249. * @param angle The angle to normalize in radian.
  250. * @return The converted angle.
  251. */
  252. static NormalizeRadians(angle: number): number;
  253. }
  254. }
  255. declare module "babylonjs/Maths/math" {
  256. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  257. /**
  258. * Constant used to convert a value to gamma space
  259. * @ignorenaming
  260. */
  261. export const ToGammaSpace: number;
  262. /**
  263. * Constant used to convert a value to linear space
  264. * @ignorenaming
  265. */
  266. export const ToLinearSpace = 2.2;
  267. /**
  268. * Constant used to define the minimal number value in Babylon.js
  269. * @ignorenaming
  270. */
  271. let Epsilon: number;
  272. export { Epsilon };
  273. /**
  274. * Class used to hold a RBG color
  275. */
  276. export class Color3 {
  277. /**
  278. * Defines the red component (between 0 and 1, default is 0)
  279. */
  280. r: number;
  281. /**
  282. * Defines the green component (between 0 and 1, default is 0)
  283. */
  284. g: number;
  285. /**
  286. * Defines the blue component (between 0 and 1, default is 0)
  287. */
  288. b: number;
  289. /**
  290. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  291. * @param r defines the red component (between 0 and 1, default is 0)
  292. * @param g defines the green component (between 0 and 1, default is 0)
  293. * @param b defines the blue component (between 0 and 1, default is 0)
  294. */
  295. constructor(
  296. /**
  297. * Defines the red component (between 0 and 1, default is 0)
  298. */
  299. r?: number,
  300. /**
  301. * Defines the green component (between 0 and 1, default is 0)
  302. */
  303. g?: number,
  304. /**
  305. * Defines the blue component (between 0 and 1, default is 0)
  306. */
  307. b?: number);
  308. /**
  309. * Creates a string with the Color3 current values
  310. * @returns the string representation of the Color3 object
  311. */
  312. toString(): string;
  313. /**
  314. * Returns the string "Color3"
  315. * @returns "Color3"
  316. */
  317. getClassName(): string;
  318. /**
  319. * Compute the Color3 hash code
  320. * @returns an unique number that can be used to hash Color3 objects
  321. */
  322. getHashCode(): number;
  323. /**
  324. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  325. * @param array defines the array where to store the r,g,b components
  326. * @param index defines an optional index in the target array to define where to start storing values
  327. * @returns the current Color3 object
  328. */
  329. toArray(array: FloatArray, index?: number): Color3;
  330. /**
  331. * Returns a new Color4 object from the current Color3 and the given alpha
  332. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  333. * @returns a new Color4 object
  334. */
  335. toColor4(alpha?: number): Color4;
  336. /**
  337. * Returns a new array populated with 3 numeric elements : red, green and blue values
  338. * @returns the new array
  339. */
  340. asArray(): number[];
  341. /**
  342. * Returns the luminance value
  343. * @returns a float value
  344. */
  345. toLuminance(): number;
  346. /**
  347. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  348. * @param otherColor defines the second operand
  349. * @returns the new Color3 object
  350. */
  351. multiply(otherColor: DeepImmutable<Color3>): Color3;
  352. /**
  353. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  354. * @param otherColor defines the second operand
  355. * @param result defines the Color3 object where to store the result
  356. * @returns the current Color3
  357. */
  358. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  359. /**
  360. * Determines equality between Color3 objects
  361. * @param otherColor defines the second operand
  362. * @returns true if the rgb values are equal to the given ones
  363. */
  364. equals(otherColor: DeepImmutable<Color3>): boolean;
  365. /**
  366. * Determines equality between the current Color3 object and a set of r,b,g values
  367. * @param r defines the red component to check
  368. * @param g defines the green component to check
  369. * @param b defines the blue component to check
  370. * @returns true if the rgb values are equal to the given ones
  371. */
  372. equalsFloats(r: number, g: number, b: number): boolean;
  373. /**
  374. * Multiplies in place each rgb value by scale
  375. * @param scale defines the scaling factor
  376. * @returns the updated Color3
  377. */
  378. scale(scale: number): Color3;
  379. /**
  380. * Multiplies the rgb values by scale and stores the result into "result"
  381. * @param scale defines the scaling factor
  382. * @param result defines the Color3 object where to store the result
  383. * @returns the unmodified current Color3
  384. */
  385. scaleToRef(scale: number, result: Color3): Color3;
  386. /**
  387. * Scale the current Color3 values by a factor and add the result to a given Color3
  388. * @param scale defines the scale factor
  389. * @param result defines color to store the result into
  390. * @returns the unmodified current Color3
  391. */
  392. scaleAndAddToRef(scale: number, result: Color3): Color3;
  393. /**
  394. * Clamps the rgb values by the min and max values and stores the result into "result"
  395. * @param min defines minimum clamping value (default is 0)
  396. * @param max defines maximum clamping value (default is 1)
  397. * @param result defines color to store the result into
  398. * @returns the original Color3
  399. */
  400. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  401. /**
  402. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  403. * @param otherColor defines the second operand
  404. * @returns the new Color3
  405. */
  406. add(otherColor: DeepImmutable<Color3>): Color3;
  407. /**
  408. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  409. * @param otherColor defines the second operand
  410. * @param result defines Color3 object to store the result into
  411. * @returns the unmodified current Color3
  412. */
  413. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  414. /**
  415. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  416. * @param otherColor defines the second operand
  417. * @returns the new Color3
  418. */
  419. subtract(otherColor: DeepImmutable<Color3>): Color3;
  420. /**
  421. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  422. * @param otherColor defines the second operand
  423. * @param result defines Color3 object to store the result into
  424. * @returns the unmodified current Color3
  425. */
  426. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  427. /**
  428. * Copy the current object
  429. * @returns a new Color3 copied the current one
  430. */
  431. clone(): Color3;
  432. /**
  433. * Copies the rgb values from the source in the current Color3
  434. * @param source defines the source Color3 object
  435. * @returns the updated Color3 object
  436. */
  437. copyFrom(source: DeepImmutable<Color3>): Color3;
  438. /**
  439. * Updates the Color3 rgb values from the given floats
  440. * @param r defines the red component to read from
  441. * @param g defines the green component to read from
  442. * @param b defines the blue component to read from
  443. * @returns the current Color3 object
  444. */
  445. copyFromFloats(r: number, g: number, b: number): Color3;
  446. /**
  447. * Updates the Color3 rgb values from the given floats
  448. * @param r defines the red component to read from
  449. * @param g defines the green component to read from
  450. * @param b defines the blue component to read from
  451. * @returns the current Color3 object
  452. */
  453. set(r: number, g: number, b: number): Color3;
  454. /**
  455. * Compute the Color3 hexadecimal code as a string
  456. * @returns a string containing the hexadecimal representation of the Color3 object
  457. */
  458. toHexString(): string;
  459. /**
  460. * Computes a new Color3 converted from the current one to linear space
  461. * @returns a new Color3 object
  462. */
  463. toLinearSpace(): Color3;
  464. /**
  465. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  466. * @param convertedColor defines the Color3 object where to store the linear space version
  467. * @returns the unmodified Color3
  468. */
  469. toLinearSpaceToRef(convertedColor: Color3): Color3;
  470. /**
  471. * Computes a new Color3 converted from the current one to gamma space
  472. * @returns a new Color3 object
  473. */
  474. toGammaSpace(): Color3;
  475. /**
  476. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  477. * @param convertedColor defines the Color3 object where to store the gamma space version
  478. * @returns the unmodified Color3
  479. */
  480. toGammaSpaceToRef(convertedColor: Color3): Color3;
  481. private static _BlackReadOnly;
  482. /**
  483. * Creates a new Color3 from the string containing valid hexadecimal values
  484. * @param hex defines a string containing valid hexadecimal values
  485. * @returns a new Color3 object
  486. */
  487. static FromHexString(hex: string): Color3;
  488. /**
  489. * Creates a new Color3 from the starting index of the given array
  490. * @param array defines the source array
  491. * @param offset defines an offset in the source array
  492. * @returns a new Color3 object
  493. */
  494. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  495. /**
  496. * Creates a new Color3 from integer values (< 256)
  497. * @param r defines the red component to read from (value between 0 and 255)
  498. * @param g defines the green component to read from (value between 0 and 255)
  499. * @param b defines the blue component to read from (value between 0 and 255)
  500. * @returns a new Color3 object
  501. */
  502. static FromInts(r: number, g: number, b: number): Color3;
  503. /**
  504. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  505. * @param start defines the start Color3 value
  506. * @param end defines the end Color3 value
  507. * @param amount defines the gradient value between start and end
  508. * @returns a new Color3 object
  509. */
  510. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  511. /**
  512. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  513. * @param left defines the start value
  514. * @param right defines the end value
  515. * @param amount defines the gradient factor
  516. * @param result defines the Color3 object where to store the result
  517. */
  518. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  519. /**
  520. * Returns a Color3 value containing a red color
  521. * @returns a new Color3 object
  522. */
  523. static Red(): Color3;
  524. /**
  525. * Returns a Color3 value containing a green color
  526. * @returns a new Color3 object
  527. */
  528. static Green(): Color3;
  529. /**
  530. * Returns a Color3 value containing a blue color
  531. * @returns a new Color3 object
  532. */
  533. static Blue(): Color3;
  534. /**
  535. * Returns a Color3 value containing a black color
  536. * @returns a new Color3 object
  537. */
  538. static Black(): Color3;
  539. /**
  540. * Gets a Color3 value containing a black color that must not be updated
  541. */
  542. static readonly BlackReadOnly: DeepImmutable<Color3>;
  543. /**
  544. * Returns a Color3 value containing a white color
  545. * @returns a new Color3 object
  546. */
  547. static White(): Color3;
  548. /**
  549. * Returns a Color3 value containing a purple color
  550. * @returns a new Color3 object
  551. */
  552. static Purple(): Color3;
  553. /**
  554. * Returns a Color3 value containing a magenta color
  555. * @returns a new Color3 object
  556. */
  557. static Magenta(): Color3;
  558. /**
  559. * Returns a Color3 value containing a yellow color
  560. * @returns a new Color3 object
  561. */
  562. static Yellow(): Color3;
  563. /**
  564. * Returns a Color3 value containing a gray color
  565. * @returns a new Color3 object
  566. */
  567. static Gray(): Color3;
  568. /**
  569. * Returns a Color3 value containing a teal color
  570. * @returns a new Color3 object
  571. */
  572. static Teal(): Color3;
  573. /**
  574. * Returns a Color3 value containing a random color
  575. * @returns a new Color3 object
  576. */
  577. static Random(): Color3;
  578. }
  579. /**
  580. * Class used to hold a RBGA color
  581. */
  582. export class Color4 {
  583. /**
  584. * Defines the red component (between 0 and 1, default is 0)
  585. */
  586. r: number;
  587. /**
  588. * Defines the green component (between 0 and 1, default is 0)
  589. */
  590. g: number;
  591. /**
  592. * Defines the blue component (between 0 and 1, default is 0)
  593. */
  594. b: number;
  595. /**
  596. * Defines the alpha component (between 0 and 1, default is 1)
  597. */
  598. a: number;
  599. /**
  600. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  601. * @param r defines the red component (between 0 and 1, default is 0)
  602. * @param g defines the green component (between 0 and 1, default is 0)
  603. * @param b defines the blue component (between 0 and 1, default is 0)
  604. * @param a defines the alpha component (between 0 and 1, default is 1)
  605. */
  606. constructor(
  607. /**
  608. * Defines the red component (between 0 and 1, default is 0)
  609. */
  610. r?: number,
  611. /**
  612. * Defines the green component (between 0 and 1, default is 0)
  613. */
  614. g?: number,
  615. /**
  616. * Defines the blue component (between 0 and 1, default is 0)
  617. */
  618. b?: number,
  619. /**
  620. * Defines the alpha component (between 0 and 1, default is 1)
  621. */
  622. a?: number);
  623. /**
  624. * Adds in place the given Color4 values to the current Color4 object
  625. * @param right defines the second operand
  626. * @returns the current updated Color4 object
  627. */
  628. addInPlace(right: DeepImmutable<Color4>): Color4;
  629. /**
  630. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  631. * @returns the new array
  632. */
  633. asArray(): number[];
  634. /**
  635. * Stores from the starting index in the given array the Color4 successive values
  636. * @param array defines the array where to store the r,g,b components
  637. * @param index defines an optional index in the target array to define where to start storing values
  638. * @returns the current Color4 object
  639. */
  640. toArray(array: number[], index?: number): Color4;
  641. /**
  642. * Determines equality between Color4 objects
  643. * @param otherColor defines the second operand
  644. * @returns true if the rgba values are equal to the given ones
  645. */
  646. equals(otherColor: DeepImmutable<Color4>): boolean;
  647. /**
  648. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  649. * @param right defines the second operand
  650. * @returns a new Color4 object
  651. */
  652. add(right: DeepImmutable<Color4>): Color4;
  653. /**
  654. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  655. * @param right defines the second operand
  656. * @returns a new Color4 object
  657. */
  658. subtract(right: DeepImmutable<Color4>): Color4;
  659. /**
  660. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  661. * @param right defines the second operand
  662. * @param result defines the Color4 object where to store the result
  663. * @returns the current Color4 object
  664. */
  665. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  666. /**
  667. * Creates a new Color4 with the current Color4 values multiplied by scale
  668. * @param scale defines the scaling factor to apply
  669. * @returns a new Color4 object
  670. */
  671. scale(scale: number): Color4;
  672. /**
  673. * Multiplies the current Color4 values by scale and stores the result in "result"
  674. * @param scale defines the scaling factor to apply
  675. * @param result defines the Color4 object where to store the result
  676. * @returns the current unmodified Color4
  677. */
  678. scaleToRef(scale: number, result: Color4): Color4;
  679. /**
  680. * Scale the current Color4 values by a factor and add the result to a given Color4
  681. * @param scale defines the scale factor
  682. * @param result defines the Color4 object where to store the result
  683. * @returns the unmodified current Color4
  684. */
  685. scaleAndAddToRef(scale: number, result: Color4): Color4;
  686. /**
  687. * Clamps the rgb values by the min and max values and stores the result into "result"
  688. * @param min defines minimum clamping value (default is 0)
  689. * @param max defines maximum clamping value (default is 1)
  690. * @param result defines color to store the result into.
  691. * @returns the cuurent Color4
  692. */
  693. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  694. /**
  695. * Multipy an Color4 value by another and return a new Color4 object
  696. * @param color defines the Color4 value to multiply by
  697. * @returns a new Color4 object
  698. */
  699. multiply(color: Color4): Color4;
  700. /**
  701. * Multipy a Color4 value by another and push the result in a reference value
  702. * @param color defines the Color4 value to multiply by
  703. * @param result defines the Color4 to fill the result in
  704. * @returns the result Color4
  705. */
  706. multiplyToRef(color: Color4, result: Color4): Color4;
  707. /**
  708. * Creates a string with the Color4 current values
  709. * @returns the string representation of the Color4 object
  710. */
  711. toString(): string;
  712. /**
  713. * Returns the string "Color4"
  714. * @returns "Color4"
  715. */
  716. getClassName(): string;
  717. /**
  718. * Compute the Color4 hash code
  719. * @returns an unique number that can be used to hash Color4 objects
  720. */
  721. getHashCode(): number;
  722. /**
  723. * Creates a new Color4 copied from the current one
  724. * @returns a new Color4 object
  725. */
  726. clone(): Color4;
  727. /**
  728. * Copies the given Color4 values into the current one
  729. * @param source defines the source Color4 object
  730. * @returns the current updated Color4 object
  731. */
  732. copyFrom(source: Color4): Color4;
  733. /**
  734. * Copies the given float values into the current one
  735. * @param r defines the red component to read from
  736. * @param g defines the green component to read from
  737. * @param b defines the blue component to read from
  738. * @param a defines the alpha component to read from
  739. * @returns the current updated Color4 object
  740. */
  741. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  742. /**
  743. * Copies the given float values into the current one
  744. * @param r defines the red component to read from
  745. * @param g defines the green component to read from
  746. * @param b defines the blue component to read from
  747. * @param a defines the alpha component to read from
  748. * @returns the current updated Color4 object
  749. */
  750. set(r: number, g: number, b: number, a: number): Color4;
  751. /**
  752. * Compute the Color4 hexadecimal code as a string
  753. * @returns a string containing the hexadecimal representation of the Color4 object
  754. */
  755. toHexString(): string;
  756. /**
  757. * Computes a new Color4 converted from the current one to linear space
  758. * @returns a new Color4 object
  759. */
  760. toLinearSpace(): Color4;
  761. /**
  762. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  763. * @param convertedColor defines the Color4 object where to store the linear space version
  764. * @returns the unmodified Color4
  765. */
  766. toLinearSpaceToRef(convertedColor: Color4): Color4;
  767. /**
  768. * Computes a new Color4 converted from the current one to gamma space
  769. * @returns a new Color4 object
  770. */
  771. toGammaSpace(): Color4;
  772. /**
  773. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  774. * @param convertedColor defines the Color4 object where to store the gamma space version
  775. * @returns the unmodified Color4
  776. */
  777. toGammaSpaceToRef(convertedColor: Color4): Color4;
  778. /**
  779. * Creates a new Color4 from the string containing valid hexadecimal values
  780. * @param hex defines a string containing valid hexadecimal values
  781. * @returns a new Color4 object
  782. */
  783. static FromHexString(hex: string): Color4;
  784. /**
  785. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  786. * @param left defines the start value
  787. * @param right defines the end value
  788. * @param amount defines the gradient factor
  789. * @returns a new Color4 object
  790. */
  791. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  792. /**
  793. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  794. * @param left defines the start value
  795. * @param right defines the end value
  796. * @param amount defines the gradient factor
  797. * @param result defines the Color4 object where to store data
  798. */
  799. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  800. /**
  801. * Creates a new Color4 from a Color3 and an alpha value
  802. * @param color3 defines the source Color3 to read from
  803. * @param alpha defines the alpha component (1.0 by default)
  804. * @returns a new Color4 object
  805. */
  806. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  807. /**
  808. * Creates a new Color4 from the starting index element of the given array
  809. * @param array defines the source array to read from
  810. * @param offset defines the offset in the source array
  811. * @returns a new Color4 object
  812. */
  813. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  814. /**
  815. * Creates a new Color3 from integer values (< 256)
  816. * @param r defines the red component to read from (value between 0 and 255)
  817. * @param g defines the green component to read from (value between 0 and 255)
  818. * @param b defines the blue component to read from (value between 0 and 255)
  819. * @param a defines the alpha component to read from (value between 0 and 255)
  820. * @returns a new Color3 object
  821. */
  822. static FromInts(r: number, g: number, b: number, a: number): Color4;
  823. /**
  824. * Check the content of a given array and convert it to an array containing RGBA data
  825. * If the original array was already containing count * 4 values then it is returned directly
  826. * @param colors defines the array to check
  827. * @param count defines the number of RGBA data to expect
  828. * @returns an array containing count * 4 values (RGBA)
  829. */
  830. static CheckColors4(colors: number[], count: number): number[];
  831. }
  832. /**
  833. * Class representing a vector containing 2 coordinates
  834. */
  835. export class Vector2 {
  836. /** defines the first coordinate */
  837. x: number;
  838. /** defines the second coordinate */
  839. y: number;
  840. /**
  841. * Creates a new Vector2 from the given x and y coordinates
  842. * @param x defines the first coordinate
  843. * @param y defines the second coordinate
  844. */
  845. constructor(
  846. /** defines the first coordinate */
  847. x?: number,
  848. /** defines the second coordinate */
  849. y?: number);
  850. /**
  851. * Gets a string with the Vector2 coordinates
  852. * @returns a string with the Vector2 coordinates
  853. */
  854. toString(): string;
  855. /**
  856. * Gets class name
  857. * @returns the string "Vector2"
  858. */
  859. getClassName(): string;
  860. /**
  861. * Gets current vector hash code
  862. * @returns the Vector2 hash code as a number
  863. */
  864. getHashCode(): number;
  865. /**
  866. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  867. * @param array defines the source array
  868. * @param index defines the offset in source array
  869. * @returns the current Vector2
  870. */
  871. toArray(array: FloatArray, index?: number): Vector2;
  872. /**
  873. * Copy the current vector to an array
  874. * @returns a new array with 2 elements: the Vector2 coordinates.
  875. */
  876. asArray(): number[];
  877. /**
  878. * Sets the Vector2 coordinates with the given Vector2 coordinates
  879. * @param source defines the source Vector2
  880. * @returns the current updated Vector2
  881. */
  882. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  883. /**
  884. * Sets the Vector2 coordinates with the given floats
  885. * @param x defines the first coordinate
  886. * @param y defines the second coordinate
  887. * @returns the current updated Vector2
  888. */
  889. copyFromFloats(x: number, y: number): Vector2;
  890. /**
  891. * Sets the Vector2 coordinates with the given floats
  892. * @param x defines the first coordinate
  893. * @param y defines the second coordinate
  894. * @returns the current updated Vector2
  895. */
  896. set(x: number, y: number): Vector2;
  897. /**
  898. * Add another vector with the current one
  899. * @param otherVector defines the other vector
  900. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  901. */
  902. add(otherVector: DeepImmutable<Vector2>): Vector2;
  903. /**
  904. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  905. * @param otherVector defines the other vector
  906. * @param result defines the target vector
  907. * @returns the unmodified current Vector2
  908. */
  909. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  910. /**
  911. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  912. * @param otherVector defines the other vector
  913. * @returns the current updated Vector2
  914. */
  915. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  916. /**
  917. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  918. * @param otherVector defines the other vector
  919. * @returns a new Vector2
  920. */
  921. addVector3(otherVector: Vector3): Vector2;
  922. /**
  923. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  924. * @param otherVector defines the other vector
  925. * @returns a new Vector2
  926. */
  927. subtract(otherVector: Vector2): Vector2;
  928. /**
  929. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  930. * @param otherVector defines the other vector
  931. * @param result defines the target vector
  932. * @returns the unmodified current Vector2
  933. */
  934. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  935. /**
  936. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  937. * @param otherVector defines the other vector
  938. * @returns the current updated Vector2
  939. */
  940. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  941. /**
  942. * Multiplies in place the current Vector2 coordinates by the given ones
  943. * @param otherVector defines the other vector
  944. * @returns the current updated Vector2
  945. */
  946. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  947. /**
  948. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  949. * @param otherVector defines the other vector
  950. * @returns a new Vector2
  951. */
  952. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  953. /**
  954. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  955. * @param otherVector defines the other vector
  956. * @param result defines the target vector
  957. * @returns the unmodified current Vector2
  958. */
  959. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  960. /**
  961. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  962. * @param x defines the first coordinate
  963. * @param y defines the second coordinate
  964. * @returns a new Vector2
  965. */
  966. multiplyByFloats(x: number, y: number): Vector2;
  967. /**
  968. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  969. * @param otherVector defines the other vector
  970. * @returns a new Vector2
  971. */
  972. divide(otherVector: Vector2): Vector2;
  973. /**
  974. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  975. * @param otherVector defines the other vector
  976. * @param result defines the target vector
  977. * @returns the unmodified current Vector2
  978. */
  979. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  980. /**
  981. * Divides the current Vector2 coordinates by the given ones
  982. * @param otherVector defines the other vector
  983. * @returns the current updated Vector2
  984. */
  985. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  986. /**
  987. * Gets a new Vector2 with current Vector2 negated coordinates
  988. * @returns a new Vector2
  989. */
  990. negate(): Vector2;
  991. /**
  992. * Multiply the Vector2 coordinates by scale
  993. * @param scale defines the scaling factor
  994. * @returns the current updated Vector2
  995. */
  996. scaleInPlace(scale: number): Vector2;
  997. /**
  998. * Returns a new Vector2 scaled by "scale" from the current Vector2
  999. * @param scale defines the scaling factor
  1000. * @returns a new Vector2
  1001. */
  1002. scale(scale: number): Vector2;
  1003. /**
  1004. * Scale the current Vector2 values by a factor to a given Vector2
  1005. * @param scale defines the scale factor
  1006. * @param result defines the Vector2 object where to store the result
  1007. * @returns the unmodified current Vector2
  1008. */
  1009. scaleToRef(scale: number, result: Vector2): Vector2;
  1010. /**
  1011. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1012. * @param scale defines the scale factor
  1013. * @param result defines the Vector2 object where to store the result
  1014. * @returns the unmodified current Vector2
  1015. */
  1016. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1017. /**
  1018. * Gets a boolean if two vectors are equals
  1019. * @param otherVector defines the other vector
  1020. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1021. */
  1022. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1023. /**
  1024. * Gets a boolean if two vectors are equals (using an epsilon value)
  1025. * @param otherVector defines the other vector
  1026. * @param epsilon defines the minimal distance to consider equality
  1027. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1028. */
  1029. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1030. /**
  1031. * Gets a new Vector2 from current Vector2 floored values
  1032. * @returns a new Vector2
  1033. */
  1034. floor(): Vector2;
  1035. /**
  1036. * Gets a new Vector2 from current Vector2 floored values
  1037. * @returns a new Vector2
  1038. */
  1039. fract(): Vector2;
  1040. /**
  1041. * Gets the length of the vector
  1042. * @returns the vector length (float)
  1043. */
  1044. length(): number;
  1045. /**
  1046. * Gets the vector squared length
  1047. * @returns the vector squared length (float)
  1048. */
  1049. lengthSquared(): number;
  1050. /**
  1051. * Normalize the vector
  1052. * @returns the current updated Vector2
  1053. */
  1054. normalize(): Vector2;
  1055. /**
  1056. * Gets a new Vector2 copied from the Vector2
  1057. * @returns a new Vector2
  1058. */
  1059. clone(): Vector2;
  1060. /**
  1061. * Gets a new Vector2(0, 0)
  1062. * @returns a new Vector2
  1063. */
  1064. static Zero(): Vector2;
  1065. /**
  1066. * Gets a new Vector2(1, 1)
  1067. * @returns a new Vector2
  1068. */
  1069. static One(): Vector2;
  1070. /**
  1071. * Gets a new Vector2 set from the given index element of the given array
  1072. * @param array defines the data source
  1073. * @param offset defines the offset in the data source
  1074. * @returns a new Vector2
  1075. */
  1076. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1077. /**
  1078. * Sets "result" from the given index element of the given array
  1079. * @param array defines the data source
  1080. * @param offset defines the offset in the data source
  1081. * @param result defines the target vector
  1082. */
  1083. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1084. /**
  1085. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1086. * @param value1 defines 1st point of control
  1087. * @param value2 defines 2nd point of control
  1088. * @param value3 defines 3rd point of control
  1089. * @param value4 defines 4th point of control
  1090. * @param amount defines the interpolation factor
  1091. * @returns a new Vector2
  1092. */
  1093. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1094. /**
  1095. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  1096. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1097. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1098. * @param value defines the value to clamp
  1099. * @param min defines the lower limit
  1100. * @param max defines the upper limit
  1101. * @returns a new Vector2
  1102. */
  1103. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1104. /**
  1105. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1106. * @param value1 defines the 1st control point
  1107. * @param tangent1 defines the outgoing tangent
  1108. * @param value2 defines the 2nd control point
  1109. * @param tangent2 defines the incoming tangent
  1110. * @param amount defines the interpolation factor
  1111. * @returns a new Vector2
  1112. */
  1113. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1114. /**
  1115. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1116. * @param start defines the start vector
  1117. * @param end defines the end vector
  1118. * @param amount defines the interpolation factor
  1119. * @returns a new Vector2
  1120. */
  1121. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1122. /**
  1123. * Gets the dot product of the vector "left" and the vector "right"
  1124. * @param left defines first vector
  1125. * @param right defines second vector
  1126. * @returns the dot product (float)
  1127. */
  1128. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1129. /**
  1130. * Returns a new Vector2 equal to the normalized given vector
  1131. * @param vector defines the vector to normalize
  1132. * @returns a new Vector2
  1133. */
  1134. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1135. /**
  1136. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1137. * @param left defines 1st vector
  1138. * @param right defines 2nd vector
  1139. * @returns a new Vector2
  1140. */
  1141. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1142. /**
  1143. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1144. * @param left defines 1st vector
  1145. * @param right defines 2nd vector
  1146. * @returns a new Vector2
  1147. */
  1148. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1149. /**
  1150. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1151. * @param vector defines the vector to transform
  1152. * @param transformation defines the matrix to apply
  1153. * @returns a new Vector2
  1154. */
  1155. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1156. /**
  1157. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1158. * @param vector defines the vector to transform
  1159. * @param transformation defines the matrix to apply
  1160. * @param result defines the target vector
  1161. */
  1162. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1163. /**
  1164. * Determines if a given vector is included in a triangle
  1165. * @param p defines the vector to test
  1166. * @param p0 defines 1st triangle point
  1167. * @param p1 defines 2nd triangle point
  1168. * @param p2 defines 3rd triangle point
  1169. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1170. */
  1171. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1172. /**
  1173. * Gets the distance between the vectors "value1" and "value2"
  1174. * @param value1 defines first vector
  1175. * @param value2 defines second vector
  1176. * @returns the distance between vectors
  1177. */
  1178. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1179. /**
  1180. * Returns the squared distance between the vectors "value1" and "value2"
  1181. * @param value1 defines first vector
  1182. * @param value2 defines second vector
  1183. * @returns the squared distance between vectors
  1184. */
  1185. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1186. /**
  1187. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1188. * @param value1 defines first vector
  1189. * @param value2 defines second vector
  1190. * @returns a new Vector2
  1191. */
  1192. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1193. /**
  1194. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1195. * @param p defines the middle point
  1196. * @param segA defines one point of the segment
  1197. * @param segB defines the other point of the segment
  1198. * @returns the shortest distance
  1199. */
  1200. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1201. }
  1202. /**
  1203. * Classed used to store (x,y,z) vector representation
  1204. * A Vector3 is the main object used in 3D geometry
  1205. * It can represent etiher the coordinates of a point the space, either a direction
  1206. * Reminder: js uses a left handed forward facing system
  1207. */
  1208. export class Vector3 {
  1209. /**
  1210. * Defines the first coordinates (on X axis)
  1211. */
  1212. x: number;
  1213. /**
  1214. * Defines the second coordinates (on Y axis)
  1215. */
  1216. y: number;
  1217. /**
  1218. * Defines the third coordinates (on Z axis)
  1219. */
  1220. z: number;
  1221. private static _UpReadOnly;
  1222. /**
  1223. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1224. * @param x defines the first coordinates (on X axis)
  1225. * @param y defines the second coordinates (on Y axis)
  1226. * @param z defines the third coordinates (on Z axis)
  1227. */
  1228. constructor(
  1229. /**
  1230. * Defines the first coordinates (on X axis)
  1231. */
  1232. x?: number,
  1233. /**
  1234. * Defines the second coordinates (on Y axis)
  1235. */
  1236. y?: number,
  1237. /**
  1238. * Defines the third coordinates (on Z axis)
  1239. */
  1240. z?: number);
  1241. /**
  1242. * Creates a string representation of the Vector3
  1243. * @returns a string with the Vector3 coordinates.
  1244. */
  1245. toString(): string;
  1246. /**
  1247. * Gets the class name
  1248. * @returns the string "Vector3"
  1249. */
  1250. getClassName(): string;
  1251. /**
  1252. * Creates the Vector3 hash code
  1253. * @returns a number which tends to be unique between Vector3 instances
  1254. */
  1255. getHashCode(): number;
  1256. /**
  1257. * Creates an array containing three elements : the coordinates of the Vector3
  1258. * @returns a new array of numbers
  1259. */
  1260. asArray(): number[];
  1261. /**
  1262. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1263. * @param array defines the destination array
  1264. * @param index defines the offset in the destination array
  1265. * @returns the current Vector3
  1266. */
  1267. toArray(array: FloatArray, index?: number): Vector3;
  1268. /**
  1269. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1270. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1271. */
  1272. toQuaternion(): Quaternion;
  1273. /**
  1274. * Adds the given vector to the current Vector3
  1275. * @param otherVector defines the second operand
  1276. * @returns the current updated Vector3
  1277. */
  1278. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1279. /**
  1280. * Adds the given coordinates to the current Vector3
  1281. * @param x defines the x coordinate of the operand
  1282. * @param y defines the y coordinate of the operand
  1283. * @param z defines the z coordinate of the operand
  1284. * @returns the current updated Vector3
  1285. */
  1286. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1287. /**
  1288. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1289. * @param otherVector defines the second operand
  1290. * @returns the resulting Vector3
  1291. */
  1292. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1293. /**
  1294. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1295. * @param otherVector defines the second operand
  1296. * @param result defines the Vector3 object where to store the result
  1297. * @returns the current Vector3
  1298. */
  1299. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1300. /**
  1301. * Subtract the given vector from the current Vector3
  1302. * @param otherVector defines the second operand
  1303. * @returns the current updated Vector3
  1304. */
  1305. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1306. /**
  1307. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1308. * @param otherVector defines the second operand
  1309. * @returns the resulting Vector3
  1310. */
  1311. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1312. /**
  1313. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1314. * @param otherVector defines the second operand
  1315. * @param result defines the Vector3 object where to store the result
  1316. * @returns the current Vector3
  1317. */
  1318. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1319. /**
  1320. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1321. * @param x defines the x coordinate of the operand
  1322. * @param y defines the y coordinate of the operand
  1323. * @param z defines the z coordinate of the operand
  1324. * @returns the resulting Vector3
  1325. */
  1326. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1327. /**
  1328. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1329. * @param x defines the x coordinate of the operand
  1330. * @param y defines the y coordinate of the operand
  1331. * @param z defines the z coordinate of the operand
  1332. * @param result defines the Vector3 object where to store the result
  1333. * @returns the current Vector3
  1334. */
  1335. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1336. /**
  1337. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1338. * @returns a new Vector3
  1339. */
  1340. negate(): Vector3;
  1341. /**
  1342. * Multiplies the Vector3 coordinates by the float "scale"
  1343. * @param scale defines the multiplier factor
  1344. * @returns the current updated Vector3
  1345. */
  1346. scaleInPlace(scale: number): Vector3;
  1347. /**
  1348. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1349. * @param scale defines the multiplier factor
  1350. * @returns a new Vector3
  1351. */
  1352. scale(scale: number): Vector3;
  1353. /**
  1354. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1355. * @param scale defines the multiplier factor
  1356. * @param result defines the Vector3 object where to store the result
  1357. * @returns the current Vector3
  1358. */
  1359. scaleToRef(scale: number, result: Vector3): Vector3;
  1360. /**
  1361. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1362. * @param scale defines the scale factor
  1363. * @param result defines the Vector3 object where to store the result
  1364. * @returns the unmodified current Vector3
  1365. */
  1366. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1367. /**
  1368. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1369. * @param otherVector defines the second operand
  1370. * @returns true if both vectors are equals
  1371. */
  1372. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1373. /**
  1374. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1375. * @param otherVector defines the second operand
  1376. * @param epsilon defines the minimal distance to define values as equals
  1377. * @returns true if both vectors are distant less than epsilon
  1378. */
  1379. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1380. /**
  1381. * Returns true if the current Vector3 coordinates equals the given floats
  1382. * @param x defines the x coordinate of the operand
  1383. * @param y defines the y coordinate of the operand
  1384. * @param z defines the z coordinate of the operand
  1385. * @returns true if both vectors are equals
  1386. */
  1387. equalsToFloats(x: number, y: number, z: number): boolean;
  1388. /**
  1389. * Multiplies the current Vector3 coordinates by the given ones
  1390. * @param otherVector defines the second operand
  1391. * @returns the current updated Vector3
  1392. */
  1393. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1394. /**
  1395. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1396. * @param otherVector defines the second operand
  1397. * @returns the new Vector3
  1398. */
  1399. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1400. /**
  1401. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1402. * @param otherVector defines the second operand
  1403. * @param result defines the Vector3 object where to store the result
  1404. * @returns the current Vector3
  1405. */
  1406. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1407. /**
  1408. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1409. * @param x defines the x coordinate of the operand
  1410. * @param y defines the y coordinate of the operand
  1411. * @param z defines the z coordinate of the operand
  1412. * @returns the new Vector3
  1413. */
  1414. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1415. /**
  1416. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1417. * @param otherVector defines the second operand
  1418. * @returns the new Vector3
  1419. */
  1420. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1421. /**
  1422. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1423. * @param otherVector defines the second operand
  1424. * @param result defines the Vector3 object where to store the result
  1425. * @returns the current Vector3
  1426. */
  1427. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1428. /**
  1429. * Divides the current Vector3 coordinates by the given ones.
  1430. * @param otherVector defines the second operand
  1431. * @returns the current updated Vector3
  1432. */
  1433. divideInPlace(otherVector: Vector3): Vector3;
  1434. /**
  1435. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1436. * @param other defines the second operand
  1437. * @returns the current updated Vector3
  1438. */
  1439. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1440. /**
  1441. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1442. * @param other defines the second operand
  1443. * @returns the current updated Vector3
  1444. */
  1445. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1446. /**
  1447. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  1448. * @param x defines the x coordinate of the operand
  1449. * @param y defines the y coordinate of the operand
  1450. * @param z defines the z coordinate of the operand
  1451. * @returns the current updated Vector3
  1452. */
  1453. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1454. /**
  1455. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  1456. * @param x defines the x coordinate of the operand
  1457. * @param y defines the y coordinate of the operand
  1458. * @param z defines the z coordinate of the operand
  1459. * @returns the current updated Vector3
  1460. */
  1461. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1462. /**
  1463. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  1464. * Check if is non uniform within a certain amount of decimal places to account for this
  1465. * @param epsilon the amount the values can differ
  1466. * @returns if the the vector is non uniform to a certain number of decimal places
  1467. */
  1468. isNonUniformWithinEpsilon(epsilon: number): boolean;
  1469. /**
  1470. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  1471. */
  1472. readonly isNonUniform: boolean;
  1473. /**
  1474. * Gets a new Vector3 from current Vector3 floored values
  1475. * @returns a new Vector3
  1476. */
  1477. floor(): Vector3;
  1478. /**
  1479. * Gets a new Vector3 from current Vector3 floored values
  1480. * @returns a new Vector3
  1481. */
  1482. fract(): Vector3;
  1483. /**
  1484. * Gets the length of the Vector3
  1485. * @returns the length of the Vecto3
  1486. */
  1487. length(): number;
  1488. /**
  1489. * Gets the squared length of the Vector3
  1490. * @returns squared length of the Vector3
  1491. */
  1492. lengthSquared(): number;
  1493. /**
  1494. * Normalize the current Vector3.
  1495. * Please note that this is an in place operation.
  1496. * @returns the current updated Vector3
  1497. */
  1498. normalize(): Vector3;
  1499. /**
  1500. * Reorders the x y z properties of the vector in place
  1501. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  1502. * @returns the current updated vector
  1503. */
  1504. reorderInPlace(order: string): this;
  1505. /**
  1506. * Rotates the vector around 0,0,0 by a quaternion
  1507. * @param quaternion the rotation quaternion
  1508. * @param result vector to store the result
  1509. * @returns the resulting vector
  1510. */
  1511. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  1512. /**
  1513. * Rotates a vector around a given point
  1514. * @param quaternion the rotation quaternion
  1515. * @param point the point to rotate around
  1516. * @param result vector to store the result
  1517. * @returns the resulting vector
  1518. */
  1519. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  1520. /**
  1521. * Normalize the current Vector3 with the given input length.
  1522. * Please note that this is an in place operation.
  1523. * @param len the length of the vector
  1524. * @returns the current updated Vector3
  1525. */
  1526. normalizeFromLength(len: number): Vector3;
  1527. /**
  1528. * Normalize the current Vector3 to a new vector
  1529. * @returns the new Vector3
  1530. */
  1531. normalizeToNew(): Vector3;
  1532. /**
  1533. * Normalize the current Vector3 to the reference
  1534. * @param reference define the Vector3 to update
  1535. * @returns the updated Vector3
  1536. */
  1537. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  1538. /**
  1539. * Creates a new Vector3 copied from the current Vector3
  1540. * @returns the new Vector3
  1541. */
  1542. clone(): Vector3;
  1543. /**
  1544. * Copies the given vector coordinates to the current Vector3 ones
  1545. * @param source defines the source Vector3
  1546. * @returns the current updated Vector3
  1547. */
  1548. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  1549. /**
  1550. * Copies the given floats to the current Vector3 coordinates
  1551. * @param x defines the x coordinate of the operand
  1552. * @param y defines the y coordinate of the operand
  1553. * @param z defines the z coordinate of the operand
  1554. * @returns the current updated Vector3
  1555. */
  1556. copyFromFloats(x: number, y: number, z: number): Vector3;
  1557. /**
  1558. * Copies the given floats to the current Vector3 coordinates
  1559. * @param x defines the x coordinate of the operand
  1560. * @param y defines the y coordinate of the operand
  1561. * @param z defines the z coordinate of the operand
  1562. * @returns the current updated Vector3
  1563. */
  1564. set(x: number, y: number, z: number): Vector3;
  1565. /**
  1566. * Copies the given float to the current Vector3 coordinates
  1567. * @param v defines the x, y and z coordinates of the operand
  1568. * @returns the current updated Vector3
  1569. */
  1570. setAll(v: number): Vector3;
  1571. /**
  1572. * Get the clip factor between two vectors
  1573. * @param vector0 defines the first operand
  1574. * @param vector1 defines the second operand
  1575. * @param axis defines the axis to use
  1576. * @param size defines the size along the axis
  1577. * @returns the clip factor
  1578. */
  1579. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  1580. /**
  1581. * Get angle between two vectors
  1582. * @param vector0 angle between vector0 and vector1
  1583. * @param vector1 angle between vector0 and vector1
  1584. * @param normal direction of the normal
  1585. * @return the angle between vector0 and vector1
  1586. */
  1587. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  1588. /**
  1589. * Returns a new Vector3 set from the index "offset" of the given array
  1590. * @param array defines the source array
  1591. * @param offset defines the offset in the source array
  1592. * @returns the new Vector3
  1593. */
  1594. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  1595. /**
  1596. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  1597. * This function is deprecated. Use FromArray instead
  1598. * @param array defines the source array
  1599. * @param offset defines the offset in the source array
  1600. * @returns the new Vector3
  1601. */
  1602. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  1603. /**
  1604. * Sets the given vector "result" with the element values from the index "offset" of the given array
  1605. * @param array defines the source array
  1606. * @param offset defines the offset in the source array
  1607. * @param result defines the Vector3 where to store the result
  1608. */
  1609. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  1610. /**
  1611. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  1612. * This function is deprecated. Use FromArrayToRef instead.
  1613. * @param array defines the source array
  1614. * @param offset defines the offset in the source array
  1615. * @param result defines the Vector3 where to store the result
  1616. */
  1617. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  1618. /**
  1619. * Sets the given vector "result" with the given floats.
  1620. * @param x defines the x coordinate of the source
  1621. * @param y defines the y coordinate of the source
  1622. * @param z defines the z coordinate of the source
  1623. * @param result defines the Vector3 where to store the result
  1624. */
  1625. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  1626. /**
  1627. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  1628. * @returns a new empty Vector3
  1629. */
  1630. static Zero(): Vector3;
  1631. /**
  1632. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  1633. * @returns a new unit Vector3
  1634. */
  1635. static One(): Vector3;
  1636. /**
  1637. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  1638. * @returns a new up Vector3
  1639. */
  1640. static Up(): Vector3;
  1641. /**
  1642. * Gets a up Vector3 that must not be updated
  1643. */
  1644. static readonly UpReadOnly: DeepImmutable<Vector3>;
  1645. /**
  1646. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  1647. * @returns a new down Vector3
  1648. */
  1649. static Down(): Vector3;
  1650. /**
  1651. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  1652. * @returns a new forward Vector3
  1653. */
  1654. static Forward(): Vector3;
  1655. /**
  1656. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  1657. * @returns a new forward Vector3
  1658. */
  1659. static Backward(): Vector3;
  1660. /**
  1661. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  1662. * @returns a new right Vector3
  1663. */
  1664. static Right(): Vector3;
  1665. /**
  1666. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  1667. * @returns a new left Vector3
  1668. */
  1669. static Left(): Vector3;
  1670. /**
  1671. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  1672. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1673. * @param vector defines the Vector3 to transform
  1674. * @param transformation defines the transformation matrix
  1675. * @returns the transformed Vector3
  1676. */
  1677. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1678. /**
  1679. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  1680. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1681. * @param vector defines the Vector3 to transform
  1682. * @param transformation defines the transformation matrix
  1683. * @param result defines the Vector3 where to store the result
  1684. */
  1685. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1686. /**
  1687. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  1688. * This method computes tranformed coordinates only, not transformed direction vectors
  1689. * @param x define the x coordinate of the source vector
  1690. * @param y define the y coordinate of the source vector
  1691. * @param z define the z coordinate of the source vector
  1692. * @param transformation defines the transformation matrix
  1693. * @param result defines the Vector3 where to store the result
  1694. */
  1695. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1696. /**
  1697. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  1698. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1699. * @param vector defines the Vector3 to transform
  1700. * @param transformation defines the transformation matrix
  1701. * @returns the new Vector3
  1702. */
  1703. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1704. /**
  1705. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  1706. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1707. * @param vector defines the Vector3 to transform
  1708. * @param transformation defines the transformation matrix
  1709. * @param result defines the Vector3 where to store the result
  1710. */
  1711. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1712. /**
  1713. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  1714. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1715. * @param x define the x coordinate of the source vector
  1716. * @param y define the y coordinate of the source vector
  1717. * @param z define the z coordinate of the source vector
  1718. * @param transformation defines the transformation matrix
  1719. * @param result defines the Vector3 where to store the result
  1720. */
  1721. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1722. /**
  1723. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  1724. * @param value1 defines the first control point
  1725. * @param value2 defines the second control point
  1726. * @param value3 defines the third control point
  1727. * @param value4 defines the fourth control point
  1728. * @param amount defines the amount on the spline to use
  1729. * @returns the new Vector3
  1730. */
  1731. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  1732. /**
  1733. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  1734. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1735. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1736. * @param value defines the current value
  1737. * @param min defines the lower range value
  1738. * @param max defines the upper range value
  1739. * @returns the new Vector3
  1740. */
  1741. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  1742. /**
  1743. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  1744. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1745. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1746. * @param value defines the current value
  1747. * @param min defines the lower range value
  1748. * @param max defines the upper range value
  1749. * @param result defines the Vector3 where to store the result
  1750. */
  1751. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  1752. /**
  1753. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  1754. * @param value1 defines the first control point
  1755. * @param tangent1 defines the first tangent vector
  1756. * @param value2 defines the second control point
  1757. * @param tangent2 defines the second tangent vector
  1758. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  1759. * @returns the new Vector3
  1760. */
  1761. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  1762. /**
  1763. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  1764. * @param start defines the start value
  1765. * @param end defines the end value
  1766. * @param amount max defines amount between both (between 0 and 1)
  1767. * @returns the new Vector3
  1768. */
  1769. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  1770. /**
  1771. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  1772. * @param start defines the start value
  1773. * @param end defines the end value
  1774. * @param amount max defines amount between both (between 0 and 1)
  1775. * @param result defines the Vector3 where to store the result
  1776. */
  1777. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  1778. /**
  1779. * Returns the dot product (float) between the vectors "left" and "right"
  1780. * @param left defines the left operand
  1781. * @param right defines the right operand
  1782. * @returns the dot product
  1783. */
  1784. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  1785. /**
  1786. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  1787. * The cross product is then orthogonal to both "left" and "right"
  1788. * @param left defines the left operand
  1789. * @param right defines the right operand
  1790. * @returns the cross product
  1791. */
  1792. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1793. /**
  1794. * Sets the given vector "result" with the cross product of "left" and "right"
  1795. * The cross product is then orthogonal to both "left" and "right"
  1796. * @param left defines the left operand
  1797. * @param right defines the right operand
  1798. * @param result defines the Vector3 where to store the result
  1799. */
  1800. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  1801. /**
  1802. * Returns a new Vector3 as the normalization of the given vector
  1803. * @param vector defines the Vector3 to normalize
  1804. * @returns the new Vector3
  1805. */
  1806. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  1807. /**
  1808. * Sets the given vector "result" with the normalization of the given first vector
  1809. * @param vector defines the Vector3 to normalize
  1810. * @param result defines the Vector3 where to store the result
  1811. */
  1812. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  1813. /**
  1814. * Project a Vector3 onto screen space
  1815. * @param vector defines the Vector3 to project
  1816. * @param world defines the world matrix to use
  1817. * @param transform defines the transform (view x projection) matrix to use
  1818. * @param viewport defines the screen viewport to use
  1819. * @returns the new Vector3
  1820. */
  1821. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  1822. /** @hidden */
  1823. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  1824. /**
  1825. * Unproject from screen space to object space
  1826. * @param source defines the screen space Vector3 to use
  1827. * @param viewportWidth defines the current width of the viewport
  1828. * @param viewportHeight defines the current height of the viewport
  1829. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1830. * @param transform defines the transform (view x projection) matrix to use
  1831. * @returns the new Vector3
  1832. */
  1833. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  1834. /**
  1835. * Unproject from screen space to object space
  1836. * @param source defines the screen space Vector3 to use
  1837. * @param viewportWidth defines the current width of the viewport
  1838. * @param viewportHeight defines the current height of the viewport
  1839. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1840. * @param view defines the view matrix to use
  1841. * @param projection defines the projection matrix to use
  1842. * @returns the new Vector3
  1843. */
  1844. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  1845. /**
  1846. * Unproject from screen space to object space
  1847. * @param source defines the screen space Vector3 to use
  1848. * @param viewportWidth defines the current width of the viewport
  1849. * @param viewportHeight defines the current height of the viewport
  1850. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1851. * @param view defines the view matrix to use
  1852. * @param projection defines the projection matrix to use
  1853. * @param result defines the Vector3 where to store the result
  1854. */
  1855. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1856. /**
  1857. * Unproject from screen space to object space
  1858. * @param sourceX defines the screen space x coordinate to use
  1859. * @param sourceY defines the screen space y coordinate to use
  1860. * @param sourceZ defines the screen space z coordinate to use
  1861. * @param viewportWidth defines the current width of the viewport
  1862. * @param viewportHeight defines the current height of the viewport
  1863. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1864. * @param view defines the view matrix to use
  1865. * @param projection defines the projection matrix to use
  1866. * @param result defines the Vector3 where to store the result
  1867. */
  1868. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1869. /**
  1870. * Gets the minimal coordinate values between two Vector3
  1871. * @param left defines the first operand
  1872. * @param right defines the second operand
  1873. * @returns the new Vector3
  1874. */
  1875. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1876. /**
  1877. * Gets the maximal coordinate values between two Vector3
  1878. * @param left defines the first operand
  1879. * @param right defines the second operand
  1880. * @returns the new Vector3
  1881. */
  1882. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1883. /**
  1884. * Returns the distance between the vectors "value1" and "value2"
  1885. * @param value1 defines the first operand
  1886. * @param value2 defines the second operand
  1887. * @returns the distance
  1888. */
  1889. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1890. /**
  1891. * Returns the squared distance between the vectors "value1" and "value2"
  1892. * @param value1 defines the first operand
  1893. * @param value2 defines the second operand
  1894. * @returns the squared distance
  1895. */
  1896. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1897. /**
  1898. * Returns a new Vector3 located at the center between "value1" and "value2"
  1899. * @param value1 defines the first operand
  1900. * @param value2 defines the second operand
  1901. * @returns the new Vector3
  1902. */
  1903. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  1904. /**
  1905. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  1906. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  1907. * to something in order to rotate it from its local system to the given target system
  1908. * Note: axis1, axis2 and axis3 are normalized during this operation
  1909. * @param axis1 defines the first axis
  1910. * @param axis2 defines the second axis
  1911. * @param axis3 defines the third axis
  1912. * @returns a new Vector3
  1913. */
  1914. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  1915. /**
  1916. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  1917. * @param axis1 defines the first axis
  1918. * @param axis2 defines the second axis
  1919. * @param axis3 defines the third axis
  1920. * @param ref defines the Vector3 where to store the result
  1921. */
  1922. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  1923. }
  1924. /**
  1925. * Vector4 class created for EulerAngle class conversion to Quaternion
  1926. */
  1927. export class Vector4 {
  1928. /** x value of the vector */
  1929. x: number;
  1930. /** y value of the vector */
  1931. y: number;
  1932. /** z value of the vector */
  1933. z: number;
  1934. /** w value of the vector */
  1935. w: number;
  1936. /**
  1937. * Creates a Vector4 object from the given floats.
  1938. * @param x x value of the vector
  1939. * @param y y value of the vector
  1940. * @param z z value of the vector
  1941. * @param w w value of the vector
  1942. */
  1943. constructor(
  1944. /** x value of the vector */
  1945. x: number,
  1946. /** y value of the vector */
  1947. y: number,
  1948. /** z value of the vector */
  1949. z: number,
  1950. /** w value of the vector */
  1951. w: number);
  1952. /**
  1953. * Returns the string with the Vector4 coordinates.
  1954. * @returns a string containing all the vector values
  1955. */
  1956. toString(): string;
  1957. /**
  1958. * Returns the string "Vector4".
  1959. * @returns "Vector4"
  1960. */
  1961. getClassName(): string;
  1962. /**
  1963. * Returns the Vector4 hash code.
  1964. * @returns a unique hash code
  1965. */
  1966. getHashCode(): number;
  1967. /**
  1968. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  1969. * @returns the resulting array
  1970. */
  1971. asArray(): number[];
  1972. /**
  1973. * Populates the given array from the given index with the Vector4 coordinates.
  1974. * @param array array to populate
  1975. * @param index index of the array to start at (default: 0)
  1976. * @returns the Vector4.
  1977. */
  1978. toArray(array: FloatArray, index?: number): Vector4;
  1979. /**
  1980. * Adds the given vector to the current Vector4.
  1981. * @param otherVector the vector to add
  1982. * @returns the updated Vector4.
  1983. */
  1984. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  1985. /**
  1986. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  1987. * @param otherVector the vector to add
  1988. * @returns the resulting vector
  1989. */
  1990. add(otherVector: DeepImmutable<Vector4>): Vector4;
  1991. /**
  1992. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  1993. * @param otherVector the vector to add
  1994. * @param result the vector to store the result
  1995. * @returns the current Vector4.
  1996. */
  1997. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  1998. /**
  1999. * Subtract in place the given vector from the current Vector4.
  2000. * @param otherVector the vector to subtract
  2001. * @returns the updated Vector4.
  2002. */
  2003. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2004. /**
  2005. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2006. * @param otherVector the vector to add
  2007. * @returns the new vector with the result
  2008. */
  2009. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2010. /**
  2011. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2012. * @param otherVector the vector to subtract
  2013. * @param result the vector to store the result
  2014. * @returns the current Vector4.
  2015. */
  2016. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2017. /**
  2018. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2019. */
  2020. /**
  2021. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2022. * @param x value to subtract
  2023. * @param y value to subtract
  2024. * @param z value to subtract
  2025. * @param w value to subtract
  2026. * @returns new vector containing the result
  2027. */
  2028. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2029. /**
  2030. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2031. * @param x value to subtract
  2032. * @param y value to subtract
  2033. * @param z value to subtract
  2034. * @param w value to subtract
  2035. * @param result the vector to store the result in
  2036. * @returns the current Vector4.
  2037. */
  2038. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2039. /**
  2040. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2041. * @returns a new vector with the negated values
  2042. */
  2043. negate(): Vector4;
  2044. /**
  2045. * Multiplies the current Vector4 coordinates by scale (float).
  2046. * @param scale the number to scale with
  2047. * @returns the updated Vector4.
  2048. */
  2049. scaleInPlace(scale: number): Vector4;
  2050. /**
  2051. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2052. * @param scale the number to scale with
  2053. * @returns a new vector with the result
  2054. */
  2055. scale(scale: number): Vector4;
  2056. /**
  2057. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2058. * @param scale the number to scale with
  2059. * @param result a vector to store the result in
  2060. * @returns the current Vector4.
  2061. */
  2062. scaleToRef(scale: number, result: Vector4): Vector4;
  2063. /**
  2064. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2065. * @param scale defines the scale factor
  2066. * @param result defines the Vector4 object where to store the result
  2067. * @returns the unmodified current Vector4
  2068. */
  2069. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2070. /**
  2071. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2072. * @param otherVector the vector to compare against
  2073. * @returns true if they are equal
  2074. */
  2075. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2076. /**
  2077. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2078. * @param otherVector vector to compare against
  2079. * @param epsilon (Default: very small number)
  2080. * @returns true if they are equal
  2081. */
  2082. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2083. /**
  2084. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2085. * @param x x value to compare against
  2086. * @param y y value to compare against
  2087. * @param z z value to compare against
  2088. * @param w w value to compare against
  2089. * @returns true if equal
  2090. */
  2091. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2092. /**
  2093. * Multiplies in place the current Vector4 by the given one.
  2094. * @param otherVector vector to multiple with
  2095. * @returns the updated Vector4.
  2096. */
  2097. multiplyInPlace(otherVector: Vector4): Vector4;
  2098. /**
  2099. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2100. * @param otherVector vector to multiple with
  2101. * @returns resulting new vector
  2102. */
  2103. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2104. /**
  2105. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2106. * @param otherVector vector to multiple with
  2107. * @param result vector to store the result
  2108. * @returns the current Vector4.
  2109. */
  2110. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2111. /**
  2112. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2113. * @param x x value multiply with
  2114. * @param y y value multiply with
  2115. * @param z z value multiply with
  2116. * @param w w value multiply with
  2117. * @returns resulting new vector
  2118. */
  2119. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2120. /**
  2121. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2122. * @param otherVector vector to devide with
  2123. * @returns resulting new vector
  2124. */
  2125. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2126. /**
  2127. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2128. * @param otherVector vector to devide with
  2129. * @param result vector to store the result
  2130. * @returns the current Vector4.
  2131. */
  2132. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2133. /**
  2134. * Divides the current Vector3 coordinates by the given ones.
  2135. * @param otherVector vector to devide with
  2136. * @returns the updated Vector3.
  2137. */
  2138. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2139. /**
  2140. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2141. * @param other defines the second operand
  2142. * @returns the current updated Vector4
  2143. */
  2144. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2145. /**
  2146. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2147. * @param other defines the second operand
  2148. * @returns the current updated Vector4
  2149. */
  2150. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2151. /**
  2152. * Gets a new Vector4 from current Vector4 floored values
  2153. * @returns a new Vector4
  2154. */
  2155. floor(): Vector4;
  2156. /**
  2157. * Gets a new Vector4 from current Vector3 floored values
  2158. * @returns a new Vector4
  2159. */
  2160. fract(): Vector4;
  2161. /**
  2162. * Returns the Vector4 length (float).
  2163. * @returns the length
  2164. */
  2165. length(): number;
  2166. /**
  2167. * Returns the Vector4 squared length (float).
  2168. * @returns the length squared
  2169. */
  2170. lengthSquared(): number;
  2171. /**
  2172. * Normalizes in place the Vector4.
  2173. * @returns the updated Vector4.
  2174. */
  2175. normalize(): Vector4;
  2176. /**
  2177. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2178. * @returns this converted to a new vector3
  2179. */
  2180. toVector3(): Vector3;
  2181. /**
  2182. * Returns a new Vector4 copied from the current one.
  2183. * @returns the new cloned vector
  2184. */
  2185. clone(): Vector4;
  2186. /**
  2187. * Updates the current Vector4 with the given one coordinates.
  2188. * @param source the source vector to copy from
  2189. * @returns the updated Vector4.
  2190. */
  2191. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2192. /**
  2193. * Updates the current Vector4 coordinates with the given floats.
  2194. * @param x float to copy from
  2195. * @param y float to copy from
  2196. * @param z float to copy from
  2197. * @param w float to copy from
  2198. * @returns the updated Vector4.
  2199. */
  2200. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2201. /**
  2202. * Updates the current Vector4 coordinates with the given floats.
  2203. * @param x float to set from
  2204. * @param y float to set from
  2205. * @param z float to set from
  2206. * @param w float to set from
  2207. * @returns the updated Vector4.
  2208. */
  2209. set(x: number, y: number, z: number, w: number): Vector4;
  2210. /**
  2211. * Copies the given float to the current Vector3 coordinates
  2212. * @param v defines the x, y, z and w coordinates of the operand
  2213. * @returns the current updated Vector3
  2214. */
  2215. setAll(v: number): Vector4;
  2216. /**
  2217. * Returns a new Vector4 set from the starting index of the given array.
  2218. * @param array the array to pull values from
  2219. * @param offset the offset into the array to start at
  2220. * @returns the new vector
  2221. */
  2222. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2223. /**
  2224. * Updates the given vector "result" from the starting index of the given array.
  2225. * @param array the array to pull values from
  2226. * @param offset the offset into the array to start at
  2227. * @param result the vector to store the result in
  2228. */
  2229. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2230. /**
  2231. * Updates the given vector "result" from the starting index of the given Float32Array.
  2232. * @param array the array to pull values from
  2233. * @param offset the offset into the array to start at
  2234. * @param result the vector to store the result in
  2235. */
  2236. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2237. /**
  2238. * Updates the given vector "result" coordinates from the given floats.
  2239. * @param x float to set from
  2240. * @param y float to set from
  2241. * @param z float to set from
  2242. * @param w float to set from
  2243. * @param result the vector to the floats in
  2244. */
  2245. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2246. /**
  2247. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2248. * @returns the new vector
  2249. */
  2250. static Zero(): Vector4;
  2251. /**
  2252. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2253. * @returns the new vector
  2254. */
  2255. static One(): Vector4;
  2256. /**
  2257. * Returns a new normalized Vector4 from the given one.
  2258. * @param vector the vector to normalize
  2259. * @returns the vector
  2260. */
  2261. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2262. /**
  2263. * Updates the given vector "result" from the normalization of the given one.
  2264. * @param vector the vector to normalize
  2265. * @param result the vector to store the result in
  2266. */
  2267. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2268. /**
  2269. * Returns a vector with the minimum values from the left and right vectors
  2270. * @param left left vector to minimize
  2271. * @param right right vector to minimize
  2272. * @returns a new vector with the minimum of the left and right vector values
  2273. */
  2274. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2275. /**
  2276. * Returns a vector with the maximum values from the left and right vectors
  2277. * @param left left vector to maximize
  2278. * @param right right vector to maximize
  2279. * @returns a new vector with the maximum of the left and right vector values
  2280. */
  2281. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2282. /**
  2283. * Returns the distance (float) between the vectors "value1" and "value2".
  2284. * @param value1 value to calulate the distance between
  2285. * @param value2 value to calulate the distance between
  2286. * @return the distance between the two vectors
  2287. */
  2288. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2289. /**
  2290. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2291. * @param value1 value to calulate the distance between
  2292. * @param value2 value to calulate the distance between
  2293. * @return the distance between the two vectors squared
  2294. */
  2295. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2296. /**
  2297. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2298. * @param value1 value to calulate the center between
  2299. * @param value2 value to calulate the center between
  2300. * @return the center between the two vectors
  2301. */
  2302. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2303. /**
  2304. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2305. * This methods computes transformed normalized direction vectors only.
  2306. * @param vector the vector to transform
  2307. * @param transformation the transformation matrix to apply
  2308. * @returns the new vector
  2309. */
  2310. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2311. /**
  2312. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2313. * This methods computes transformed normalized direction vectors only.
  2314. * @param vector the vector to transform
  2315. * @param transformation the transformation matrix to apply
  2316. * @param result the vector to store the result in
  2317. */
  2318. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2319. /**
  2320. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2321. * This methods computes transformed normalized direction vectors only.
  2322. * @param x value to transform
  2323. * @param y value to transform
  2324. * @param z value to transform
  2325. * @param w value to transform
  2326. * @param transformation the transformation matrix to apply
  2327. * @param result the vector to store the results in
  2328. */
  2329. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2330. /**
  2331. * Creates a new Vector4 from a Vector3
  2332. * @param source defines the source data
  2333. * @param w defines the 4th component (default is 0)
  2334. * @returns a new Vector4
  2335. */
  2336. static FromVector3(source: Vector3, w?: number): Vector4;
  2337. }
  2338. /**
  2339. * Interface for the size containing width and height
  2340. */
  2341. export interface ISize {
  2342. /**
  2343. * Width
  2344. */
  2345. width: number;
  2346. /**
  2347. * Heighht
  2348. */
  2349. height: number;
  2350. }
  2351. /**
  2352. * Size containing widht and height
  2353. */
  2354. export class Size implements ISize {
  2355. /**
  2356. * Width
  2357. */
  2358. width: number;
  2359. /**
  2360. * Height
  2361. */
  2362. height: number;
  2363. /**
  2364. * Creates a Size object from the given width and height (floats).
  2365. * @param width width of the new size
  2366. * @param height height of the new size
  2367. */
  2368. constructor(width: number, height: number);
  2369. /**
  2370. * Returns a string with the Size width and height
  2371. * @returns a string with the Size width and height
  2372. */
  2373. toString(): string;
  2374. /**
  2375. * "Size"
  2376. * @returns the string "Size"
  2377. */
  2378. getClassName(): string;
  2379. /**
  2380. * Returns the Size hash code.
  2381. * @returns a hash code for a unique width and height
  2382. */
  2383. getHashCode(): number;
  2384. /**
  2385. * Updates the current size from the given one.
  2386. * @param src the given size
  2387. */
  2388. copyFrom(src: Size): void;
  2389. /**
  2390. * Updates in place the current Size from the given floats.
  2391. * @param width width of the new size
  2392. * @param height height of the new size
  2393. * @returns the updated Size.
  2394. */
  2395. copyFromFloats(width: number, height: number): Size;
  2396. /**
  2397. * Updates in place the current Size from the given floats.
  2398. * @param width width to set
  2399. * @param height height to set
  2400. * @returns the updated Size.
  2401. */
  2402. set(width: number, height: number): Size;
  2403. /**
  2404. * Multiplies the width and height by numbers
  2405. * @param w factor to multiple the width by
  2406. * @param h factor to multiple the height by
  2407. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  2408. */
  2409. multiplyByFloats(w: number, h: number): Size;
  2410. /**
  2411. * Clones the size
  2412. * @returns a new Size copied from the given one.
  2413. */
  2414. clone(): Size;
  2415. /**
  2416. * True if the current Size and the given one width and height are strictly equal.
  2417. * @param other the other size to compare against
  2418. * @returns True if the current Size and the given one width and height are strictly equal.
  2419. */
  2420. equals(other: Size): boolean;
  2421. /**
  2422. * The surface of the Size : width * height (float).
  2423. */
  2424. readonly surface: number;
  2425. /**
  2426. * Create a new size of zero
  2427. * @returns a new Size set to (0.0, 0.0)
  2428. */
  2429. static Zero(): Size;
  2430. /**
  2431. * Sums the width and height of two sizes
  2432. * @param otherSize size to add to this size
  2433. * @returns a new Size set as the addition result of the current Size and the given one.
  2434. */
  2435. add(otherSize: Size): Size;
  2436. /**
  2437. * Subtracts the width and height of two
  2438. * @param otherSize size to subtract to this size
  2439. * @returns a new Size set as the subtraction result of the given one from the current Size.
  2440. */
  2441. subtract(otherSize: Size): Size;
  2442. /**
  2443. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  2444. * @param start starting size to lerp between
  2445. * @param end end size to lerp between
  2446. * @param amount amount to lerp between the start and end values
  2447. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  2448. */
  2449. static Lerp(start: Size, end: Size, amount: number): Size;
  2450. }
  2451. /**
  2452. * Class used to store quaternion data
  2453. * @see https://en.wikipedia.org/wiki/Quaternion
  2454. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2455. */
  2456. export class Quaternion {
  2457. /** defines the first component (0 by default) */
  2458. x: number;
  2459. /** defines the second component (0 by default) */
  2460. y: number;
  2461. /** defines the third component (0 by default) */
  2462. z: number;
  2463. /** defines the fourth component (1.0 by default) */
  2464. w: number;
  2465. /**
  2466. * Creates a new Quaternion from the given floats
  2467. * @param x defines the first component (0 by default)
  2468. * @param y defines the second component (0 by default)
  2469. * @param z defines the third component (0 by default)
  2470. * @param w defines the fourth component (1.0 by default)
  2471. */
  2472. constructor(
  2473. /** defines the first component (0 by default) */
  2474. x?: number,
  2475. /** defines the second component (0 by default) */
  2476. y?: number,
  2477. /** defines the third component (0 by default) */
  2478. z?: number,
  2479. /** defines the fourth component (1.0 by default) */
  2480. w?: number);
  2481. /**
  2482. * Gets a string representation for the current quaternion
  2483. * @returns a string with the Quaternion coordinates
  2484. */
  2485. toString(): string;
  2486. /**
  2487. * Gets the class name of the quaternion
  2488. * @returns the string "Quaternion"
  2489. */
  2490. getClassName(): string;
  2491. /**
  2492. * Gets a hash code for this quaternion
  2493. * @returns the quaternion hash code
  2494. */
  2495. getHashCode(): number;
  2496. /**
  2497. * Copy the quaternion to an array
  2498. * @returns a new array populated with 4 elements from the quaternion coordinates
  2499. */
  2500. asArray(): number[];
  2501. /**
  2502. * Check if two quaternions are equals
  2503. * @param otherQuaternion defines the second operand
  2504. * @return true if the current quaternion and the given one coordinates are strictly equals
  2505. */
  2506. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2507. /**
  2508. * Clone the current quaternion
  2509. * @returns a new quaternion copied from the current one
  2510. */
  2511. clone(): Quaternion;
  2512. /**
  2513. * Copy a quaternion to the current one
  2514. * @param other defines the other quaternion
  2515. * @returns the updated current quaternion
  2516. */
  2517. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2518. /**
  2519. * Updates the current quaternion with the given float coordinates
  2520. * @param x defines the x coordinate
  2521. * @param y defines the y coordinate
  2522. * @param z defines the z coordinate
  2523. * @param w defines the w coordinate
  2524. * @returns the updated current quaternion
  2525. */
  2526. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2527. /**
  2528. * Updates the current quaternion from the given float coordinates
  2529. * @param x defines the x coordinate
  2530. * @param y defines the y coordinate
  2531. * @param z defines the z coordinate
  2532. * @param w defines the w coordinate
  2533. * @returns the updated current quaternion
  2534. */
  2535. set(x: number, y: number, z: number, w: number): Quaternion;
  2536. /**
  2537. * Adds two quaternions
  2538. * @param other defines the second operand
  2539. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2540. */
  2541. add(other: DeepImmutable<Quaternion>): Quaternion;
  2542. /**
  2543. * Add a quaternion to the current one
  2544. * @param other defines the quaternion to add
  2545. * @returns the current quaternion
  2546. */
  2547. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  2548. /**
  2549. * Subtract two quaternions
  2550. * @param other defines the second operand
  2551. * @returns a new quaternion as the subtraction result of the given one from the current one
  2552. */
  2553. subtract(other: Quaternion): Quaternion;
  2554. /**
  2555. * Multiplies the current quaternion by a scale factor
  2556. * @param value defines the scale factor
  2557. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  2558. */
  2559. scale(value: number): Quaternion;
  2560. /**
  2561. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  2562. * @param scale defines the scale factor
  2563. * @param result defines the Quaternion object where to store the result
  2564. * @returns the unmodified current quaternion
  2565. */
  2566. scaleToRef(scale: number, result: Quaternion): Quaternion;
  2567. /**
  2568. * Multiplies in place the current quaternion by a scale factor
  2569. * @param value defines the scale factor
  2570. * @returns the current modified quaternion
  2571. */
  2572. scaleInPlace(value: number): Quaternion;
  2573. /**
  2574. * Scale the current quaternion values by a factor and add the result to a given quaternion
  2575. * @param scale defines the scale factor
  2576. * @param result defines the Quaternion object where to store the result
  2577. * @returns the unmodified current quaternion
  2578. */
  2579. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  2580. /**
  2581. * Multiplies two quaternions
  2582. * @param q1 defines the second operand
  2583. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  2584. */
  2585. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  2586. /**
  2587. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  2588. * @param q1 defines the second operand
  2589. * @param result defines the target quaternion
  2590. * @returns the current quaternion
  2591. */
  2592. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  2593. /**
  2594. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  2595. * @param q1 defines the second operand
  2596. * @returns the currentupdated quaternion
  2597. */
  2598. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  2599. /**
  2600. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  2601. * @param ref defines the target quaternion
  2602. * @returns the current quaternion
  2603. */
  2604. conjugateToRef(ref: Quaternion): Quaternion;
  2605. /**
  2606. * Conjugates in place (1-q) the current quaternion
  2607. * @returns the current updated quaternion
  2608. */
  2609. conjugateInPlace(): Quaternion;
  2610. /**
  2611. * Conjugates in place (1-q) the current quaternion
  2612. * @returns a new quaternion
  2613. */
  2614. conjugate(): Quaternion;
  2615. /**
  2616. * Gets length of current quaternion
  2617. * @returns the quaternion length (float)
  2618. */
  2619. length(): number;
  2620. /**
  2621. * Normalize in place the current quaternion
  2622. * @returns the current updated quaternion
  2623. */
  2624. normalize(): Quaternion;
  2625. /**
  2626. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  2627. * @param order is a reserved parameter and is ignore for now
  2628. * @returns a new Vector3 containing the Euler angles
  2629. */
  2630. toEulerAngles(order?: string): Vector3;
  2631. /**
  2632. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  2633. * @param result defines the vector which will be filled with the Euler angles
  2634. * @param order is a reserved parameter and is ignore for now
  2635. * @returns the current unchanged quaternion
  2636. */
  2637. toEulerAnglesToRef(result: Vector3): Quaternion;
  2638. /**
  2639. * Updates the given rotation matrix with the current quaternion values
  2640. * @param result defines the target matrix
  2641. * @returns the current unchanged quaternion
  2642. */
  2643. toRotationMatrix(result: Matrix): Quaternion;
  2644. /**
  2645. * Updates the current quaternion from the given rotation matrix values
  2646. * @param matrix defines the source matrix
  2647. * @returns the current updated quaternion
  2648. */
  2649. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2650. /**
  2651. * Creates a new quaternion from a rotation matrix
  2652. * @param matrix defines the source matrix
  2653. * @returns a new quaternion created from the given rotation matrix values
  2654. */
  2655. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2656. /**
  2657. * Updates the given quaternion with the given rotation matrix values
  2658. * @param matrix defines the source matrix
  2659. * @param result defines the target quaternion
  2660. */
  2661. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  2662. /**
  2663. * Returns the dot product (float) between the quaternions "left" and "right"
  2664. * @param left defines the left operand
  2665. * @param right defines the right operand
  2666. * @returns the dot product
  2667. */
  2668. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  2669. /**
  2670. * Checks if the two quaternions are close to each other
  2671. * @param quat0 defines the first quaternion to check
  2672. * @param quat1 defines the second quaternion to check
  2673. * @returns true if the two quaternions are close to each other
  2674. */
  2675. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  2676. /**
  2677. * Creates an empty quaternion
  2678. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  2679. */
  2680. static Zero(): Quaternion;
  2681. /**
  2682. * Inverse a given quaternion
  2683. * @param q defines the source quaternion
  2684. * @returns a new quaternion as the inverted current quaternion
  2685. */
  2686. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  2687. /**
  2688. * Inverse a given quaternion
  2689. * @param q defines the source quaternion
  2690. * @param result the quaternion the result will be stored in
  2691. * @returns the result quaternion
  2692. */
  2693. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  2694. /**
  2695. * Creates an identity quaternion
  2696. * @returns the identity quaternion
  2697. */
  2698. static Identity(): Quaternion;
  2699. /**
  2700. * Gets a boolean indicating if the given quaternion is identity
  2701. * @param quaternion defines the quaternion to check
  2702. * @returns true if the quaternion is identity
  2703. */
  2704. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  2705. /**
  2706. * Creates a quaternion from a rotation around an axis
  2707. * @param axis defines the axis to use
  2708. * @param angle defines the angle to use
  2709. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  2710. */
  2711. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  2712. /**
  2713. * Creates a rotation around an axis and stores it into the given quaternion
  2714. * @param axis defines the axis to use
  2715. * @param angle defines the angle to use
  2716. * @param result defines the target quaternion
  2717. * @returns the target quaternion
  2718. */
  2719. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  2720. /**
  2721. * Creates a new quaternion from data stored into an array
  2722. * @param array defines the data source
  2723. * @param offset defines the offset in the source array where the data starts
  2724. * @returns a new quaternion
  2725. */
  2726. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  2727. /**
  2728. * Create a quaternion from Euler rotation angles
  2729. * @param x Pitch
  2730. * @param y Yaw
  2731. * @param z Roll
  2732. * @returns the new Quaternion
  2733. */
  2734. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  2735. /**
  2736. * Updates a quaternion from Euler rotation angles
  2737. * @param x Pitch
  2738. * @param y Yaw
  2739. * @param z Roll
  2740. * @param result the quaternion to store the result
  2741. * @returns the updated quaternion
  2742. */
  2743. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  2744. /**
  2745. * Create a quaternion from Euler rotation vector
  2746. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2747. * @returns the new Quaternion
  2748. */
  2749. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  2750. /**
  2751. * Updates a quaternion from Euler rotation vector
  2752. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2753. * @param result the quaternion to store the result
  2754. * @returns the updated quaternion
  2755. */
  2756. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  2757. /**
  2758. * Creates a new quaternion from the given Euler float angles (y, x, z)
  2759. * @param yaw defines the rotation around Y axis
  2760. * @param pitch defines the rotation around X axis
  2761. * @param roll defines the rotation around Z axis
  2762. * @returns the new quaternion
  2763. */
  2764. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  2765. /**
  2766. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  2767. * @param yaw defines the rotation around Y axis
  2768. * @param pitch defines the rotation around X axis
  2769. * @param roll defines the rotation around Z axis
  2770. * @param result defines the target quaternion
  2771. */
  2772. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  2773. /**
  2774. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  2775. * @param alpha defines the rotation around first axis
  2776. * @param beta defines the rotation around second axis
  2777. * @param gamma defines the rotation around third axis
  2778. * @returns the new quaternion
  2779. */
  2780. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  2781. /**
  2782. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  2783. * @param alpha defines the rotation around first axis
  2784. * @param beta defines the rotation around second axis
  2785. * @param gamma defines the rotation around third axis
  2786. * @param result defines the target quaternion
  2787. */
  2788. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  2789. /**
  2790. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  2791. * @param axis1 defines the first axis
  2792. * @param axis2 defines the second axis
  2793. * @param axis3 defines the third axis
  2794. * @returns the new quaternion
  2795. */
  2796. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  2797. /**
  2798. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  2799. * @param axis1 defines the first axis
  2800. * @param axis2 defines the second axis
  2801. * @param axis3 defines the third axis
  2802. * @param ref defines the target quaternion
  2803. */
  2804. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  2805. /**
  2806. * Interpolates between two quaternions
  2807. * @param left defines first quaternion
  2808. * @param right defines second quaternion
  2809. * @param amount defines the gradient to use
  2810. * @returns the new interpolated quaternion
  2811. */
  2812. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2813. /**
  2814. * Interpolates between two quaternions and stores it into a target quaternion
  2815. * @param left defines first quaternion
  2816. * @param right defines second quaternion
  2817. * @param amount defines the gradient to use
  2818. * @param result defines the target quaternion
  2819. */
  2820. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  2821. /**
  2822. * Interpolate between two quaternions using Hermite interpolation
  2823. * @param value1 defines first quaternion
  2824. * @param tangent1 defines the incoming tangent
  2825. * @param value2 defines second quaternion
  2826. * @param tangent2 defines the outgoing tangent
  2827. * @param amount defines the target quaternion
  2828. * @returns the new interpolated quaternion
  2829. */
  2830. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2831. }
  2832. /**
  2833. * Class used to store matrix data (4x4)
  2834. */
  2835. export class Matrix {
  2836. private static _updateFlagSeed;
  2837. private static _identityReadOnly;
  2838. private _isIdentity;
  2839. private _isIdentityDirty;
  2840. private _isIdentity3x2;
  2841. private _isIdentity3x2Dirty;
  2842. /**
  2843. * Gets the update flag of the matrix which is an unique number for the matrix.
  2844. * It will be incremented every time the matrix data change.
  2845. * You can use it to speed the comparison between two versions of the same matrix.
  2846. */
  2847. updateFlag: number;
  2848. private readonly _m;
  2849. /**
  2850. * Gets the internal data of the matrix
  2851. */
  2852. readonly m: DeepImmutable<Float32Array>;
  2853. /** @hidden */
  2854. _markAsUpdated(): void;
  2855. /** @hidden */
  2856. private _updateIdentityStatus;
  2857. /**
  2858. * Creates an empty matrix (filled with zeros)
  2859. */
  2860. constructor();
  2861. /**
  2862. * Check if the current matrix is identity
  2863. * @returns true is the matrix is the identity matrix
  2864. */
  2865. isIdentity(): boolean;
  2866. /**
  2867. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  2868. * @returns true is the matrix is the identity matrix
  2869. */
  2870. isIdentityAs3x2(): boolean;
  2871. /**
  2872. * Gets the determinant of the matrix
  2873. * @returns the matrix determinant
  2874. */
  2875. determinant(): number;
  2876. /**
  2877. * Returns the matrix as a Float32Array
  2878. * @returns the matrix underlying array
  2879. */
  2880. toArray(): DeepImmutable<Float32Array>;
  2881. /**
  2882. * Returns the matrix as a Float32Array
  2883. * @returns the matrix underlying array.
  2884. */
  2885. asArray(): DeepImmutable<Float32Array>;
  2886. /**
  2887. * Inverts the current matrix in place
  2888. * @returns the current inverted matrix
  2889. */
  2890. invert(): Matrix;
  2891. /**
  2892. * Sets all the matrix elements to zero
  2893. * @returns the current matrix
  2894. */
  2895. reset(): Matrix;
  2896. /**
  2897. * Adds the current matrix with a second one
  2898. * @param other defines the matrix to add
  2899. * @returns a new matrix as the addition of the current matrix and the given one
  2900. */
  2901. add(other: DeepImmutable<Matrix>): Matrix;
  2902. /**
  2903. * Sets the given matrix "result" to the addition of the current matrix and the given one
  2904. * @param other defines the matrix to add
  2905. * @param result defines the target matrix
  2906. * @returns the current matrix
  2907. */
  2908. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2909. /**
  2910. * Adds in place the given matrix to the current matrix
  2911. * @param other defines the second operand
  2912. * @returns the current updated matrix
  2913. */
  2914. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  2915. /**
  2916. * Sets the given matrix to the current inverted Matrix
  2917. * @param other defines the target matrix
  2918. * @returns the unmodified current matrix
  2919. */
  2920. invertToRef(other: Matrix): Matrix;
  2921. /**
  2922. * add a value at the specified position in the current Matrix
  2923. * @param index the index of the value within the matrix. between 0 and 15.
  2924. * @param value the value to be added
  2925. * @returns the current updated matrix
  2926. */
  2927. addAtIndex(index: number, value: number): Matrix;
  2928. /**
  2929. * mutiply the specified position in the current Matrix by a value
  2930. * @param index the index of the value within the matrix. between 0 and 15.
  2931. * @param value the value to be added
  2932. * @returns the current updated matrix
  2933. */
  2934. multiplyAtIndex(index: number, value: number): Matrix;
  2935. /**
  2936. * Inserts the translation vector (using 3 floats) in the current matrix
  2937. * @param x defines the 1st component of the translation
  2938. * @param y defines the 2nd component of the translation
  2939. * @param z defines the 3rd component of the translation
  2940. * @returns the current updated matrix
  2941. */
  2942. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2943. /**
  2944. * Adds the translation vector (using 3 floats) in the current matrix
  2945. * @param x defines the 1st component of the translation
  2946. * @param y defines the 2nd component of the translation
  2947. * @param z defines the 3rd component of the translation
  2948. * @returns the current updated matrix
  2949. */
  2950. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2951. /**
  2952. * Inserts the translation vector in the current matrix
  2953. * @param vector3 defines the translation to insert
  2954. * @returns the current updated matrix
  2955. */
  2956. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  2957. /**
  2958. * Gets the translation value of the current matrix
  2959. * @returns a new Vector3 as the extracted translation from the matrix
  2960. */
  2961. getTranslation(): Vector3;
  2962. /**
  2963. * Fill a Vector3 with the extracted translation from the matrix
  2964. * @param result defines the Vector3 where to store the translation
  2965. * @returns the current matrix
  2966. */
  2967. getTranslationToRef(result: Vector3): Matrix;
  2968. /**
  2969. * Remove rotation and scaling part from the matrix
  2970. * @returns the updated matrix
  2971. */
  2972. removeRotationAndScaling(): Matrix;
  2973. /**
  2974. * Multiply two matrices
  2975. * @param other defines the second operand
  2976. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  2977. */
  2978. multiply(other: DeepImmutable<Matrix>): Matrix;
  2979. /**
  2980. * Copy the current matrix from the given one
  2981. * @param other defines the source matrix
  2982. * @returns the current updated matrix
  2983. */
  2984. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  2985. /**
  2986. * Populates the given array from the starting index with the current matrix values
  2987. * @param array defines the target array
  2988. * @param offset defines the offset in the target array where to start storing values
  2989. * @returns the current matrix
  2990. */
  2991. copyToArray(array: Float32Array, offset?: number): Matrix;
  2992. /**
  2993. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  2994. * @param other defines the second operand
  2995. * @param result defines the matrix where to store the multiplication
  2996. * @returns the current matrix
  2997. */
  2998. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2999. /**
  3000. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  3001. * @param other defines the second operand
  3002. * @param result defines the array where to store the multiplication
  3003. * @param offset defines the offset in the target array where to start storing values
  3004. * @returns the current matrix
  3005. */
  3006. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3007. /**
  3008. * Check equality between this matrix and a second one
  3009. * @param value defines the second matrix to compare
  3010. * @returns true is the current matrix and the given one values are strictly equal
  3011. */
  3012. equals(value: DeepImmutable<Matrix>): boolean;
  3013. /**
  3014. * Clone the current matrix
  3015. * @returns a new matrix from the current matrix
  3016. */
  3017. clone(): Matrix;
  3018. /**
  3019. * Returns the name of the current matrix class
  3020. * @returns the string "Matrix"
  3021. */
  3022. getClassName(): string;
  3023. /**
  3024. * Gets the hash code of the current matrix
  3025. * @returns the hash code
  3026. */
  3027. getHashCode(): number;
  3028. /**
  3029. * Decomposes the current Matrix into a translation, rotation and scaling components
  3030. * @param scale defines the scale vector3 given as a reference to update
  3031. * @param rotation defines the rotation quaternion given as a reference to update
  3032. * @param translation defines the translation vector3 given as a reference to update
  3033. * @returns true if operation was successful
  3034. */
  3035. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3036. /**
  3037. * Gets specific row of the matrix
  3038. * @param index defines the number of the row to get
  3039. * @returns the index-th row of the current matrix as a new Vector4
  3040. */
  3041. getRow(index: number): Nullable<Vector4>;
  3042. /**
  3043. * Sets the index-th row of the current matrix to the vector4 values
  3044. * @param index defines the number of the row to set
  3045. * @param row defines the target vector4
  3046. * @returns the updated current matrix
  3047. */
  3048. setRow(index: number, row: Vector4): Matrix;
  3049. /**
  3050. * Compute the transpose of the matrix
  3051. * @returns the new transposed matrix
  3052. */
  3053. transpose(): Matrix;
  3054. /**
  3055. * Compute the transpose of the matrix and store it in a given matrix
  3056. * @param result defines the target matrix
  3057. * @returns the current matrix
  3058. */
  3059. transposeToRef(result: Matrix): Matrix;
  3060. /**
  3061. * Sets the index-th row of the current matrix with the given 4 x float values
  3062. * @param index defines the row index
  3063. * @param x defines the x component to set
  3064. * @param y defines the y component to set
  3065. * @param z defines the z component to set
  3066. * @param w defines the w component to set
  3067. * @returns the updated current matrix
  3068. */
  3069. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3070. /**
  3071. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3072. * @param scale defines the scale factor
  3073. * @returns a new matrix
  3074. */
  3075. scale(scale: number): Matrix;
  3076. /**
  3077. * Scale the current matrix values by a factor to a given result matrix
  3078. * @param scale defines the scale factor
  3079. * @param result defines the matrix to store the result
  3080. * @returns the current matrix
  3081. */
  3082. scaleToRef(scale: number, result: Matrix): Matrix;
  3083. /**
  3084. * Scale the current matrix values by a factor and add the result to a given matrix
  3085. * @param scale defines the scale factor
  3086. * @param result defines the Matrix to store the result
  3087. * @returns the current matrix
  3088. */
  3089. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3090. /**
  3091. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3092. * @param ref matrix to store the result
  3093. */
  3094. toNormalMatrix(ref: Matrix): void;
  3095. /**
  3096. * Gets only rotation part of the current matrix
  3097. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3098. */
  3099. getRotationMatrix(): Matrix;
  3100. /**
  3101. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3102. * @param result defines the target matrix to store data to
  3103. * @returns the current matrix
  3104. */
  3105. getRotationMatrixToRef(result: Matrix): Matrix;
  3106. /**
  3107. * Toggles model matrix from being right handed to left handed in place and vice versa
  3108. */
  3109. toggleModelMatrixHandInPlace(): void;
  3110. /**
  3111. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3112. */
  3113. toggleProjectionMatrixHandInPlace(): void;
  3114. /**
  3115. * Creates a matrix from an array
  3116. * @param array defines the source array
  3117. * @param offset defines an offset in the source array
  3118. * @returns a new Matrix set from the starting index of the given array
  3119. */
  3120. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3121. /**
  3122. * Copy the content of an array into a given matrix
  3123. * @param array defines the source array
  3124. * @param offset defines an offset in the source array
  3125. * @param result defines the target matrix
  3126. */
  3127. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3128. /**
  3129. * Stores an array into a matrix after having multiplied each component by a given factor
  3130. * @param array defines the source array
  3131. * @param offset defines the offset in the source array
  3132. * @param scale defines the scaling factor
  3133. * @param result defines the target matrix
  3134. */
  3135. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3136. /**
  3137. * Gets an identity matrix that must not be updated
  3138. */
  3139. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3140. /**
  3141. * Stores a list of values (16) inside a given matrix
  3142. * @param initialM11 defines 1st value of 1st row
  3143. * @param initialM12 defines 2nd value of 1st row
  3144. * @param initialM13 defines 3rd value of 1st row
  3145. * @param initialM14 defines 4th value of 1st row
  3146. * @param initialM21 defines 1st value of 2nd row
  3147. * @param initialM22 defines 2nd value of 2nd row
  3148. * @param initialM23 defines 3rd value of 2nd row
  3149. * @param initialM24 defines 4th value of 2nd row
  3150. * @param initialM31 defines 1st value of 3rd row
  3151. * @param initialM32 defines 2nd value of 3rd row
  3152. * @param initialM33 defines 3rd value of 3rd row
  3153. * @param initialM34 defines 4th value of 3rd row
  3154. * @param initialM41 defines 1st value of 4th row
  3155. * @param initialM42 defines 2nd value of 4th row
  3156. * @param initialM43 defines 3rd value of 4th row
  3157. * @param initialM44 defines 4th value of 4th row
  3158. * @param result defines the target matrix
  3159. */
  3160. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  3161. /**
  3162. * Creates new matrix from a list of values (16)
  3163. * @param initialM11 defines 1st value of 1st row
  3164. * @param initialM12 defines 2nd value of 1st row
  3165. * @param initialM13 defines 3rd value of 1st row
  3166. * @param initialM14 defines 4th value of 1st row
  3167. * @param initialM21 defines 1st value of 2nd row
  3168. * @param initialM22 defines 2nd value of 2nd row
  3169. * @param initialM23 defines 3rd value of 2nd row
  3170. * @param initialM24 defines 4th value of 2nd row
  3171. * @param initialM31 defines 1st value of 3rd row
  3172. * @param initialM32 defines 2nd value of 3rd row
  3173. * @param initialM33 defines 3rd value of 3rd row
  3174. * @param initialM34 defines 4th value of 3rd row
  3175. * @param initialM41 defines 1st value of 4th row
  3176. * @param initialM42 defines 2nd value of 4th row
  3177. * @param initialM43 defines 3rd value of 4th row
  3178. * @param initialM44 defines 4th value of 4th row
  3179. * @returns the new matrix
  3180. */
  3181. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  3182. /**
  3183. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3184. * @param scale defines the scale vector3
  3185. * @param rotation defines the rotation quaternion
  3186. * @param translation defines the translation vector3
  3187. * @returns a new matrix
  3188. */
  3189. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3190. /**
  3191. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3192. * @param scale defines the scale vector3
  3193. * @param rotation defines the rotation quaternion
  3194. * @param translation defines the translation vector3
  3195. * @param result defines the target matrix
  3196. */
  3197. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3198. /**
  3199. * Creates a new identity matrix
  3200. * @returns a new identity matrix
  3201. */
  3202. static Identity(): Matrix;
  3203. /**
  3204. * Creates a new identity matrix and stores the result in a given matrix
  3205. * @param result defines the target matrix
  3206. */
  3207. static IdentityToRef(result: Matrix): void;
  3208. /**
  3209. * Creates a new zero matrix
  3210. * @returns a new zero matrix
  3211. */
  3212. static Zero(): Matrix;
  3213. /**
  3214. * Creates a new rotation matrix for "angle" radians around the X axis
  3215. * @param angle defines the angle (in radians) to use
  3216. * @return the new matrix
  3217. */
  3218. static RotationX(angle: number): Matrix;
  3219. /**
  3220. * Creates a new matrix as the invert of a given matrix
  3221. * @param source defines the source matrix
  3222. * @returns the new matrix
  3223. */
  3224. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3225. /**
  3226. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3227. * @param angle defines the angle (in radians) to use
  3228. * @param result defines the target matrix
  3229. */
  3230. static RotationXToRef(angle: number, result: Matrix): void;
  3231. /**
  3232. * Creates a new rotation matrix for "angle" radians around the Y axis
  3233. * @param angle defines the angle (in radians) to use
  3234. * @return the new matrix
  3235. */
  3236. static RotationY(angle: number): Matrix;
  3237. /**
  3238. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3239. * @param angle defines the angle (in radians) to use
  3240. * @param result defines the target matrix
  3241. */
  3242. static RotationYToRef(angle: number, result: Matrix): void;
  3243. /**
  3244. * Creates a new rotation matrix for "angle" radians around the Z axis
  3245. * @param angle defines the angle (in radians) to use
  3246. * @return the new matrix
  3247. */
  3248. static RotationZ(angle: number): Matrix;
  3249. /**
  3250. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3251. * @param angle defines the angle (in radians) to use
  3252. * @param result defines the target matrix
  3253. */
  3254. static RotationZToRef(angle: number, result: Matrix): void;
  3255. /**
  3256. * Creates a new rotation matrix for "angle" radians around the given axis
  3257. * @param axis defines the axis to use
  3258. * @param angle defines the angle (in radians) to use
  3259. * @return the new matrix
  3260. */
  3261. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3262. /**
  3263. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3264. * @param axis defines the axis to use
  3265. * @param angle defines the angle (in radians) to use
  3266. * @param result defines the target matrix
  3267. */
  3268. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3269. /**
  3270. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  3271. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  3272. * @param from defines the vector to align
  3273. * @param to defines the vector to align to
  3274. * @param result defines the target matrix
  3275. */
  3276. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  3277. /**
  3278. * Creates a rotation matrix
  3279. * @param yaw defines the yaw angle in radians (Y axis)
  3280. * @param pitch defines the pitch angle in radians (X axis)
  3281. * @param roll defines the roll angle in radians (X axis)
  3282. * @returns the new rotation matrix
  3283. */
  3284. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3285. /**
  3286. * Creates a rotation matrix and stores it in a given matrix
  3287. * @param yaw defines the yaw angle in radians (Y axis)
  3288. * @param pitch defines the pitch angle in radians (X axis)
  3289. * @param roll defines the roll angle in radians (X axis)
  3290. * @param result defines the target matrix
  3291. */
  3292. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3293. /**
  3294. * Creates a scaling matrix
  3295. * @param x defines the scale factor on X axis
  3296. * @param y defines the scale factor on Y axis
  3297. * @param z defines the scale factor on Z axis
  3298. * @returns the new matrix
  3299. */
  3300. static Scaling(x: number, y: number, z: number): Matrix;
  3301. /**
  3302. * Creates a scaling matrix and stores it in a given matrix
  3303. * @param x defines the scale factor on X axis
  3304. * @param y defines the scale factor on Y axis
  3305. * @param z defines the scale factor on Z axis
  3306. * @param result defines the target matrix
  3307. */
  3308. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3309. /**
  3310. * Creates a translation matrix
  3311. * @param x defines the translation on X axis
  3312. * @param y defines the translation on Y axis
  3313. * @param z defines the translationon Z axis
  3314. * @returns the new matrix
  3315. */
  3316. static Translation(x: number, y: number, z: number): Matrix;
  3317. /**
  3318. * Creates a translation matrix and stores it in a given matrix
  3319. * @param x defines the translation on X axis
  3320. * @param y defines the translation on Y axis
  3321. * @param z defines the translationon Z axis
  3322. * @param result defines the target matrix
  3323. */
  3324. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3325. /**
  3326. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3327. * @param startValue defines the start value
  3328. * @param endValue defines the end value
  3329. * @param gradient defines the gradient factor
  3330. * @returns the new matrix
  3331. */
  3332. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3333. /**
  3334. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3335. * @param startValue defines the start value
  3336. * @param endValue defines the end value
  3337. * @param gradient defines the gradient factor
  3338. * @param result defines the Matrix object where to store data
  3339. */
  3340. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3341. /**
  3342. * Builds a new matrix whose values are computed by:
  3343. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3344. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3345. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3346. * @param startValue defines the first matrix
  3347. * @param endValue defines the second matrix
  3348. * @param gradient defines the gradient between the two matrices
  3349. * @returns the new matrix
  3350. */
  3351. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3352. /**
  3353. * Update a matrix to values which are computed by:
  3354. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3355. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3356. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3357. * @param startValue defines the first matrix
  3358. * @param endValue defines the second matrix
  3359. * @param gradient defines the gradient between the two matrices
  3360. * @param result defines the target matrix
  3361. */
  3362. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3363. /**
  3364. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  3365. * This function works in left handed mode
  3366. * @param eye defines the final position of the entity
  3367. * @param target defines where the entity should look at
  3368. * @param up defines the up vector for the entity
  3369. * @returns the new matrix
  3370. */
  3371. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3372. /**
  3373. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  3374. * This function works in left handed mode
  3375. * @param eye defines the final position of the entity
  3376. * @param target defines where the entity should look at
  3377. * @param up defines the up vector for the entity
  3378. * @param result defines the target matrix
  3379. */
  3380. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3381. /**
  3382. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  3383. * This function works in right handed mode
  3384. * @param eye defines the final position of the entity
  3385. * @param target defines where the entity should look at
  3386. * @param up defines the up vector for the entity
  3387. * @returns the new matrix
  3388. */
  3389. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3390. /**
  3391. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  3392. * This function works in right handed mode
  3393. * @param eye defines the final position of the entity
  3394. * @param target defines where the entity should look at
  3395. * @param up defines the up vector for the entity
  3396. * @param result defines the target matrix
  3397. */
  3398. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3399. /**
  3400. * Create a left-handed orthographic projection matrix
  3401. * @param width defines the viewport width
  3402. * @param height defines the viewport height
  3403. * @param znear defines the near clip plane
  3404. * @param zfar defines the far clip plane
  3405. * @returns a new matrix as a left-handed orthographic projection matrix
  3406. */
  3407. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3408. /**
  3409. * Store a left-handed orthographic projection to a given matrix
  3410. * @param width defines the viewport width
  3411. * @param height defines the viewport height
  3412. * @param znear defines the near clip plane
  3413. * @param zfar defines the far clip plane
  3414. * @param result defines the target matrix
  3415. */
  3416. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3417. /**
  3418. * Create a left-handed orthographic projection matrix
  3419. * @param left defines the viewport left coordinate
  3420. * @param right defines the viewport right coordinate
  3421. * @param bottom defines the viewport bottom coordinate
  3422. * @param top defines the viewport top coordinate
  3423. * @param znear defines the near clip plane
  3424. * @param zfar defines the far clip plane
  3425. * @returns a new matrix as a left-handed orthographic projection matrix
  3426. */
  3427. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3428. /**
  3429. * Stores a left-handed orthographic projection into a given matrix
  3430. * @param left defines the viewport left coordinate
  3431. * @param right defines the viewport right coordinate
  3432. * @param bottom defines the viewport bottom coordinate
  3433. * @param top defines the viewport top coordinate
  3434. * @param znear defines the near clip plane
  3435. * @param zfar defines the far clip plane
  3436. * @param result defines the target matrix
  3437. */
  3438. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3439. /**
  3440. * Creates a right-handed orthographic projection matrix
  3441. * @param left defines the viewport left coordinate
  3442. * @param right defines the viewport right coordinate
  3443. * @param bottom defines the viewport bottom coordinate
  3444. * @param top defines the viewport top coordinate
  3445. * @param znear defines the near clip plane
  3446. * @param zfar defines the far clip plane
  3447. * @returns a new matrix as a right-handed orthographic projection matrix
  3448. */
  3449. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3450. /**
  3451. * Stores a right-handed orthographic projection into a given matrix
  3452. * @param left defines the viewport left coordinate
  3453. * @param right defines the viewport right coordinate
  3454. * @param bottom defines the viewport bottom coordinate
  3455. * @param top defines the viewport top coordinate
  3456. * @param znear defines the near clip plane
  3457. * @param zfar defines the far clip plane
  3458. * @param result defines the target matrix
  3459. */
  3460. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3461. /**
  3462. * Creates a left-handed perspective projection matrix
  3463. * @param width defines the viewport width
  3464. * @param height defines the viewport height
  3465. * @param znear defines the near clip plane
  3466. * @param zfar defines the far clip plane
  3467. * @returns a new matrix as a left-handed perspective projection matrix
  3468. */
  3469. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3470. /**
  3471. * Creates a left-handed perspective projection matrix
  3472. * @param fov defines the horizontal field of view
  3473. * @param aspect defines the aspect ratio
  3474. * @param znear defines the near clip plane
  3475. * @param zfar defines the far clip plane
  3476. * @returns a new matrix as a left-handed perspective projection matrix
  3477. */
  3478. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3479. /**
  3480. * Stores a left-handed perspective projection into a given matrix
  3481. * @param fov defines the horizontal field of view
  3482. * @param aspect defines the aspect ratio
  3483. * @param znear defines the near clip plane
  3484. * @param zfar defines the far clip plane
  3485. * @param result defines the target matrix
  3486. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3487. */
  3488. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3489. /**
  3490. * Creates a right-handed perspective projection matrix
  3491. * @param fov defines the horizontal field of view
  3492. * @param aspect defines the aspect ratio
  3493. * @param znear defines the near clip plane
  3494. * @param zfar defines the far clip plane
  3495. * @returns a new matrix as a right-handed perspective projection matrix
  3496. */
  3497. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3498. /**
  3499. * Stores a right-handed perspective projection into a given matrix
  3500. * @param fov defines the horizontal field of view
  3501. * @param aspect defines the aspect ratio
  3502. * @param znear defines the near clip plane
  3503. * @param zfar defines the far clip plane
  3504. * @param result defines the target matrix
  3505. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3506. */
  3507. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3508. /**
  3509. * Stores a perspective projection for WebVR info a given matrix
  3510. * @param fov defines the field of view
  3511. * @param znear defines the near clip plane
  3512. * @param zfar defines the far clip plane
  3513. * @param result defines the target matrix
  3514. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3515. */
  3516. static PerspectiveFovWebVRToRef(fov: {
  3517. upDegrees: number;
  3518. downDegrees: number;
  3519. leftDegrees: number;
  3520. rightDegrees: number;
  3521. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3522. /**
  3523. * Computes a complete transformation matrix
  3524. * @param viewport defines the viewport to use
  3525. * @param world defines the world matrix
  3526. * @param view defines the view matrix
  3527. * @param projection defines the projection matrix
  3528. * @param zmin defines the near clip plane
  3529. * @param zmax defines the far clip plane
  3530. * @returns the transformation matrix
  3531. */
  3532. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3533. /**
  3534. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3535. * @param matrix defines the matrix to use
  3536. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3537. */
  3538. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3539. /**
  3540. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3541. * @param matrix defines the matrix to use
  3542. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3543. */
  3544. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3545. /**
  3546. * Compute the transpose of a given matrix
  3547. * @param matrix defines the matrix to transpose
  3548. * @returns the new matrix
  3549. */
  3550. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3551. /**
  3552. * Compute the transpose of a matrix and store it in a target matrix
  3553. * @param matrix defines the matrix to transpose
  3554. * @param result defines the target matrix
  3555. */
  3556. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  3557. /**
  3558. * Computes a reflection matrix from a plane
  3559. * @param plane defines the reflection plane
  3560. * @returns a new matrix
  3561. */
  3562. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  3563. /**
  3564. * Computes a reflection matrix from a plane
  3565. * @param plane defines the reflection plane
  3566. * @param result defines the target matrix
  3567. */
  3568. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  3569. /**
  3570. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  3571. * @param xaxis defines the value of the 1st axis
  3572. * @param yaxis defines the value of the 2nd axis
  3573. * @param zaxis defines the value of the 3rd axis
  3574. * @param result defines the target matrix
  3575. */
  3576. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  3577. /**
  3578. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  3579. * @param quat defines the quaternion to use
  3580. * @param result defines the target matrix
  3581. */
  3582. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  3583. }
  3584. /**
  3585. * Represens a plane by the equation ax + by + cz + d = 0
  3586. */
  3587. export class Plane {
  3588. /**
  3589. * Normal of the plane (a,b,c)
  3590. */
  3591. normal: Vector3;
  3592. /**
  3593. * d component of the plane
  3594. */
  3595. d: number;
  3596. /**
  3597. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  3598. * @param a a component of the plane
  3599. * @param b b component of the plane
  3600. * @param c c component of the plane
  3601. * @param d d component of the plane
  3602. */
  3603. constructor(a: number, b: number, c: number, d: number);
  3604. /**
  3605. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  3606. */
  3607. asArray(): number[];
  3608. /**
  3609. * @returns a new plane copied from the current Plane.
  3610. */
  3611. clone(): Plane;
  3612. /**
  3613. * @returns the string "Plane".
  3614. */
  3615. getClassName(): string;
  3616. /**
  3617. * @returns the Plane hash code.
  3618. */
  3619. getHashCode(): number;
  3620. /**
  3621. * Normalize the current Plane in place.
  3622. * @returns the updated Plane.
  3623. */
  3624. normalize(): Plane;
  3625. /**
  3626. * Applies a transformation the plane and returns the result
  3627. * @param transformation the transformation matrix to be applied to the plane
  3628. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  3629. */
  3630. transform(transformation: DeepImmutable<Matrix>): Plane;
  3631. /**
  3632. * Calcualtte the dot product between the point and the plane normal
  3633. * @param point point to calculate the dot product with
  3634. * @returns the dot product (float) of the point coordinates and the plane normal.
  3635. */
  3636. dotCoordinate(point: DeepImmutable<Vector3>): number;
  3637. /**
  3638. * Updates the current Plane from the plane defined by the three given points.
  3639. * @param point1 one of the points used to contruct the plane
  3640. * @param point2 one of the points used to contruct the plane
  3641. * @param point3 one of the points used to contruct the plane
  3642. * @returns the updated Plane.
  3643. */
  3644. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3645. /**
  3646. * Checks if the plane is facing a given direction
  3647. * @param direction the direction to check if the plane is facing
  3648. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  3649. * @returns True is the vector "direction" is the same side than the plane normal.
  3650. */
  3651. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  3652. /**
  3653. * Calculates the distance to a point
  3654. * @param point point to calculate distance to
  3655. * @returns the signed distance (float) from the given point to the Plane.
  3656. */
  3657. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  3658. /**
  3659. * Creates a plane from an array
  3660. * @param array the array to create a plane from
  3661. * @returns a new Plane from the given array.
  3662. */
  3663. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  3664. /**
  3665. * Creates a plane from three points
  3666. * @param point1 point used to create the plane
  3667. * @param point2 point used to create the plane
  3668. * @param point3 point used to create the plane
  3669. * @returns a new Plane defined by the three given points.
  3670. */
  3671. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3672. /**
  3673. * Creates a plane from an origin point and a normal
  3674. * @param origin origin of the plane to be constructed
  3675. * @param normal normal of the plane to be constructed
  3676. * @returns a new Plane the normal vector to this plane at the given origin point.
  3677. * Note : the vector "normal" is updated because normalized.
  3678. */
  3679. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  3680. /**
  3681. * Calculates the distance from a plane and a point
  3682. * @param origin origin of the plane to be constructed
  3683. * @param normal normal of the plane to be constructed
  3684. * @param point point to calculate distance to
  3685. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  3686. */
  3687. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  3688. }
  3689. /**
  3690. * Class used to represent a viewport on screen
  3691. */
  3692. export class Viewport {
  3693. /** viewport left coordinate */
  3694. x: number;
  3695. /** viewport top coordinate */
  3696. y: number;
  3697. /**viewport width */
  3698. width: number;
  3699. /** viewport height */
  3700. height: number;
  3701. /**
  3702. * Creates a Viewport object located at (x, y) and sized (width, height)
  3703. * @param x defines viewport left coordinate
  3704. * @param y defines viewport top coordinate
  3705. * @param width defines the viewport width
  3706. * @param height defines the viewport height
  3707. */
  3708. constructor(
  3709. /** viewport left coordinate */
  3710. x: number,
  3711. /** viewport top coordinate */
  3712. y: number,
  3713. /**viewport width */
  3714. width: number,
  3715. /** viewport height */
  3716. height: number);
  3717. /**
  3718. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  3719. * @param renderWidth defines the rendering width
  3720. * @param renderHeight defines the rendering height
  3721. * @returns a new Viewport
  3722. */
  3723. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  3724. /**
  3725. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  3726. * @param renderWidth defines the rendering width
  3727. * @param renderHeight defines the rendering height
  3728. * @param ref defines the target viewport
  3729. * @returns the current viewport
  3730. */
  3731. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  3732. /**
  3733. * Returns a new Viewport copied from the current one
  3734. * @returns a new Viewport
  3735. */
  3736. clone(): Viewport;
  3737. }
  3738. /**
  3739. * Reprasents a camera frustum
  3740. */
  3741. export class Frustum {
  3742. /**
  3743. * Gets the planes representing the frustum
  3744. * @param transform matrix to be applied to the returned planes
  3745. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  3746. */
  3747. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  3748. /**
  3749. * Gets the near frustum plane transformed by the transform matrix
  3750. * @param transform transformation matrix to be applied to the resulting frustum plane
  3751. * @param frustumPlane the resuling frustum plane
  3752. */
  3753. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3754. /**
  3755. * Gets the far frustum plane transformed by the transform matrix
  3756. * @param transform transformation matrix to be applied to the resulting frustum plane
  3757. * @param frustumPlane the resuling frustum plane
  3758. */
  3759. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3760. /**
  3761. * Gets the left frustum plane transformed by the transform matrix
  3762. * @param transform transformation matrix to be applied to the resulting frustum plane
  3763. * @param frustumPlane the resuling frustum plane
  3764. */
  3765. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3766. /**
  3767. * Gets the right frustum plane transformed by the transform matrix
  3768. * @param transform transformation matrix to be applied to the resulting frustum plane
  3769. * @param frustumPlane the resuling frustum plane
  3770. */
  3771. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3772. /**
  3773. * Gets the top frustum plane transformed by the transform matrix
  3774. * @param transform transformation matrix to be applied to the resulting frustum plane
  3775. * @param frustumPlane the resuling frustum plane
  3776. */
  3777. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3778. /**
  3779. * Gets the bottom frustum plane transformed by the transform matrix
  3780. * @param transform transformation matrix to be applied to the resulting frustum plane
  3781. * @param frustumPlane the resuling frustum plane
  3782. */
  3783. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3784. /**
  3785. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  3786. * @param transform transformation matrix to be applied to the resulting frustum planes
  3787. * @param frustumPlanes the resuling frustum planes
  3788. */
  3789. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  3790. }
  3791. /** Defines supported spaces */
  3792. export enum Space {
  3793. /** Local (object) space */
  3794. LOCAL = 0,
  3795. /** World space */
  3796. WORLD = 1,
  3797. /** Bone space */
  3798. BONE = 2
  3799. }
  3800. /** Defines the 3 main axes */
  3801. export class Axis {
  3802. /** X axis */
  3803. static X: Vector3;
  3804. /** Y axis */
  3805. static Y: Vector3;
  3806. /** Z axis */
  3807. static Z: Vector3;
  3808. }
  3809. /** Class used to represent a Bezier curve */
  3810. export class BezierCurve {
  3811. /**
  3812. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  3813. * @param t defines the time
  3814. * @param x1 defines the left coordinate on X axis
  3815. * @param y1 defines the left coordinate on Y axis
  3816. * @param x2 defines the right coordinate on X axis
  3817. * @param y2 defines the right coordinate on Y axis
  3818. * @returns the interpolated value
  3819. */
  3820. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  3821. }
  3822. /**
  3823. * Defines potential orientation for back face culling
  3824. */
  3825. export enum Orientation {
  3826. /**
  3827. * Clockwise
  3828. */
  3829. CW = 0,
  3830. /** Counter clockwise */
  3831. CCW = 1
  3832. }
  3833. /**
  3834. * Defines angle representation
  3835. */
  3836. export class Angle {
  3837. private _radians;
  3838. /**
  3839. * Creates an Angle object of "radians" radians (float).
  3840. * @param radians the angle in radians
  3841. */
  3842. constructor(radians: number);
  3843. /**
  3844. * Get value in degrees
  3845. * @returns the Angle value in degrees (float)
  3846. */
  3847. degrees(): number;
  3848. /**
  3849. * Get value in radians
  3850. * @returns the Angle value in radians (float)
  3851. */
  3852. radians(): number;
  3853. /**
  3854. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  3855. * @param a defines first vector
  3856. * @param b defines second vector
  3857. * @returns a new Angle
  3858. */
  3859. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  3860. /**
  3861. * Gets a new Angle object from the given float in radians
  3862. * @param radians defines the angle value in radians
  3863. * @returns a new Angle
  3864. */
  3865. static FromRadians(radians: number): Angle;
  3866. /**
  3867. * Gets a new Angle object from the given float in degrees
  3868. * @param degrees defines the angle value in degrees
  3869. * @returns a new Angle
  3870. */
  3871. static FromDegrees(degrees: number): Angle;
  3872. }
  3873. /**
  3874. * This represents an arc in a 2d space.
  3875. */
  3876. export class Arc2 {
  3877. /** Defines the start point of the arc */
  3878. startPoint: Vector2;
  3879. /** Defines the mid point of the arc */
  3880. midPoint: Vector2;
  3881. /** Defines the end point of the arc */
  3882. endPoint: Vector2;
  3883. /**
  3884. * Defines the center point of the arc.
  3885. */
  3886. centerPoint: Vector2;
  3887. /**
  3888. * Defines the radius of the arc.
  3889. */
  3890. radius: number;
  3891. /**
  3892. * Defines the angle of the arc (from mid point to end point).
  3893. */
  3894. angle: Angle;
  3895. /**
  3896. * Defines the start angle of the arc (from start point to middle point).
  3897. */
  3898. startAngle: Angle;
  3899. /**
  3900. * Defines the orientation of the arc (clock wise/counter clock wise).
  3901. */
  3902. orientation: Orientation;
  3903. /**
  3904. * Creates an Arc object from the three given points : start, middle and end.
  3905. * @param startPoint Defines the start point of the arc
  3906. * @param midPoint Defines the midlle point of the arc
  3907. * @param endPoint Defines the end point of the arc
  3908. */
  3909. constructor(
  3910. /** Defines the start point of the arc */
  3911. startPoint: Vector2,
  3912. /** Defines the mid point of the arc */
  3913. midPoint: Vector2,
  3914. /** Defines the end point of the arc */
  3915. endPoint: Vector2);
  3916. }
  3917. /**
  3918. * Represents a 2D path made up of multiple 2D points
  3919. */
  3920. export class Path2 {
  3921. private _points;
  3922. private _length;
  3923. /**
  3924. * If the path start and end point are the same
  3925. */
  3926. closed: boolean;
  3927. /**
  3928. * Creates a Path2 object from the starting 2D coordinates x and y.
  3929. * @param x the starting points x value
  3930. * @param y the starting points y value
  3931. */
  3932. constructor(x: number, y: number);
  3933. /**
  3934. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  3935. * @param x the added points x value
  3936. * @param y the added points y value
  3937. * @returns the updated Path2.
  3938. */
  3939. addLineTo(x: number, y: number): Path2;
  3940. /**
  3941. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  3942. * @param midX middle point x value
  3943. * @param midY middle point y value
  3944. * @param endX end point x value
  3945. * @param endY end point y value
  3946. * @param numberOfSegments (default: 36)
  3947. * @returns the updated Path2.
  3948. */
  3949. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  3950. /**
  3951. * Closes the Path2.
  3952. * @returns the Path2.
  3953. */
  3954. close(): Path2;
  3955. /**
  3956. * Gets the sum of the distance between each sequential point in the path
  3957. * @returns the Path2 total length (float).
  3958. */
  3959. length(): number;
  3960. /**
  3961. * Gets the points which construct the path
  3962. * @returns the Path2 internal array of points.
  3963. */
  3964. getPoints(): Vector2[];
  3965. /**
  3966. * Retreives the point at the distance aways from the starting point
  3967. * @param normalizedLengthPosition the length along the path to retreive the point from
  3968. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  3969. */
  3970. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  3971. /**
  3972. * Creates a new path starting from an x and y position
  3973. * @param x starting x value
  3974. * @param y starting y value
  3975. * @returns a new Path2 starting at the coordinates (x, y).
  3976. */
  3977. static StartingAt(x: number, y: number): Path2;
  3978. }
  3979. /**
  3980. * Represents a 3D path made up of multiple 3D points
  3981. */
  3982. export class Path3D {
  3983. /**
  3984. * an array of Vector3, the curve axis of the Path3D
  3985. */
  3986. path: Vector3[];
  3987. private _curve;
  3988. private _distances;
  3989. private _tangents;
  3990. private _normals;
  3991. private _binormals;
  3992. private _raw;
  3993. /**
  3994. * new Path3D(path, normal, raw)
  3995. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  3996. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  3997. * @param path an array of Vector3, the curve axis of the Path3D
  3998. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  3999. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4000. */
  4001. constructor(
  4002. /**
  4003. * an array of Vector3, the curve axis of the Path3D
  4004. */
  4005. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  4006. /**
  4007. * Returns the Path3D array of successive Vector3 designing its curve.
  4008. * @returns the Path3D array of successive Vector3 designing its curve.
  4009. */
  4010. getCurve(): Vector3[];
  4011. /**
  4012. * Returns an array populated with tangent vectors on each Path3D curve point.
  4013. * @returns an array populated with tangent vectors on each Path3D curve point.
  4014. */
  4015. getTangents(): Vector3[];
  4016. /**
  4017. * Returns an array populated with normal vectors on each Path3D curve point.
  4018. * @returns an array populated with normal vectors on each Path3D curve point.
  4019. */
  4020. getNormals(): Vector3[];
  4021. /**
  4022. * Returns an array populated with binormal vectors on each Path3D curve point.
  4023. * @returns an array populated with binormal vectors on each Path3D curve point.
  4024. */
  4025. getBinormals(): Vector3[];
  4026. /**
  4027. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4028. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4029. */
  4030. getDistances(): number[];
  4031. /**
  4032. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4033. * @param path path which all values are copied into the curves points
  4034. * @param firstNormal which should be projected onto the curve
  4035. * @returns the same object updated.
  4036. */
  4037. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  4038. private _compute;
  4039. private _getFirstNonNullVector;
  4040. private _getLastNonNullVector;
  4041. private _normalVector;
  4042. }
  4043. /**
  4044. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4045. * A Curve3 is designed from a series of successive Vector3.
  4046. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4047. */
  4048. export class Curve3 {
  4049. private _points;
  4050. private _length;
  4051. /**
  4052. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4053. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4054. * @param v1 (Vector3) the control point
  4055. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4056. * @param nbPoints (integer) the wanted number of points in the curve
  4057. * @returns the created Curve3
  4058. */
  4059. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4060. /**
  4061. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4062. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4063. * @param v1 (Vector3) the first control point
  4064. * @param v2 (Vector3) the second control point
  4065. * @param v3 (Vector3) the end point of the Cubic Bezier
  4066. * @param nbPoints (integer) the wanted number of points in the curve
  4067. * @returns the created Curve3
  4068. */
  4069. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4070. /**
  4071. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4072. * @param p1 (Vector3) the origin point of the Hermite Spline
  4073. * @param t1 (Vector3) the tangent vector at the origin point
  4074. * @param p2 (Vector3) the end point of the Hermite Spline
  4075. * @param t2 (Vector3) the tangent vector at the end point
  4076. * @param nbPoints (integer) the wanted number of points in the curve
  4077. * @returns the created Curve3
  4078. */
  4079. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4080. /**
  4081. * Returns a Curve3 object along a CatmullRom Spline curve :
  4082. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4083. * @param nbPoints (integer) the wanted number of points between each curve control points
  4084. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4085. * @returns the created Curve3
  4086. */
  4087. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4088. /**
  4089. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4090. * A Curve3 is designed from a series of successive Vector3.
  4091. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4092. * @param points points which make up the curve
  4093. */
  4094. constructor(points: Vector3[]);
  4095. /**
  4096. * @returns the Curve3 stored array of successive Vector3
  4097. */
  4098. getPoints(): Vector3[];
  4099. /**
  4100. * @returns the computed length (float) of the curve.
  4101. */
  4102. length(): number;
  4103. /**
  4104. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4105. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4106. * curveA and curveB keep unchanged.
  4107. * @param curve the curve to continue from this curve
  4108. * @returns the newly constructed curve
  4109. */
  4110. continue(curve: DeepImmutable<Curve3>): Curve3;
  4111. private _computeLength;
  4112. }
  4113. /**
  4114. * Contains position and normal vectors for a vertex
  4115. */
  4116. export class PositionNormalVertex {
  4117. /** the position of the vertex (defaut: 0,0,0) */
  4118. position: Vector3;
  4119. /** the normal of the vertex (defaut: 0,1,0) */
  4120. normal: Vector3;
  4121. /**
  4122. * Creates a PositionNormalVertex
  4123. * @param position the position of the vertex (defaut: 0,0,0)
  4124. * @param normal the normal of the vertex (defaut: 0,1,0)
  4125. */
  4126. constructor(
  4127. /** the position of the vertex (defaut: 0,0,0) */
  4128. position?: Vector3,
  4129. /** the normal of the vertex (defaut: 0,1,0) */
  4130. normal?: Vector3);
  4131. /**
  4132. * Clones the PositionNormalVertex
  4133. * @returns the cloned PositionNormalVertex
  4134. */
  4135. clone(): PositionNormalVertex;
  4136. }
  4137. /**
  4138. * Contains position, normal and uv vectors for a vertex
  4139. */
  4140. export class PositionNormalTextureVertex {
  4141. /** the position of the vertex (defaut: 0,0,0) */
  4142. position: Vector3;
  4143. /** the normal of the vertex (defaut: 0,1,0) */
  4144. normal: Vector3;
  4145. /** the uv of the vertex (default: 0,0) */
  4146. uv: Vector2;
  4147. /**
  4148. * Creates a PositionNormalTextureVertex
  4149. * @param position the position of the vertex (defaut: 0,0,0)
  4150. * @param normal the normal of the vertex (defaut: 0,1,0)
  4151. * @param uv the uv of the vertex (default: 0,0)
  4152. */
  4153. constructor(
  4154. /** the position of the vertex (defaut: 0,0,0) */
  4155. position?: Vector3,
  4156. /** the normal of the vertex (defaut: 0,1,0) */
  4157. normal?: Vector3,
  4158. /** the uv of the vertex (default: 0,0) */
  4159. uv?: Vector2);
  4160. /**
  4161. * Clones the PositionNormalTextureVertex
  4162. * @returns the cloned PositionNormalTextureVertex
  4163. */
  4164. clone(): PositionNormalTextureVertex;
  4165. }
  4166. /**
  4167. * @hidden
  4168. */
  4169. export class Tmp {
  4170. static Color3: Color3[];
  4171. static Color4: Color4[];
  4172. static Vector2: Vector2[];
  4173. static Vector3: Vector3[];
  4174. static Vector4: Vector4[];
  4175. static Quaternion: Quaternion[];
  4176. static Matrix: Matrix[];
  4177. }
  4178. }
  4179. declare module "babylonjs/Offline/IOfflineProvider" {
  4180. /**
  4181. * Class used to enable access to offline support
  4182. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4183. */
  4184. export interface IOfflineProvider {
  4185. /**
  4186. * Gets a boolean indicating if scene must be saved in the database
  4187. */
  4188. enableSceneOffline: boolean;
  4189. /**
  4190. * Gets a boolean indicating if textures must be saved in the database
  4191. */
  4192. enableTexturesOffline: boolean;
  4193. /**
  4194. * Open the offline support and make it available
  4195. * @param successCallback defines the callback to call on success
  4196. * @param errorCallback defines the callback to call on error
  4197. */
  4198. open(successCallback: () => void, errorCallback: () => void): void;
  4199. /**
  4200. * Loads an image from the offline support
  4201. * @param url defines the url to load from
  4202. * @param image defines the target DOM image
  4203. */
  4204. loadImage(url: string, image: HTMLImageElement): void;
  4205. /**
  4206. * Loads a file from offline support
  4207. * @param url defines the URL to load from
  4208. * @param sceneLoaded defines a callback to call on success
  4209. * @param progressCallBack defines a callback to call when progress changed
  4210. * @param errorCallback defines a callback to call on error
  4211. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4212. */
  4213. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4214. }
  4215. }
  4216. declare module "babylonjs/Misc/observable" {
  4217. import { Nullable } from "babylonjs/types";
  4218. /**
  4219. * A class serves as a medium between the observable and its observers
  4220. */
  4221. export class EventState {
  4222. /**
  4223. * Create a new EventState
  4224. * @param mask defines the mask associated with this state
  4225. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4226. * @param target defines the original target of the state
  4227. * @param currentTarget defines the current target of the state
  4228. */
  4229. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  4230. /**
  4231. * Initialize the current event state
  4232. * @param mask defines the mask associated with this state
  4233. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4234. * @param target defines the original target of the state
  4235. * @param currentTarget defines the current target of the state
  4236. * @returns the current event state
  4237. */
  4238. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  4239. /**
  4240. * An Observer can set this property to true to prevent subsequent observers of being notified
  4241. */
  4242. skipNextObservers: boolean;
  4243. /**
  4244. * Get the mask value that were used to trigger the event corresponding to this EventState object
  4245. */
  4246. mask: number;
  4247. /**
  4248. * The object that originally notified the event
  4249. */
  4250. target?: any;
  4251. /**
  4252. * The current object in the bubbling phase
  4253. */
  4254. currentTarget?: any;
  4255. /**
  4256. * This will be populated with the return value of the last function that was executed.
  4257. * If it is the first function in the callback chain it will be the event data.
  4258. */
  4259. lastReturnValue?: any;
  4260. }
  4261. /**
  4262. * Represent an Observer registered to a given Observable object.
  4263. */
  4264. export class Observer<T> {
  4265. /**
  4266. * Defines the callback to call when the observer is notified
  4267. */
  4268. callback: (eventData: T, eventState: EventState) => void;
  4269. /**
  4270. * Defines the mask of the observer (used to filter notifications)
  4271. */
  4272. mask: number;
  4273. /**
  4274. * Defines the current scope used to restore the JS context
  4275. */
  4276. scope: any;
  4277. /** @hidden */
  4278. _willBeUnregistered: boolean;
  4279. /**
  4280. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  4281. */
  4282. unregisterOnNextCall: boolean;
  4283. /**
  4284. * Creates a new observer
  4285. * @param callback defines the callback to call when the observer is notified
  4286. * @param mask defines the mask of the observer (used to filter notifications)
  4287. * @param scope defines the current scope used to restore the JS context
  4288. */
  4289. constructor(
  4290. /**
  4291. * Defines the callback to call when the observer is notified
  4292. */
  4293. callback: (eventData: T, eventState: EventState) => void,
  4294. /**
  4295. * Defines the mask of the observer (used to filter notifications)
  4296. */
  4297. mask: number,
  4298. /**
  4299. * Defines the current scope used to restore the JS context
  4300. */
  4301. scope?: any);
  4302. }
  4303. /**
  4304. * Represent a list of observers registered to multiple Observables object.
  4305. */
  4306. export class MultiObserver<T> {
  4307. private _observers;
  4308. private _observables;
  4309. /**
  4310. * Release associated resources
  4311. */
  4312. dispose(): void;
  4313. /**
  4314. * Raise a callback when one of the observable will notify
  4315. * @param observables defines a list of observables to watch
  4316. * @param callback defines the callback to call on notification
  4317. * @param mask defines the mask used to filter notifications
  4318. * @param scope defines the current scope used to restore the JS context
  4319. * @returns the new MultiObserver
  4320. */
  4321. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  4322. }
  4323. /**
  4324. * The Observable class is a simple implementation of the Observable pattern.
  4325. *
  4326. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  4327. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  4328. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  4329. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  4330. */
  4331. export class Observable<T> {
  4332. private _observers;
  4333. private _eventState;
  4334. private _onObserverAdded;
  4335. /**
  4336. * Creates a new observable
  4337. * @param onObserverAdded defines a callback to call when a new observer is added
  4338. */
  4339. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  4340. /**
  4341. * Create a new Observer with the specified callback
  4342. * @param callback the callback that will be executed for that Observer
  4343. * @param mask the mask used to filter observers
  4344. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  4345. * @param scope optional scope for the callback to be called from
  4346. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  4347. * @returns the new observer created for the callback
  4348. */
  4349. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  4350. /**
  4351. * Create a new Observer with the specified callback and unregisters after the next notification
  4352. * @param callback the callback that will be executed for that Observer
  4353. * @returns the new observer created for the callback
  4354. */
  4355. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  4356. /**
  4357. * Remove an Observer from the Observable object
  4358. * @param observer the instance of the Observer to remove
  4359. * @returns false if it doesn't belong to this Observable
  4360. */
  4361. remove(observer: Nullable<Observer<T>>): boolean;
  4362. /**
  4363. * Remove a callback from the Observable object
  4364. * @param callback the callback to remove
  4365. * @param scope optional scope. If used only the callbacks with this scope will be removed
  4366. * @returns false if it doesn't belong to this Observable
  4367. */
  4368. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  4369. private _deferUnregister;
  4370. private _remove;
  4371. /**
  4372. * Moves the observable to the top of the observer list making it get called first when notified
  4373. * @param observer the observer to move
  4374. */
  4375. makeObserverTopPriority(observer: Observer<T>): void;
  4376. /**
  4377. * Moves the observable to the bottom of the observer list making it get called last when notified
  4378. * @param observer the observer to move
  4379. */
  4380. makeObserverBottomPriority(observer: Observer<T>): void;
  4381. /**
  4382. * Notify all Observers by calling their respective callback with the given data
  4383. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  4384. * @param eventData defines the data to send to all observers
  4385. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  4386. * @param target defines the original target of the state
  4387. * @param currentTarget defines the current target of the state
  4388. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  4389. */
  4390. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  4391. /**
  4392. * Calling this will execute each callback, expecting it to be a promise or return a value.
  4393. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  4394. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  4395. * and it is crucial that all callbacks will be executed.
  4396. * The order of the callbacks is kept, callbacks are not executed parallel.
  4397. *
  4398. * @param eventData The data to be sent to each callback
  4399. * @param mask is used to filter observers defaults to -1
  4400. * @param target defines the callback target (see EventState)
  4401. * @param currentTarget defines he current object in the bubbling phase
  4402. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  4403. */
  4404. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  4405. /**
  4406. * Notify a specific observer
  4407. * @param observer defines the observer to notify
  4408. * @param eventData defines the data to be sent to each callback
  4409. * @param mask is used to filter observers defaults to -1
  4410. */
  4411. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  4412. /**
  4413. * Gets a boolean indicating if the observable has at least one observer
  4414. * @returns true is the Observable has at least one Observer registered
  4415. */
  4416. hasObservers(): boolean;
  4417. /**
  4418. * Clear the list of observers
  4419. */
  4420. clear(): void;
  4421. /**
  4422. * Clone the current observable
  4423. * @returns a new observable
  4424. */
  4425. clone(): Observable<T>;
  4426. /**
  4427. * Does this observable handles observer registered with a given mask
  4428. * @param mask defines the mask to be tested
  4429. * @return whether or not one observer registered with the given mask is handeled
  4430. **/
  4431. hasSpecificMask(mask?: number): boolean;
  4432. }
  4433. }
  4434. declare module "babylonjs/Misc/filesInputStore" {
  4435. /**
  4436. * Class used to help managing file picking and drag'n'drop
  4437. * File Storage
  4438. */
  4439. export class FilesInputStore {
  4440. /**
  4441. * List of files ready to be loaded
  4442. */
  4443. static FilesToLoad: {
  4444. [key: string]: File;
  4445. };
  4446. }
  4447. }
  4448. declare module "babylonjs/Engines/constants" {
  4449. /** Defines the cross module used constants to avoid circular dependncies */
  4450. export class Constants {
  4451. /** Defines that alpha blending is disabled */
  4452. static readonly ALPHA_DISABLE: number;
  4453. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4454. static readonly ALPHA_ADD: number;
  4455. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4456. static readonly ALPHA_COMBINE: number;
  4457. /** Defines that alpha blending to DEST - SRC * DEST */
  4458. static readonly ALPHA_SUBTRACT: number;
  4459. /** Defines that alpha blending to SRC * DEST */
  4460. static readonly ALPHA_MULTIPLY: number;
  4461. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4462. static readonly ALPHA_MAXIMIZED: number;
  4463. /** Defines that alpha blending to SRC + DEST */
  4464. static readonly ALPHA_ONEONE: number;
  4465. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4466. static readonly ALPHA_PREMULTIPLIED: number;
  4467. /**
  4468. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4469. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4470. */
  4471. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4472. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4473. static readonly ALPHA_INTERPOLATE: number;
  4474. /**
  4475. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4476. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4477. */
  4478. static readonly ALPHA_SCREENMODE: number;
  4479. /** Defines that the ressource is not delayed*/
  4480. static readonly DELAYLOADSTATE_NONE: number;
  4481. /** Defines that the ressource was successfully delay loaded */
  4482. static readonly DELAYLOADSTATE_LOADED: number;
  4483. /** Defines that the ressource is currently delay loading */
  4484. static readonly DELAYLOADSTATE_LOADING: number;
  4485. /** Defines that the ressource is delayed and has not started loading */
  4486. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4487. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4488. static readonly NEVER: number;
  4489. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  4490. static readonly ALWAYS: number;
  4491. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4492. static readonly LESS: number;
  4493. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4494. static readonly EQUAL: number;
  4495. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  4496. static readonly LEQUAL: number;
  4497. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4498. static readonly GREATER: number;
  4499. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  4500. static readonly GEQUAL: number;
  4501. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  4502. static readonly NOTEQUAL: number;
  4503. /** Passed to stencilOperation to specify that stencil value must be kept */
  4504. static readonly KEEP: number;
  4505. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4506. static readonly REPLACE: number;
  4507. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4508. static readonly INCR: number;
  4509. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4510. static readonly DECR: number;
  4511. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4512. static readonly INVERT: number;
  4513. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4514. static readonly INCR_WRAP: number;
  4515. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4516. static readonly DECR_WRAP: number;
  4517. /** Texture is not repeating outside of 0..1 UVs */
  4518. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4519. /** Texture is repeating outside of 0..1 UVs */
  4520. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4521. /** Texture is repeating and mirrored */
  4522. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4523. /** ALPHA */
  4524. static readonly TEXTUREFORMAT_ALPHA: number;
  4525. /** LUMINANCE */
  4526. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4527. /** LUMINANCE_ALPHA */
  4528. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4529. /** RGB */
  4530. static readonly TEXTUREFORMAT_RGB: number;
  4531. /** RGBA */
  4532. static readonly TEXTUREFORMAT_RGBA: number;
  4533. /** RED */
  4534. static readonly TEXTUREFORMAT_RED: number;
  4535. /** RED (2nd reference) */
  4536. static readonly TEXTUREFORMAT_R: number;
  4537. /** RG */
  4538. static readonly TEXTUREFORMAT_RG: number;
  4539. /** RED_INTEGER */
  4540. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4541. /** RED_INTEGER (2nd reference) */
  4542. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4543. /** RG_INTEGER */
  4544. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4545. /** RGB_INTEGER */
  4546. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4547. /** RGBA_INTEGER */
  4548. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4549. /** UNSIGNED_BYTE */
  4550. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4551. /** UNSIGNED_BYTE (2nd reference) */
  4552. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4553. /** FLOAT */
  4554. static readonly TEXTURETYPE_FLOAT: number;
  4555. /** HALF_FLOAT */
  4556. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4557. /** BYTE */
  4558. static readonly TEXTURETYPE_BYTE: number;
  4559. /** SHORT */
  4560. static readonly TEXTURETYPE_SHORT: number;
  4561. /** UNSIGNED_SHORT */
  4562. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4563. /** INT */
  4564. static readonly TEXTURETYPE_INT: number;
  4565. /** UNSIGNED_INT */
  4566. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4567. /** UNSIGNED_SHORT_4_4_4_4 */
  4568. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4569. /** UNSIGNED_SHORT_5_5_5_1 */
  4570. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4571. /** UNSIGNED_SHORT_5_6_5 */
  4572. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4573. /** UNSIGNED_INT_2_10_10_10_REV */
  4574. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4575. /** UNSIGNED_INT_24_8 */
  4576. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4577. /** UNSIGNED_INT_10F_11F_11F_REV */
  4578. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4579. /** UNSIGNED_INT_5_9_9_9_REV */
  4580. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4581. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4582. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4583. /** nearest is mag = nearest and min = nearest and mip = linear */
  4584. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4585. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4586. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4587. /** Trilinear is mag = linear and min = linear and mip = linear */
  4588. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4589. /** nearest is mag = nearest and min = nearest and mip = linear */
  4590. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4591. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4592. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4593. /** Trilinear is mag = linear and min = linear and mip = linear */
  4594. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4595. /** mag = nearest and min = nearest and mip = nearest */
  4596. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4597. /** mag = nearest and min = linear and mip = nearest */
  4598. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4599. /** mag = nearest and min = linear and mip = linear */
  4600. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4601. /** mag = nearest and min = linear and mip = none */
  4602. static readonly TEXTURE_NEAREST_LINEAR: number;
  4603. /** mag = nearest and min = nearest and mip = none */
  4604. static readonly TEXTURE_NEAREST_NEAREST: number;
  4605. /** mag = linear and min = nearest and mip = nearest */
  4606. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4607. /** mag = linear and min = nearest and mip = linear */
  4608. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4609. /** mag = linear and min = linear and mip = none */
  4610. static readonly TEXTURE_LINEAR_LINEAR: number;
  4611. /** mag = linear and min = nearest and mip = none */
  4612. static readonly TEXTURE_LINEAR_NEAREST: number;
  4613. /** Explicit coordinates mode */
  4614. static readonly TEXTURE_EXPLICIT_MODE: number;
  4615. /** Spherical coordinates mode */
  4616. static readonly TEXTURE_SPHERICAL_MODE: number;
  4617. /** Planar coordinates mode */
  4618. static readonly TEXTURE_PLANAR_MODE: number;
  4619. /** Cubic coordinates mode */
  4620. static readonly TEXTURE_CUBIC_MODE: number;
  4621. /** Projection coordinates mode */
  4622. static readonly TEXTURE_PROJECTION_MODE: number;
  4623. /** Skybox coordinates mode */
  4624. static readonly TEXTURE_SKYBOX_MODE: number;
  4625. /** Inverse Cubic coordinates mode */
  4626. static readonly TEXTURE_INVCUBIC_MODE: number;
  4627. /** Equirectangular coordinates mode */
  4628. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4629. /** Equirectangular Fixed coordinates mode */
  4630. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4631. /** Equirectangular Fixed Mirrored coordinates mode */
  4632. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4633. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4634. static readonly SCALEMODE_FLOOR: number;
  4635. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4636. static readonly SCALEMODE_NEAREST: number;
  4637. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4638. static readonly SCALEMODE_CEILING: number;
  4639. /**
  4640. * The dirty texture flag value
  4641. */
  4642. static readonly MATERIAL_TextureDirtyFlag: number;
  4643. /**
  4644. * The dirty light flag value
  4645. */
  4646. static readonly MATERIAL_LightDirtyFlag: number;
  4647. /**
  4648. * The dirty fresnel flag value
  4649. */
  4650. static readonly MATERIAL_FresnelDirtyFlag: number;
  4651. /**
  4652. * The dirty attribute flag value
  4653. */
  4654. static readonly MATERIAL_AttributesDirtyFlag: number;
  4655. /**
  4656. * The dirty misc flag value
  4657. */
  4658. static readonly MATERIAL_MiscDirtyFlag: number;
  4659. /**
  4660. * The all dirty flag value
  4661. */
  4662. static readonly MATERIAL_AllDirtyFlag: number;
  4663. /**
  4664. * Returns the triangle fill mode
  4665. */
  4666. static readonly MATERIAL_TriangleFillMode: number;
  4667. /**
  4668. * Returns the wireframe mode
  4669. */
  4670. static readonly MATERIAL_WireFrameFillMode: number;
  4671. /**
  4672. * Returns the point fill mode
  4673. */
  4674. static readonly MATERIAL_PointFillMode: number;
  4675. /**
  4676. * Returns the point list draw mode
  4677. */
  4678. static readonly MATERIAL_PointListDrawMode: number;
  4679. /**
  4680. * Returns the line list draw mode
  4681. */
  4682. static readonly MATERIAL_LineListDrawMode: number;
  4683. /**
  4684. * Returns the line loop draw mode
  4685. */
  4686. static readonly MATERIAL_LineLoopDrawMode: number;
  4687. /**
  4688. * Returns the line strip draw mode
  4689. */
  4690. static readonly MATERIAL_LineStripDrawMode: number;
  4691. /**
  4692. * Returns the triangle strip draw mode
  4693. */
  4694. static readonly MATERIAL_TriangleStripDrawMode: number;
  4695. /**
  4696. * Returns the triangle fan draw mode
  4697. */
  4698. static readonly MATERIAL_TriangleFanDrawMode: number;
  4699. /**
  4700. * Stores the clock-wise side orientation
  4701. */
  4702. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4703. /**
  4704. * Stores the counter clock-wise side orientation
  4705. */
  4706. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4707. /**
  4708. * Nothing
  4709. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4710. */
  4711. static readonly ACTION_NothingTrigger: number;
  4712. /**
  4713. * On pick
  4714. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4715. */
  4716. static readonly ACTION_OnPickTrigger: number;
  4717. /**
  4718. * On left pick
  4719. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4720. */
  4721. static readonly ACTION_OnLeftPickTrigger: number;
  4722. /**
  4723. * On right pick
  4724. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4725. */
  4726. static readonly ACTION_OnRightPickTrigger: number;
  4727. /**
  4728. * On center pick
  4729. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4730. */
  4731. static readonly ACTION_OnCenterPickTrigger: number;
  4732. /**
  4733. * On pick down
  4734. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4735. */
  4736. static readonly ACTION_OnPickDownTrigger: number;
  4737. /**
  4738. * On double pick
  4739. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4740. */
  4741. static readonly ACTION_OnDoublePickTrigger: number;
  4742. /**
  4743. * On pick up
  4744. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4745. */
  4746. static readonly ACTION_OnPickUpTrigger: number;
  4747. /**
  4748. * On pick out.
  4749. * This trigger will only be raised if you also declared a OnPickDown
  4750. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4751. */
  4752. static readonly ACTION_OnPickOutTrigger: number;
  4753. /**
  4754. * On long press
  4755. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4756. */
  4757. static readonly ACTION_OnLongPressTrigger: number;
  4758. /**
  4759. * On pointer over
  4760. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4761. */
  4762. static readonly ACTION_OnPointerOverTrigger: number;
  4763. /**
  4764. * On pointer out
  4765. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4766. */
  4767. static readonly ACTION_OnPointerOutTrigger: number;
  4768. /**
  4769. * On every frame
  4770. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4771. */
  4772. static readonly ACTION_OnEveryFrameTrigger: number;
  4773. /**
  4774. * On intersection enter
  4775. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4776. */
  4777. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4778. /**
  4779. * On intersection exit
  4780. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4781. */
  4782. static readonly ACTION_OnIntersectionExitTrigger: number;
  4783. /**
  4784. * On key down
  4785. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4786. */
  4787. static readonly ACTION_OnKeyDownTrigger: number;
  4788. /**
  4789. * On key up
  4790. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4791. */
  4792. static readonly ACTION_OnKeyUpTrigger: number;
  4793. /**
  4794. * Billboard mode will only apply to Y axis
  4795. */
  4796. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4797. /**
  4798. * Billboard mode will apply to all axes
  4799. */
  4800. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4801. /**
  4802. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4803. */
  4804. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4805. /**
  4806. * Gets or sets base Assets URL
  4807. */
  4808. static readonly PARTICLES_BaseAssetsUrl: string;
  4809. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4810. * Test order :
  4811. * Is the bounding sphere outside the frustum ?
  4812. * If not, are the bounding box vertices outside the frustum ?
  4813. * It not, then the cullable object is in the frustum.
  4814. */
  4815. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4816. /** Culling strategy : Bounding Sphere Only.
  4817. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4818. * It's also less accurate than the standard because some not visible objects can still be selected.
  4819. * Test : is the bounding sphere outside the frustum ?
  4820. * If not, then the cullable object is in the frustum.
  4821. */
  4822. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4823. /** Culling strategy : Optimistic Inclusion.
  4824. * This in an inclusion test first, then the standard exclusion test.
  4825. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4826. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  4827. * Anyway, it's as accurate as the standard strategy.
  4828. * Test :
  4829. * Is the cullable object bounding sphere center in the frustum ?
  4830. * If not, apply the default culling strategy.
  4831. */
  4832. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4833. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4834. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4835. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4836. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  4837. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4838. * Test :
  4839. * Is the cullable object bounding sphere center in the frustum ?
  4840. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4841. */
  4842. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4843. /**
  4844. * No logging while loading
  4845. */
  4846. static readonly SCENELOADER_NO_LOGGING: number;
  4847. /**
  4848. * Minimal logging while loading
  4849. */
  4850. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4851. /**
  4852. * Summary logging while loading
  4853. */
  4854. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4855. /**
  4856. * Detailled logging while loading
  4857. */
  4858. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4859. }
  4860. }
  4861. declare module "babylonjs/Misc/domManagement" {
  4862. /**
  4863. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  4864. * Babylon.js
  4865. */
  4866. export class DomManagement {
  4867. /**
  4868. * Checks if the window object exists
  4869. * @returns true if the window object exists
  4870. */
  4871. static IsWindowObjectExist(): boolean;
  4872. /**
  4873. * Extracts text content from a DOM element hierarchy
  4874. * @param element defines the root element
  4875. * @returns a string
  4876. */
  4877. static GetDOMTextContent(element: HTMLElement): string;
  4878. }
  4879. }
  4880. declare module "babylonjs/Misc/logger" {
  4881. /**
  4882. * Logger used througouht the application to allow configuration of
  4883. * the log level required for the messages.
  4884. */
  4885. export class Logger {
  4886. /**
  4887. * No log
  4888. */
  4889. static readonly NoneLogLevel: number;
  4890. /**
  4891. * Only message logs
  4892. */
  4893. static readonly MessageLogLevel: number;
  4894. /**
  4895. * Only warning logs
  4896. */
  4897. static readonly WarningLogLevel: number;
  4898. /**
  4899. * Only error logs
  4900. */
  4901. static readonly ErrorLogLevel: number;
  4902. /**
  4903. * All logs
  4904. */
  4905. static readonly AllLogLevel: number;
  4906. private static _LogCache;
  4907. /**
  4908. * Gets a value indicating the number of loading errors
  4909. * @ignorenaming
  4910. */
  4911. static errorsCount: number;
  4912. /**
  4913. * Callback called when a new log is added
  4914. */
  4915. static OnNewCacheEntry: (entry: string) => void;
  4916. private static _AddLogEntry;
  4917. private static _FormatMessage;
  4918. private static _LogDisabled;
  4919. private static _LogEnabled;
  4920. private static _WarnDisabled;
  4921. private static _WarnEnabled;
  4922. private static _ErrorDisabled;
  4923. private static _ErrorEnabled;
  4924. /**
  4925. * Log a message to the console
  4926. */
  4927. static Log: (message: string) => void;
  4928. /**
  4929. * Write a warning message to the console
  4930. */
  4931. static Warn: (message: string) => void;
  4932. /**
  4933. * Write an error message to the console
  4934. */
  4935. static Error: (message: string) => void;
  4936. /**
  4937. * Gets current log cache (list of logs)
  4938. */
  4939. static readonly LogCache: string;
  4940. /**
  4941. * Clears the log cache
  4942. */
  4943. static ClearLogCache(): void;
  4944. /**
  4945. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  4946. */
  4947. static LogLevels: number;
  4948. }
  4949. }
  4950. declare module "babylonjs/Misc/typeStore" {
  4951. /** @hidden */
  4952. export class _TypeStore {
  4953. /** @hidden */
  4954. static RegisteredTypes: {
  4955. [key: string]: Object;
  4956. };
  4957. /** @hidden */
  4958. static GetClass(fqdn: string): any;
  4959. }
  4960. }
  4961. declare module "babylonjs/Misc/deepCopier" {
  4962. /**
  4963. * Class containing a set of static utilities functions for deep copy.
  4964. */
  4965. export class DeepCopier {
  4966. /**
  4967. * Tries to copy an object by duplicating every property
  4968. * @param source defines the source object
  4969. * @param destination defines the target object
  4970. * @param doNotCopyList defines a list of properties to avoid
  4971. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  4972. */
  4973. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  4974. }
  4975. }
  4976. declare module "babylonjs/Misc/precisionDate" {
  4977. /**
  4978. * Class containing a set of static utilities functions for precision date
  4979. */
  4980. export class PrecisionDate {
  4981. /**
  4982. * Gets either window.performance.now() if supported or Date.now() else
  4983. */
  4984. static readonly Now: number;
  4985. }
  4986. }
  4987. declare module "babylonjs/Misc/devTools" {
  4988. /** @hidden */
  4989. export class _DevTools {
  4990. static WarnImport(name: string): string;
  4991. }
  4992. }
  4993. declare module "babylonjs/Misc/webRequest" {
  4994. /**
  4995. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  4996. */
  4997. export class WebRequest {
  4998. private _xhr;
  4999. /**
  5000. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  5001. * i.e. when loading files, where the server/service expects an Authorization header
  5002. */
  5003. static CustomRequestHeaders: {
  5004. [key: string]: string;
  5005. };
  5006. /**
  5007. * Add callback functions in this array to update all the requests before they get sent to the network
  5008. */
  5009. static CustomRequestModifiers: ((request: XMLHttpRequest) => void)[];
  5010. private _injectCustomRequestHeaders;
  5011. /**
  5012. * Gets or sets a function to be called when loading progress changes
  5013. */
  5014. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  5015. /**
  5016. * Returns client's state
  5017. */
  5018. readonly readyState: number;
  5019. /**
  5020. * Returns client's status
  5021. */
  5022. readonly status: number;
  5023. /**
  5024. * Returns client's status as a text
  5025. */
  5026. readonly statusText: string;
  5027. /**
  5028. * Returns client's response
  5029. */
  5030. readonly response: any;
  5031. /**
  5032. * Returns client's response url
  5033. */
  5034. readonly responseURL: string;
  5035. /**
  5036. * Returns client's response as text
  5037. */
  5038. readonly responseText: string;
  5039. /**
  5040. * Gets or sets the expected response type
  5041. */
  5042. responseType: XMLHttpRequestResponseType;
  5043. /** @hidden */
  5044. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  5045. /** @hidden */
  5046. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  5047. /**
  5048. * Cancels any network activity
  5049. */
  5050. abort(): void;
  5051. /**
  5052. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  5053. * @param body defines an optional request body
  5054. */
  5055. send(body?: Document | BodyInit | null): void;
  5056. /**
  5057. * Sets the request method, request URL
  5058. * @param method defines the method to use (GET, POST, etc..)
  5059. * @param url defines the url to connect with
  5060. */
  5061. open(method: string, url: string): void;
  5062. }
  5063. }
  5064. declare module "babylonjs/Misc/andOrNotEvaluator" {
  5065. /**
  5066. * Class used to evalaute queries containing `and` and `or` operators
  5067. */
  5068. export class AndOrNotEvaluator {
  5069. /**
  5070. * Evaluate a query
  5071. * @param query defines the query to evaluate
  5072. * @param evaluateCallback defines the callback used to filter result
  5073. * @returns true if the query matches
  5074. */
  5075. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5076. private static _HandleParenthesisContent;
  5077. private static _SimplifyNegation;
  5078. }
  5079. }
  5080. declare module "babylonjs/Misc/tags" {
  5081. /**
  5082. * Class used to store custom tags
  5083. */
  5084. export class Tags {
  5085. /**
  5086. * Adds support for tags on the given object
  5087. * @param obj defines the object to use
  5088. */
  5089. static EnableFor(obj: any): void;
  5090. /**
  5091. * Removes tags support
  5092. * @param obj defines the object to use
  5093. */
  5094. static DisableFor(obj: any): void;
  5095. /**
  5096. * Gets a boolean indicating if the given object has tags
  5097. * @param obj defines the object to use
  5098. * @returns a boolean
  5099. */
  5100. static HasTags(obj: any): boolean;
  5101. /**
  5102. * Gets the tags available on a given object
  5103. * @param obj defines the object to use
  5104. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5105. * @returns the tags
  5106. */
  5107. static GetTags(obj: any, asString?: boolean): any;
  5108. /**
  5109. * Adds tags to an object
  5110. * @param obj defines the object to use
  5111. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5112. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5113. */
  5114. static AddTagsTo(obj: any, tagsString: string): void;
  5115. /**
  5116. * @hidden
  5117. */
  5118. static _AddTagTo(obj: any, tag: string): void;
  5119. /**
  5120. * Removes specific tags from a specific object
  5121. * @param obj defines the object to use
  5122. * @param tagsString defines the tags to remove
  5123. */
  5124. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5125. /**
  5126. * @hidden
  5127. */
  5128. static _RemoveTagFrom(obj: any, tag: string): void;
  5129. /**
  5130. * Defines if tags hosted on an object match a given query
  5131. * @param obj defines the object to use
  5132. * @param tagsQuery defines the tag query
  5133. * @returns a boolean
  5134. */
  5135. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5136. }
  5137. }
  5138. declare module "babylonjs/Materials/materialDefines" {
  5139. /**
  5140. * Manages the defines for the Material
  5141. */
  5142. export class MaterialDefines {
  5143. private _keys;
  5144. private _isDirty;
  5145. /** @hidden */
  5146. _renderId: number;
  5147. /** @hidden */
  5148. _areLightsDirty: boolean;
  5149. /** @hidden */
  5150. _areAttributesDirty: boolean;
  5151. /** @hidden */
  5152. _areTexturesDirty: boolean;
  5153. /** @hidden */
  5154. _areFresnelDirty: boolean;
  5155. /** @hidden */
  5156. _areMiscDirty: boolean;
  5157. /** @hidden */
  5158. _areImageProcessingDirty: boolean;
  5159. /** @hidden */
  5160. _normals: boolean;
  5161. /** @hidden */
  5162. _uvs: boolean;
  5163. /** @hidden */
  5164. _needNormals: boolean;
  5165. /** @hidden */
  5166. _needUVs: boolean;
  5167. /**
  5168. * Specifies if the material needs to be re-calculated
  5169. */
  5170. readonly isDirty: boolean;
  5171. /**
  5172. * Marks the material to indicate that it has been re-calculated
  5173. */
  5174. markAsProcessed(): void;
  5175. /**
  5176. * Marks the material to indicate that it needs to be re-calculated
  5177. */
  5178. markAsUnprocessed(): void;
  5179. /**
  5180. * Marks the material to indicate all of its defines need to be re-calculated
  5181. */
  5182. markAllAsDirty(): void;
  5183. /**
  5184. * Marks the material to indicate that image processing needs to be re-calculated
  5185. */
  5186. markAsImageProcessingDirty(): void;
  5187. /**
  5188. * Marks the material to indicate the lights need to be re-calculated
  5189. */
  5190. markAsLightDirty(): void;
  5191. /**
  5192. * Marks the attribute state as changed
  5193. */
  5194. markAsAttributesDirty(): void;
  5195. /**
  5196. * Marks the texture state as changed
  5197. */
  5198. markAsTexturesDirty(): void;
  5199. /**
  5200. * Marks the fresnel state as changed
  5201. */
  5202. markAsFresnelDirty(): void;
  5203. /**
  5204. * Marks the misc state as changed
  5205. */
  5206. markAsMiscDirty(): void;
  5207. /**
  5208. * Rebuilds the material defines
  5209. */
  5210. rebuild(): void;
  5211. /**
  5212. * Specifies if two material defines are equal
  5213. * @param other - A material define instance to compare to
  5214. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  5215. */
  5216. isEqual(other: MaterialDefines): boolean;
  5217. /**
  5218. * Clones this instance's defines to another instance
  5219. * @param other - material defines to clone values to
  5220. */
  5221. cloneTo(other: MaterialDefines): void;
  5222. /**
  5223. * Resets the material define values
  5224. */
  5225. reset(): void;
  5226. /**
  5227. * Converts the material define values to a string
  5228. * @returns - String of material define information
  5229. */
  5230. toString(): string;
  5231. }
  5232. }
  5233. declare module "babylonjs/Engines/IPipelineContext" {
  5234. /**
  5235. * Class used to store and describe the pipeline context associated with an effect
  5236. */
  5237. export interface IPipelineContext {
  5238. /**
  5239. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  5240. */
  5241. isAsync: boolean;
  5242. /**
  5243. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  5244. */
  5245. isReady: boolean;
  5246. /** @hidden */
  5247. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  5248. }
  5249. }
  5250. declare module "babylonjs/Meshes/dataBuffer" {
  5251. /**
  5252. * Class used to store gfx data (like WebGLBuffer)
  5253. */
  5254. export class DataBuffer {
  5255. /**
  5256. * Gets or sets the number of objects referencing this buffer
  5257. */
  5258. references: number;
  5259. /** Gets or sets the size of the underlying buffer */
  5260. capacity: number;
  5261. /**
  5262. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  5263. */
  5264. is32Bits: boolean;
  5265. /**
  5266. * Gets the underlying buffer
  5267. */
  5268. readonly underlyingResource: any;
  5269. }
  5270. }
  5271. declare module "babylonjs/Misc/performanceMonitor" {
  5272. /**
  5273. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  5274. */
  5275. export class PerformanceMonitor {
  5276. private _enabled;
  5277. private _rollingFrameTime;
  5278. private _lastFrameTimeMs;
  5279. /**
  5280. * constructor
  5281. * @param frameSampleSize The number of samples required to saturate the sliding window
  5282. */
  5283. constructor(frameSampleSize?: number);
  5284. /**
  5285. * Samples current frame
  5286. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  5287. */
  5288. sampleFrame(timeMs?: number): void;
  5289. /**
  5290. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5291. */
  5292. readonly averageFrameTime: number;
  5293. /**
  5294. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5295. */
  5296. readonly averageFrameTimeVariance: number;
  5297. /**
  5298. * Returns the frame time of the most recent frame
  5299. */
  5300. readonly instantaneousFrameTime: number;
  5301. /**
  5302. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  5303. */
  5304. readonly averageFPS: number;
  5305. /**
  5306. * Returns the average framerate in frames per second using the most recent frame time
  5307. */
  5308. readonly instantaneousFPS: number;
  5309. /**
  5310. * Returns true if enough samples have been taken to completely fill the sliding window
  5311. */
  5312. readonly isSaturated: boolean;
  5313. /**
  5314. * Enables contributions to the sliding window sample set
  5315. */
  5316. enable(): void;
  5317. /**
  5318. * Disables contributions to the sliding window sample set
  5319. * Samples will not be interpolated over the disabled period
  5320. */
  5321. disable(): void;
  5322. /**
  5323. * Returns true if sampling is enabled
  5324. */
  5325. readonly isEnabled: boolean;
  5326. /**
  5327. * Resets performance monitor
  5328. */
  5329. reset(): void;
  5330. }
  5331. /**
  5332. * RollingAverage
  5333. *
  5334. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  5335. */
  5336. export class RollingAverage {
  5337. /**
  5338. * Current average
  5339. */
  5340. average: number;
  5341. /**
  5342. * Current variance
  5343. */
  5344. variance: number;
  5345. protected _samples: Array<number>;
  5346. protected _sampleCount: number;
  5347. protected _pos: number;
  5348. protected _m2: number;
  5349. /**
  5350. * constructor
  5351. * @param length The number of samples required to saturate the sliding window
  5352. */
  5353. constructor(length: number);
  5354. /**
  5355. * Adds a sample to the sample set
  5356. * @param v The sample value
  5357. */
  5358. add(v: number): void;
  5359. /**
  5360. * Returns previously added values or null if outside of history or outside the sliding window domain
  5361. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  5362. * @return Value previously recorded with add() or null if outside of range
  5363. */
  5364. history(i: number): number;
  5365. /**
  5366. * Returns true if enough samples have been taken to completely fill the sliding window
  5367. * @return true if sample-set saturated
  5368. */
  5369. isSaturated(): boolean;
  5370. /**
  5371. * Resets the rolling average (equivalent to 0 samples taken so far)
  5372. */
  5373. reset(): void;
  5374. /**
  5375. * Wraps a value around the sample range boundaries
  5376. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  5377. * @return Wrapped position in sample range
  5378. */
  5379. protected _wrapPosition(i: number): number;
  5380. }
  5381. }
  5382. declare module "babylonjs/Misc/stringDictionary" {
  5383. import { Nullable } from "babylonjs/types";
  5384. /**
  5385. * This class implement a typical dictionary using a string as key and the generic type T as value.
  5386. * The underlying implementation relies on an associative array to ensure the best performances.
  5387. * The value can be anything including 'null' but except 'undefined'
  5388. */
  5389. export class StringDictionary<T> {
  5390. /**
  5391. * This will clear this dictionary and copy the content from the 'source' one.
  5392. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  5393. * @param source the dictionary to take the content from and copy to this dictionary
  5394. */
  5395. copyFrom(source: StringDictionary<T>): void;
  5396. /**
  5397. * Get a value based from its key
  5398. * @param key the given key to get the matching value from
  5399. * @return the value if found, otherwise undefined is returned
  5400. */
  5401. get(key: string): T | undefined;
  5402. /**
  5403. * Get a value from its key or add it if it doesn't exist.
  5404. * This method will ensure you that a given key/data will be present in the dictionary.
  5405. * @param key the given key to get the matching value from
  5406. * @param factory the factory that will create the value if the key is not present in the dictionary.
  5407. * The factory will only be invoked if there's no data for the given key.
  5408. * @return the value corresponding to the key.
  5409. */
  5410. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  5411. /**
  5412. * Get a value from its key if present in the dictionary otherwise add it
  5413. * @param key the key to get the value from
  5414. * @param val if there's no such key/value pair in the dictionary add it with this value
  5415. * @return the value corresponding to the key
  5416. */
  5417. getOrAdd(key: string, val: T): T;
  5418. /**
  5419. * Check if there's a given key in the dictionary
  5420. * @param key the key to check for
  5421. * @return true if the key is present, false otherwise
  5422. */
  5423. contains(key: string): boolean;
  5424. /**
  5425. * Add a new key and its corresponding value
  5426. * @param key the key to add
  5427. * @param value the value corresponding to the key
  5428. * @return true if the operation completed successfully, false if we couldn't insert the key/value because there was already this key in the dictionary
  5429. */
  5430. add(key: string, value: T): boolean;
  5431. /**
  5432. * Update a specific value associated to a key
  5433. * @param key defines the key to use
  5434. * @param value defines the value to store
  5435. * @returns true if the value was updated (or false if the key was not found)
  5436. */
  5437. set(key: string, value: T): boolean;
  5438. /**
  5439. * Get the element of the given key and remove it from the dictionary
  5440. * @param key defines the key to search
  5441. * @returns the value associated with the key or null if not found
  5442. */
  5443. getAndRemove(key: string): Nullable<T>;
  5444. /**
  5445. * Remove a key/value from the dictionary.
  5446. * @param key the key to remove
  5447. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  5448. */
  5449. remove(key: string): boolean;
  5450. /**
  5451. * Clear the whole content of the dictionary
  5452. */
  5453. clear(): void;
  5454. /**
  5455. * Gets the current count
  5456. */
  5457. readonly count: number;
  5458. /**
  5459. * Execute a callback on each key/val of the dictionary.
  5460. * Note that you can remove any element in this dictionary in the callback implementation
  5461. * @param callback the callback to execute on a given key/value pair
  5462. */
  5463. forEach(callback: (key: string, val: T) => void): void;
  5464. /**
  5465. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  5466. * If the callback returns null or undefined the method will iterate to the next key/value pair
  5467. * Note that you can remove any element in this dictionary in the callback implementation
  5468. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  5469. * @returns the first item
  5470. */
  5471. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  5472. private _count;
  5473. private _data;
  5474. }
  5475. }
  5476. declare module "babylonjs/Misc/promise" {
  5477. /**
  5478. * Helper class that provides a small promise polyfill
  5479. */
  5480. export class PromisePolyfill {
  5481. /**
  5482. * Static function used to check if the polyfill is required
  5483. * If this is the case then the function will inject the polyfill to window.Promise
  5484. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  5485. */
  5486. static Apply(force?: boolean): void;
  5487. }
  5488. }
  5489. declare module "babylonjs/Meshes/buffer" {
  5490. import { Nullable, DataArray } from "babylonjs/types";
  5491. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  5492. /**
  5493. * Class used to store data that will be store in GPU memory
  5494. */
  5495. export class Buffer {
  5496. private _engine;
  5497. private _buffer;
  5498. /** @hidden */
  5499. _data: Nullable<DataArray>;
  5500. private _updatable;
  5501. private _instanced;
  5502. /**
  5503. * Gets the byte stride.
  5504. */
  5505. readonly byteStride: number;
  5506. /**
  5507. * Constructor
  5508. * @param engine the engine
  5509. * @param data the data to use for this buffer
  5510. * @param updatable whether the data is updatable
  5511. * @param stride the stride (optional)
  5512. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5513. * @param instanced whether the buffer is instanced (optional)
  5514. * @param useBytes set to true if the stride in in bytes (optional)
  5515. */
  5516. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  5517. /**
  5518. * Create a new VertexBuffer based on the current buffer
  5519. * @param kind defines the vertex buffer kind (position, normal, etc.)
  5520. * @param offset defines offset in the buffer (0 by default)
  5521. * @param size defines the size in floats of attributes (position is 3 for instance)
  5522. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  5523. * @param instanced defines if the vertex buffer contains indexed data
  5524. * @param useBytes defines if the offset and stride are in bytes
  5525. * @returns the new vertex buffer
  5526. */
  5527. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  5528. /**
  5529. * Gets a boolean indicating if the Buffer is updatable?
  5530. * @returns true if the buffer is updatable
  5531. */
  5532. isUpdatable(): boolean;
  5533. /**
  5534. * Gets current buffer's data
  5535. * @returns a DataArray or null
  5536. */
  5537. getData(): Nullable<DataArray>;
  5538. /**
  5539. * Gets underlying native buffer
  5540. * @returns underlying native buffer
  5541. */
  5542. getBuffer(): Nullable<DataBuffer>;
  5543. /**
  5544. * Gets the stride in float32 units (i.e. byte stride / 4).
  5545. * May not be an integer if the byte stride is not divisible by 4.
  5546. * DEPRECATED. Use byteStride instead.
  5547. * @returns the stride in float32 units
  5548. */
  5549. getStrideSize(): number;
  5550. /**
  5551. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5552. * @param data defines the data to store
  5553. */
  5554. create(data?: Nullable<DataArray>): void;
  5555. /** @hidden */
  5556. _rebuild(): void;
  5557. /**
  5558. * Update current buffer data
  5559. * @param data defines the data to store
  5560. */
  5561. update(data: DataArray): void;
  5562. /**
  5563. * Updates the data directly.
  5564. * @param data the new data
  5565. * @param offset the new offset
  5566. * @param vertexCount the vertex count (optional)
  5567. * @param useBytes set to true if the offset is in bytes
  5568. */
  5569. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  5570. /**
  5571. * Release all resources
  5572. */
  5573. dispose(): void;
  5574. }
  5575. /**
  5576. * Specialized buffer used to store vertex data
  5577. */
  5578. export class VertexBuffer {
  5579. /** @hidden */
  5580. _buffer: Buffer;
  5581. private _kind;
  5582. private _size;
  5583. private _ownsBuffer;
  5584. private _instanced;
  5585. private _instanceDivisor;
  5586. /**
  5587. * The byte type.
  5588. */
  5589. static readonly BYTE: number;
  5590. /**
  5591. * The unsigned byte type.
  5592. */
  5593. static readonly UNSIGNED_BYTE: number;
  5594. /**
  5595. * The short type.
  5596. */
  5597. static readonly SHORT: number;
  5598. /**
  5599. * The unsigned short type.
  5600. */
  5601. static readonly UNSIGNED_SHORT: number;
  5602. /**
  5603. * The integer type.
  5604. */
  5605. static readonly INT: number;
  5606. /**
  5607. * The unsigned integer type.
  5608. */
  5609. static readonly UNSIGNED_INT: number;
  5610. /**
  5611. * The float type.
  5612. */
  5613. static readonly FLOAT: number;
  5614. /**
  5615. * Gets or sets the instance divisor when in instanced mode
  5616. */
  5617. instanceDivisor: number;
  5618. /**
  5619. * Gets the byte stride.
  5620. */
  5621. readonly byteStride: number;
  5622. /**
  5623. * Gets the byte offset.
  5624. */
  5625. readonly byteOffset: number;
  5626. /**
  5627. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  5628. */
  5629. readonly normalized: boolean;
  5630. /**
  5631. * Gets the data type of each component in the array.
  5632. */
  5633. readonly type: number;
  5634. /**
  5635. * Constructor
  5636. * @param engine the engine
  5637. * @param data the data to use for this vertex buffer
  5638. * @param kind the vertex buffer kind
  5639. * @param updatable whether the data is updatable
  5640. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5641. * @param stride the stride (optional)
  5642. * @param instanced whether the buffer is instanced (optional)
  5643. * @param offset the offset of the data (optional)
  5644. * @param size the number of components (optional)
  5645. * @param type the type of the component (optional)
  5646. * @param normalized whether the data contains normalized data (optional)
  5647. * @param useBytes set to true if stride and offset are in bytes (optional)
  5648. */
  5649. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean);
  5650. /** @hidden */
  5651. _rebuild(): void;
  5652. /**
  5653. * Returns the kind of the VertexBuffer (string)
  5654. * @returns a string
  5655. */
  5656. getKind(): string;
  5657. /**
  5658. * Gets a boolean indicating if the VertexBuffer is updatable?
  5659. * @returns true if the buffer is updatable
  5660. */
  5661. isUpdatable(): boolean;
  5662. /**
  5663. * Gets current buffer's data
  5664. * @returns a DataArray or null
  5665. */
  5666. getData(): Nullable<DataArray>;
  5667. /**
  5668. * Gets underlying native buffer
  5669. * @returns underlying native buffer
  5670. */
  5671. getBuffer(): Nullable<DataBuffer>;
  5672. /**
  5673. * Gets the stride in float32 units (i.e. byte stride / 4).
  5674. * May not be an integer if the byte stride is not divisible by 4.
  5675. * DEPRECATED. Use byteStride instead.
  5676. * @returns the stride in float32 units
  5677. */
  5678. getStrideSize(): number;
  5679. /**
  5680. * Returns the offset as a multiple of the type byte length.
  5681. * DEPRECATED. Use byteOffset instead.
  5682. * @returns the offset in bytes
  5683. */
  5684. getOffset(): number;
  5685. /**
  5686. * Returns the number of components per vertex attribute (integer)
  5687. * @returns the size in float
  5688. */
  5689. getSize(): number;
  5690. /**
  5691. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  5692. * @returns true if this buffer is instanced
  5693. */
  5694. getIsInstanced(): boolean;
  5695. /**
  5696. * Returns the instancing divisor, zero for non-instanced (integer).
  5697. * @returns a number
  5698. */
  5699. getInstanceDivisor(): number;
  5700. /**
  5701. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5702. * @param data defines the data to store
  5703. */
  5704. create(data?: DataArray): void;
  5705. /**
  5706. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  5707. * This function will create a new buffer if the current one is not updatable
  5708. * @param data defines the data to store
  5709. */
  5710. update(data: DataArray): void;
  5711. /**
  5712. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  5713. * Returns the directly updated WebGLBuffer.
  5714. * @param data the new data
  5715. * @param offset the new offset
  5716. * @param useBytes set to true if the offset is in bytes
  5717. */
  5718. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  5719. /**
  5720. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  5721. */
  5722. dispose(): void;
  5723. /**
  5724. * Enumerates each value of this vertex buffer as numbers.
  5725. * @param count the number of values to enumerate
  5726. * @param callback the callback function called for each value
  5727. */
  5728. forEach(count: number, callback: (value: number, index: number) => void): void;
  5729. /**
  5730. * Positions
  5731. */
  5732. static readonly PositionKind: string;
  5733. /**
  5734. * Normals
  5735. */
  5736. static readonly NormalKind: string;
  5737. /**
  5738. * Tangents
  5739. */
  5740. static readonly TangentKind: string;
  5741. /**
  5742. * Texture coordinates
  5743. */
  5744. static readonly UVKind: string;
  5745. /**
  5746. * Texture coordinates 2
  5747. */
  5748. static readonly UV2Kind: string;
  5749. /**
  5750. * Texture coordinates 3
  5751. */
  5752. static readonly UV3Kind: string;
  5753. /**
  5754. * Texture coordinates 4
  5755. */
  5756. static readonly UV4Kind: string;
  5757. /**
  5758. * Texture coordinates 5
  5759. */
  5760. static readonly UV5Kind: string;
  5761. /**
  5762. * Texture coordinates 6
  5763. */
  5764. static readonly UV6Kind: string;
  5765. /**
  5766. * Colors
  5767. */
  5768. static readonly ColorKind: string;
  5769. /**
  5770. * Matrix indices (for bones)
  5771. */
  5772. static readonly MatricesIndicesKind: string;
  5773. /**
  5774. * Matrix weights (for bones)
  5775. */
  5776. static readonly MatricesWeightsKind: string;
  5777. /**
  5778. * Additional matrix indices (for bones)
  5779. */
  5780. static readonly MatricesIndicesExtraKind: string;
  5781. /**
  5782. * Additional matrix weights (for bones)
  5783. */
  5784. static readonly MatricesWeightsExtraKind: string;
  5785. /**
  5786. * Deduces the stride given a kind.
  5787. * @param kind The kind string to deduce
  5788. * @returns The deduced stride
  5789. */
  5790. static DeduceStride(kind: string): number;
  5791. /**
  5792. * Gets the byte length of the given type.
  5793. * @param type the type
  5794. * @returns the number of bytes
  5795. */
  5796. static GetTypeByteLength(type: number): number;
  5797. /**
  5798. * Enumerates each value of the given parameters as numbers.
  5799. * @param data the data to enumerate
  5800. * @param byteOffset the byte offset of the data
  5801. * @param byteStride the byte stride of the data
  5802. * @param componentCount the number of components per element
  5803. * @param componentType the type of the component
  5804. * @param count the total number of components
  5805. * @param normalized whether the data is normalized
  5806. * @param callback the callback function called for each value
  5807. */
  5808. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  5809. private static _GetFloatValue;
  5810. }
  5811. }
  5812. declare module "babylonjs/Maths/sphericalPolynomial" {
  5813. import { Vector3, Color3 } from "babylonjs/Maths/math";
  5814. /**
  5815. * Class representing spherical harmonics coefficients to the 3rd degree
  5816. */
  5817. export class SphericalHarmonics {
  5818. /**
  5819. * Defines whether or not the harmonics have been prescaled for rendering.
  5820. */
  5821. preScaled: boolean;
  5822. /**
  5823. * The l0,0 coefficients of the spherical harmonics
  5824. */
  5825. l00: Vector3;
  5826. /**
  5827. * The l1,-1 coefficients of the spherical harmonics
  5828. */
  5829. l1_1: Vector3;
  5830. /**
  5831. * The l1,0 coefficients of the spherical harmonics
  5832. */
  5833. l10: Vector3;
  5834. /**
  5835. * The l1,1 coefficients of the spherical harmonics
  5836. */
  5837. l11: Vector3;
  5838. /**
  5839. * The l2,-2 coefficients of the spherical harmonics
  5840. */
  5841. l2_2: Vector3;
  5842. /**
  5843. * The l2,-1 coefficients of the spherical harmonics
  5844. */
  5845. l2_1: Vector3;
  5846. /**
  5847. * The l2,0 coefficients of the spherical harmonics
  5848. */
  5849. l20: Vector3;
  5850. /**
  5851. * The l2,1 coefficients of the spherical harmonics
  5852. */
  5853. l21: Vector3;
  5854. /**
  5855. * The l2,2 coefficients of the spherical harmonics
  5856. */
  5857. l22: Vector3;
  5858. /**
  5859. * Adds a light to the spherical harmonics
  5860. * @param direction the direction of the light
  5861. * @param color the color of the light
  5862. * @param deltaSolidAngle the delta solid angle of the light
  5863. */
  5864. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5865. /**
  5866. * Scales the spherical harmonics by the given amount
  5867. * @param scale the amount to scale
  5868. */
  5869. scaleInPlace(scale: number): void;
  5870. /**
  5871. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5872. *
  5873. * ```
  5874. * E_lm = A_l * L_lm
  5875. * ```
  5876. *
  5877. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5878. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5879. * the scaling factors are given in equation 9.
  5880. */
  5881. convertIncidentRadianceToIrradiance(): void;
  5882. /**
  5883. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5884. *
  5885. * ```
  5886. * L = (1/pi) * E * rho
  5887. * ```
  5888. *
  5889. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5890. */
  5891. convertIrradianceToLambertianRadiance(): void;
  5892. /**
  5893. * Integrates the reconstruction coefficients directly in to the SH preventing further
  5894. * required operations at run time.
  5895. *
  5896. * This is simply done by scaling back the SH with Ylm constants parameter.
  5897. * The trigonometric part being applied by the shader at run time.
  5898. */
  5899. preScaleForRendering(): void;
  5900. /**
  5901. * Constructs a spherical harmonics from an array.
  5902. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5903. * @returns the spherical harmonics
  5904. */
  5905. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5906. /**
  5907. * Gets the spherical harmonics from polynomial
  5908. * @param polynomial the spherical polynomial
  5909. * @returns the spherical harmonics
  5910. */
  5911. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5912. }
  5913. /**
  5914. * Class representing spherical polynomial coefficients to the 3rd degree
  5915. */
  5916. export class SphericalPolynomial {
  5917. private _harmonics;
  5918. /**
  5919. * The spherical harmonics used to create the polynomials.
  5920. */
  5921. readonly preScaledHarmonics: SphericalHarmonics;
  5922. /**
  5923. * The x coefficients of the spherical polynomial
  5924. */
  5925. x: Vector3;
  5926. /**
  5927. * The y coefficients of the spherical polynomial
  5928. */
  5929. y: Vector3;
  5930. /**
  5931. * The z coefficients of the spherical polynomial
  5932. */
  5933. z: Vector3;
  5934. /**
  5935. * The xx coefficients of the spherical polynomial
  5936. */
  5937. xx: Vector3;
  5938. /**
  5939. * The yy coefficients of the spherical polynomial
  5940. */
  5941. yy: Vector3;
  5942. /**
  5943. * The zz coefficients of the spherical polynomial
  5944. */
  5945. zz: Vector3;
  5946. /**
  5947. * The xy coefficients of the spherical polynomial
  5948. */
  5949. xy: Vector3;
  5950. /**
  5951. * The yz coefficients of the spherical polynomial
  5952. */
  5953. yz: Vector3;
  5954. /**
  5955. * The zx coefficients of the spherical polynomial
  5956. */
  5957. zx: Vector3;
  5958. /**
  5959. * Adds an ambient color to the spherical polynomial
  5960. * @param color the color to add
  5961. */
  5962. addAmbient(color: Color3): void;
  5963. /**
  5964. * Scales the spherical polynomial by the given amount
  5965. * @param scale the amount to scale
  5966. */
  5967. scaleInPlace(scale: number): void;
  5968. /**
  5969. * Gets the spherical polynomial from harmonics
  5970. * @param harmonics the spherical harmonics
  5971. * @returns the spherical polynomial
  5972. */
  5973. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5974. /**
  5975. * Constructs a spherical polynomial from an array.
  5976. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5977. * @returns the spherical polynomial
  5978. */
  5979. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5980. }
  5981. }
  5982. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  5983. import { Nullable } from "babylonjs/types";
  5984. /**
  5985. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  5986. */
  5987. export interface CubeMapInfo {
  5988. /**
  5989. * The pixel array for the front face.
  5990. * This is stored in format, left to right, up to down format.
  5991. */
  5992. front: Nullable<ArrayBufferView>;
  5993. /**
  5994. * The pixel array for the back face.
  5995. * This is stored in format, left to right, up to down format.
  5996. */
  5997. back: Nullable<ArrayBufferView>;
  5998. /**
  5999. * The pixel array for the left face.
  6000. * This is stored in format, left to right, up to down format.
  6001. */
  6002. left: Nullable<ArrayBufferView>;
  6003. /**
  6004. * The pixel array for the right face.
  6005. * This is stored in format, left to right, up to down format.
  6006. */
  6007. right: Nullable<ArrayBufferView>;
  6008. /**
  6009. * The pixel array for the up face.
  6010. * This is stored in format, left to right, up to down format.
  6011. */
  6012. up: Nullable<ArrayBufferView>;
  6013. /**
  6014. * The pixel array for the down face.
  6015. * This is stored in format, left to right, up to down format.
  6016. */
  6017. down: Nullable<ArrayBufferView>;
  6018. /**
  6019. * The size of the cubemap stored.
  6020. *
  6021. * Each faces will be size * size pixels.
  6022. */
  6023. size: number;
  6024. /**
  6025. * The format of the texture.
  6026. *
  6027. * RGBA, RGB.
  6028. */
  6029. format: number;
  6030. /**
  6031. * The type of the texture data.
  6032. *
  6033. * UNSIGNED_INT, FLOAT.
  6034. */
  6035. type: number;
  6036. /**
  6037. * Specifies whether the texture is in gamma space.
  6038. */
  6039. gammaSpace: boolean;
  6040. }
  6041. /**
  6042. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  6043. */
  6044. export class PanoramaToCubeMapTools {
  6045. private static FACE_FRONT;
  6046. private static FACE_BACK;
  6047. private static FACE_RIGHT;
  6048. private static FACE_LEFT;
  6049. private static FACE_DOWN;
  6050. private static FACE_UP;
  6051. /**
  6052. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  6053. *
  6054. * @param float32Array The source data.
  6055. * @param inputWidth The width of the input panorama.
  6056. * @param inputHeight The height of the input panorama.
  6057. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  6058. * @return The cubemap data
  6059. */
  6060. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  6061. private static CreateCubemapTexture;
  6062. private static CalcProjectionSpherical;
  6063. }
  6064. }
  6065. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  6066. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  6067. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  6068. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  6069. /**
  6070. * Helper class dealing with the extraction of spherical polynomial dataArray
  6071. * from a cube map.
  6072. */
  6073. export class CubeMapToSphericalPolynomialTools {
  6074. private static FileFaces;
  6075. /**
  6076. * Converts a texture to the according Spherical Polynomial data.
  6077. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6078. *
  6079. * @param texture The texture to extract the information from.
  6080. * @return The Spherical Polynomial data.
  6081. */
  6082. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  6083. /**
  6084. * Converts a cubemap to the according Spherical Polynomial data.
  6085. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6086. *
  6087. * @param cubeInfo The Cube map to extract the information from.
  6088. * @return The Spherical Polynomial data.
  6089. */
  6090. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  6091. }
  6092. }
  6093. declare module "babylonjs/Engines/engineStore" {
  6094. import { Nullable } from "babylonjs/types";
  6095. import { Engine } from "babylonjs/Engines/engine";
  6096. import { Scene } from "babylonjs/scene";
  6097. /**
  6098. * The engine store class is responsible to hold all the instances of Engine and Scene created
  6099. * during the life time of the application.
  6100. */
  6101. export class EngineStore {
  6102. /** Gets the list of created engines */
  6103. static Instances: import("babylonjs/Engines/engine").Engine[];
  6104. /** @hidden */
  6105. static _LastCreatedScene: Nullable<Scene>;
  6106. /**
  6107. * Gets the latest created engine
  6108. */
  6109. static readonly LastCreatedEngine: Nullable<Engine>;
  6110. /**
  6111. * Gets the latest created scene
  6112. */
  6113. static readonly LastCreatedScene: Nullable<Scene>;
  6114. }
  6115. }
  6116. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  6117. /**
  6118. * Define options used to create a render target texture
  6119. */
  6120. export class RenderTargetCreationOptions {
  6121. /**
  6122. * Specifies is mipmaps must be generated
  6123. */
  6124. generateMipMaps?: boolean;
  6125. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  6126. generateDepthBuffer?: boolean;
  6127. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  6128. generateStencilBuffer?: boolean;
  6129. /** Defines texture type (int by default) */
  6130. type?: number;
  6131. /** Defines sampling mode (trilinear by default) */
  6132. samplingMode?: number;
  6133. /** Defines format (RGBA by default) */
  6134. format?: number;
  6135. }
  6136. }
  6137. declare module "babylonjs/States/alphaCullingState" {
  6138. /**
  6139. * @hidden
  6140. **/
  6141. export class _AlphaState {
  6142. private _isAlphaBlendDirty;
  6143. private _isBlendFunctionParametersDirty;
  6144. private _isBlendEquationParametersDirty;
  6145. private _isBlendConstantsDirty;
  6146. private _alphaBlend;
  6147. private _blendFunctionParameters;
  6148. private _blendEquationParameters;
  6149. private _blendConstants;
  6150. /**
  6151. * Initializes the state.
  6152. */
  6153. constructor();
  6154. readonly isDirty: boolean;
  6155. alphaBlend: boolean;
  6156. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  6157. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  6158. setAlphaEquationParameters(rgb: number, alpha: number): void;
  6159. reset(): void;
  6160. apply(gl: WebGLRenderingContext): void;
  6161. }
  6162. }
  6163. declare module "babylonjs/States/depthCullingState" {
  6164. import { Nullable } from "babylonjs/types";
  6165. /**
  6166. * @hidden
  6167. **/
  6168. export class _DepthCullingState {
  6169. private _isDepthTestDirty;
  6170. private _isDepthMaskDirty;
  6171. private _isDepthFuncDirty;
  6172. private _isCullFaceDirty;
  6173. private _isCullDirty;
  6174. private _isZOffsetDirty;
  6175. private _isFrontFaceDirty;
  6176. private _depthTest;
  6177. private _depthMask;
  6178. private _depthFunc;
  6179. private _cull;
  6180. private _cullFace;
  6181. private _zOffset;
  6182. private _frontFace;
  6183. /**
  6184. * Initializes the state.
  6185. */
  6186. constructor();
  6187. readonly isDirty: boolean;
  6188. zOffset: number;
  6189. cullFace: Nullable<number>;
  6190. cull: Nullable<boolean>;
  6191. depthFunc: Nullable<number>;
  6192. depthMask: boolean;
  6193. depthTest: boolean;
  6194. frontFace: Nullable<number>;
  6195. reset(): void;
  6196. apply(gl: WebGLRenderingContext): void;
  6197. }
  6198. }
  6199. declare module "babylonjs/States/stencilState" {
  6200. /**
  6201. * @hidden
  6202. **/
  6203. export class _StencilState {
  6204. /** 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 */
  6205. static readonly ALWAYS: number;
  6206. /** Passed to stencilOperation to specify that stencil value must be kept */
  6207. static readonly KEEP: number;
  6208. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6209. static readonly REPLACE: number;
  6210. private _isStencilTestDirty;
  6211. private _isStencilMaskDirty;
  6212. private _isStencilFuncDirty;
  6213. private _isStencilOpDirty;
  6214. private _stencilTest;
  6215. private _stencilMask;
  6216. private _stencilFunc;
  6217. private _stencilFuncRef;
  6218. private _stencilFuncMask;
  6219. private _stencilOpStencilFail;
  6220. private _stencilOpDepthFail;
  6221. private _stencilOpStencilDepthPass;
  6222. readonly isDirty: boolean;
  6223. stencilFunc: number;
  6224. stencilFuncRef: number;
  6225. stencilFuncMask: number;
  6226. stencilOpStencilFail: number;
  6227. stencilOpDepthFail: number;
  6228. stencilOpStencilDepthPass: number;
  6229. stencilMask: number;
  6230. stencilTest: boolean;
  6231. constructor();
  6232. reset(): void;
  6233. apply(gl: WebGLRenderingContext): void;
  6234. }
  6235. }
  6236. declare module "babylonjs/States/index" {
  6237. export * from "babylonjs/States/alphaCullingState";
  6238. export * from "babylonjs/States/depthCullingState";
  6239. export * from "babylonjs/States/stencilState";
  6240. }
  6241. declare module "babylonjs/Instrumentation/timeToken" {
  6242. import { Nullable } from "babylonjs/types";
  6243. /**
  6244. * @hidden
  6245. **/
  6246. export class _TimeToken {
  6247. _startTimeQuery: Nullable<WebGLQuery>;
  6248. _endTimeQuery: Nullable<WebGLQuery>;
  6249. _timeElapsedQuery: Nullable<WebGLQuery>;
  6250. _timeElapsedQueryEnded: boolean;
  6251. }
  6252. }
  6253. declare module "babylonjs/Materials/Textures/internalTexture" {
  6254. import { Observable } from "babylonjs/Misc/observable";
  6255. import { Nullable, int } from "babylonjs/types";
  6256. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  6257. import { Engine } from "babylonjs/Engines/engine";
  6258. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  6259. /**
  6260. * Class used to store data associated with WebGL texture data for the engine
  6261. * This class should not be used directly
  6262. */
  6263. export class InternalTexture {
  6264. /** hidden */
  6265. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  6266. /**
  6267. * The source of the texture data is unknown
  6268. */
  6269. static DATASOURCE_UNKNOWN: number;
  6270. /**
  6271. * Texture data comes from an URL
  6272. */
  6273. static DATASOURCE_URL: number;
  6274. /**
  6275. * Texture data is only used for temporary storage
  6276. */
  6277. static DATASOURCE_TEMP: number;
  6278. /**
  6279. * Texture data comes from raw data (ArrayBuffer)
  6280. */
  6281. static DATASOURCE_RAW: number;
  6282. /**
  6283. * Texture content is dynamic (video or dynamic texture)
  6284. */
  6285. static DATASOURCE_DYNAMIC: number;
  6286. /**
  6287. * Texture content is generated by rendering to it
  6288. */
  6289. static DATASOURCE_RENDERTARGET: number;
  6290. /**
  6291. * Texture content is part of a multi render target process
  6292. */
  6293. static DATASOURCE_MULTIRENDERTARGET: number;
  6294. /**
  6295. * Texture data comes from a cube data file
  6296. */
  6297. static DATASOURCE_CUBE: number;
  6298. /**
  6299. * Texture data comes from a raw cube data
  6300. */
  6301. static DATASOURCE_CUBERAW: number;
  6302. /**
  6303. * Texture data come from a prefiltered cube data file
  6304. */
  6305. static DATASOURCE_CUBEPREFILTERED: number;
  6306. /**
  6307. * Texture content is raw 3D data
  6308. */
  6309. static DATASOURCE_RAW3D: number;
  6310. /**
  6311. * Texture content is a depth texture
  6312. */
  6313. static DATASOURCE_DEPTHTEXTURE: number;
  6314. /**
  6315. * Texture data comes from a raw cube data encoded with RGBD
  6316. */
  6317. static DATASOURCE_CUBERAW_RGBD: number;
  6318. /**
  6319. * Defines if the texture is ready
  6320. */
  6321. isReady: boolean;
  6322. /**
  6323. * Defines if the texture is a cube texture
  6324. */
  6325. isCube: boolean;
  6326. /**
  6327. * Defines if the texture contains 3D data
  6328. */
  6329. is3D: boolean;
  6330. /**
  6331. * Defines if the texture contains multiview data
  6332. */
  6333. isMultiview: boolean;
  6334. /**
  6335. * Gets the URL used to load this texture
  6336. */
  6337. url: string;
  6338. /**
  6339. * Gets the sampling mode of the texture
  6340. */
  6341. samplingMode: number;
  6342. /**
  6343. * Gets a boolean indicating if the texture needs mipmaps generation
  6344. */
  6345. generateMipMaps: boolean;
  6346. /**
  6347. * Gets the number of samples used by the texture (WebGL2+ only)
  6348. */
  6349. samples: number;
  6350. /**
  6351. * Gets the type of the texture (int, float...)
  6352. */
  6353. type: number;
  6354. /**
  6355. * Gets the format of the texture (RGB, RGBA...)
  6356. */
  6357. format: number;
  6358. /**
  6359. * Observable called when the texture is loaded
  6360. */
  6361. onLoadedObservable: Observable<InternalTexture>;
  6362. /**
  6363. * Gets the width of the texture
  6364. */
  6365. width: number;
  6366. /**
  6367. * Gets the height of the texture
  6368. */
  6369. height: number;
  6370. /**
  6371. * Gets the depth of the texture
  6372. */
  6373. depth: number;
  6374. /**
  6375. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  6376. */
  6377. baseWidth: number;
  6378. /**
  6379. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  6380. */
  6381. baseHeight: number;
  6382. /**
  6383. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  6384. */
  6385. baseDepth: number;
  6386. /**
  6387. * Gets a boolean indicating if the texture is inverted on Y axis
  6388. */
  6389. invertY: boolean;
  6390. /** @hidden */
  6391. _invertVScale: boolean;
  6392. /** @hidden */
  6393. _associatedChannel: number;
  6394. /** @hidden */
  6395. _dataSource: number;
  6396. /** @hidden */
  6397. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  6398. /** @hidden */
  6399. _bufferView: Nullable<ArrayBufferView>;
  6400. /** @hidden */
  6401. _bufferViewArray: Nullable<ArrayBufferView[]>;
  6402. /** @hidden */
  6403. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  6404. /** @hidden */
  6405. _size: number;
  6406. /** @hidden */
  6407. _extension: string;
  6408. /** @hidden */
  6409. _files: Nullable<string[]>;
  6410. /** @hidden */
  6411. _workingCanvas: Nullable<HTMLCanvasElement>;
  6412. /** @hidden */
  6413. _workingContext: Nullable<CanvasRenderingContext2D>;
  6414. /** @hidden */
  6415. _framebuffer: Nullable<WebGLFramebuffer>;
  6416. /** @hidden */
  6417. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  6418. /** @hidden */
  6419. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  6420. /** @hidden */
  6421. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  6422. /** @hidden */
  6423. _attachments: Nullable<number[]>;
  6424. /** @hidden */
  6425. _cachedCoordinatesMode: Nullable<number>;
  6426. /** @hidden */
  6427. _cachedWrapU: Nullable<number>;
  6428. /** @hidden */
  6429. _cachedWrapV: Nullable<number>;
  6430. /** @hidden */
  6431. _cachedWrapR: Nullable<number>;
  6432. /** @hidden */
  6433. _cachedAnisotropicFilteringLevel: Nullable<number>;
  6434. /** @hidden */
  6435. _isDisabled: boolean;
  6436. /** @hidden */
  6437. _compression: Nullable<string>;
  6438. /** @hidden */
  6439. _generateStencilBuffer: boolean;
  6440. /** @hidden */
  6441. _generateDepthBuffer: boolean;
  6442. /** @hidden */
  6443. _comparisonFunction: number;
  6444. /** @hidden */
  6445. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  6446. /** @hidden */
  6447. _lodGenerationScale: number;
  6448. /** @hidden */
  6449. _lodGenerationOffset: number;
  6450. /** @hidden */
  6451. _colorTextureArray: Nullable<WebGLTexture>;
  6452. /** @hidden */
  6453. _depthStencilTextureArray: Nullable<WebGLTexture>;
  6454. /** @hidden */
  6455. _lodTextureHigh: Nullable<BaseTexture>;
  6456. /** @hidden */
  6457. _lodTextureMid: Nullable<BaseTexture>;
  6458. /** @hidden */
  6459. _lodTextureLow: Nullable<BaseTexture>;
  6460. /** @hidden */
  6461. _isRGBD: boolean;
  6462. /** @hidden */
  6463. _webGLTexture: Nullable<WebGLTexture>;
  6464. /** @hidden */
  6465. _references: number;
  6466. private _engine;
  6467. /**
  6468. * Gets the Engine the texture belongs to.
  6469. * @returns The babylon engine
  6470. */
  6471. getEngine(): Engine;
  6472. /**
  6473. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  6474. */
  6475. readonly dataSource: number;
  6476. /**
  6477. * Creates a new InternalTexture
  6478. * @param engine defines the engine to use
  6479. * @param dataSource defines the type of data that will be used
  6480. * @param delayAllocation if the texture allocation should be delayed (default: false)
  6481. */
  6482. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  6483. /**
  6484. * Increments the number of references (ie. the number of Texture that point to it)
  6485. */
  6486. incrementReferences(): void;
  6487. /**
  6488. * Change the size of the texture (not the size of the content)
  6489. * @param width defines the new width
  6490. * @param height defines the new height
  6491. * @param depth defines the new depth (1 by default)
  6492. */
  6493. updateSize(width: int, height: int, depth?: int): void;
  6494. /** @hidden */
  6495. _rebuild(): void;
  6496. /** @hidden */
  6497. _swapAndDie(target: InternalTexture): void;
  6498. /**
  6499. * Dispose the current allocated resources
  6500. */
  6501. dispose(): void;
  6502. }
  6503. }
  6504. declare module "babylonjs/Animations/easing" {
  6505. /**
  6506. * This represents the main contract an easing function should follow.
  6507. * Easing functions are used throughout the animation system.
  6508. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6509. */
  6510. export interface IEasingFunction {
  6511. /**
  6512. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6513. * of the easing function.
  6514. * The link below provides some of the most common examples of easing functions.
  6515. * @see https://easings.net/
  6516. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6517. * @returns the corresponding value on the curve defined by the easing function
  6518. */
  6519. ease(gradient: number): number;
  6520. }
  6521. /**
  6522. * Base class used for every default easing function.
  6523. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6524. */
  6525. export class EasingFunction implements IEasingFunction {
  6526. /**
  6527. * Interpolation follows the mathematical formula associated with the easing function.
  6528. */
  6529. static readonly EASINGMODE_EASEIN: number;
  6530. /**
  6531. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6532. */
  6533. static readonly EASINGMODE_EASEOUT: number;
  6534. /**
  6535. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6536. */
  6537. static readonly EASINGMODE_EASEINOUT: number;
  6538. private _easingMode;
  6539. /**
  6540. * Sets the easing mode of the current function.
  6541. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6542. */
  6543. setEasingMode(easingMode: number): void;
  6544. /**
  6545. * Gets the current easing mode.
  6546. * @returns the easing mode
  6547. */
  6548. getEasingMode(): number;
  6549. /**
  6550. * @hidden
  6551. */
  6552. easeInCore(gradient: number): number;
  6553. /**
  6554. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6555. * of the easing function.
  6556. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6557. * @returns the corresponding value on the curve defined by the easing function
  6558. */
  6559. ease(gradient: number): number;
  6560. }
  6561. /**
  6562. * Easing function with a circle shape (see link below).
  6563. * @see https://easings.net/#easeInCirc
  6564. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6565. */
  6566. export class CircleEase extends EasingFunction implements IEasingFunction {
  6567. /** @hidden */
  6568. easeInCore(gradient: number): number;
  6569. }
  6570. /**
  6571. * Easing function with a ease back shape (see link below).
  6572. * @see https://easings.net/#easeInBack
  6573. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6574. */
  6575. export class BackEase extends EasingFunction implements IEasingFunction {
  6576. /** Defines the amplitude of the function */
  6577. amplitude: number;
  6578. /**
  6579. * Instantiates a back ease easing
  6580. * @see https://easings.net/#easeInBack
  6581. * @param amplitude Defines the amplitude of the function
  6582. */
  6583. constructor(
  6584. /** Defines the amplitude of the function */
  6585. amplitude?: number);
  6586. /** @hidden */
  6587. easeInCore(gradient: number): number;
  6588. }
  6589. /**
  6590. * Easing function with a bouncing shape (see link below).
  6591. * @see https://easings.net/#easeInBounce
  6592. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6593. */
  6594. export class BounceEase extends EasingFunction implements IEasingFunction {
  6595. /** Defines the number of bounces */
  6596. bounces: number;
  6597. /** Defines the amplitude of the bounce */
  6598. bounciness: number;
  6599. /**
  6600. * Instantiates a bounce easing
  6601. * @see https://easings.net/#easeInBounce
  6602. * @param bounces Defines the number of bounces
  6603. * @param bounciness Defines the amplitude of the bounce
  6604. */
  6605. constructor(
  6606. /** Defines the number of bounces */
  6607. bounces?: number,
  6608. /** Defines the amplitude of the bounce */
  6609. bounciness?: number);
  6610. /** @hidden */
  6611. easeInCore(gradient: number): number;
  6612. }
  6613. /**
  6614. * Easing function with a power of 3 shape (see link below).
  6615. * @see https://easings.net/#easeInCubic
  6616. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6617. */
  6618. export class CubicEase extends EasingFunction implements IEasingFunction {
  6619. /** @hidden */
  6620. easeInCore(gradient: number): number;
  6621. }
  6622. /**
  6623. * Easing function with an elastic shape (see link below).
  6624. * @see https://easings.net/#easeInElastic
  6625. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6626. */
  6627. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6628. /** Defines the number of oscillations*/
  6629. oscillations: number;
  6630. /** Defines the amplitude of the oscillations*/
  6631. springiness: number;
  6632. /**
  6633. * Instantiates an elastic easing function
  6634. * @see https://easings.net/#easeInElastic
  6635. * @param oscillations Defines the number of oscillations
  6636. * @param springiness Defines the amplitude of the oscillations
  6637. */
  6638. constructor(
  6639. /** Defines the number of oscillations*/
  6640. oscillations?: number,
  6641. /** Defines the amplitude of the oscillations*/
  6642. springiness?: number);
  6643. /** @hidden */
  6644. easeInCore(gradient: number): number;
  6645. }
  6646. /**
  6647. * Easing function with an exponential shape (see link below).
  6648. * @see https://easings.net/#easeInExpo
  6649. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6650. */
  6651. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6652. /** Defines the exponent of the function */
  6653. exponent: number;
  6654. /**
  6655. * Instantiates an exponential easing function
  6656. * @see https://easings.net/#easeInExpo
  6657. * @param exponent Defines the exponent of the function
  6658. */
  6659. constructor(
  6660. /** Defines the exponent of the function */
  6661. exponent?: number);
  6662. /** @hidden */
  6663. easeInCore(gradient: number): number;
  6664. }
  6665. /**
  6666. * Easing function with a power shape (see link below).
  6667. * @see https://easings.net/#easeInQuad
  6668. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6669. */
  6670. export class PowerEase extends EasingFunction implements IEasingFunction {
  6671. /** Defines the power of the function */
  6672. power: number;
  6673. /**
  6674. * Instantiates an power base easing function
  6675. * @see https://easings.net/#easeInQuad
  6676. * @param power Defines the power of the function
  6677. */
  6678. constructor(
  6679. /** Defines the power of the function */
  6680. power?: number);
  6681. /** @hidden */
  6682. easeInCore(gradient: number): number;
  6683. }
  6684. /**
  6685. * Easing function with a power of 2 shape (see link below).
  6686. * @see https://easings.net/#easeInQuad
  6687. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6688. */
  6689. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6690. /** @hidden */
  6691. easeInCore(gradient: number): number;
  6692. }
  6693. /**
  6694. * Easing function with a power of 4 shape (see link below).
  6695. * @see https://easings.net/#easeInQuart
  6696. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6697. */
  6698. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6699. /** @hidden */
  6700. easeInCore(gradient: number): number;
  6701. }
  6702. /**
  6703. * Easing function with a power of 5 shape (see link below).
  6704. * @see https://easings.net/#easeInQuint
  6705. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6706. */
  6707. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6708. /** @hidden */
  6709. easeInCore(gradient: number): number;
  6710. }
  6711. /**
  6712. * Easing function with a sin shape (see link below).
  6713. * @see https://easings.net/#easeInSine
  6714. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6715. */
  6716. export class SineEase extends EasingFunction implements IEasingFunction {
  6717. /** @hidden */
  6718. easeInCore(gradient: number): number;
  6719. }
  6720. /**
  6721. * Easing function with a bezier shape (see link below).
  6722. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6723. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6724. */
  6725. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6726. /** Defines the x component of the start tangent in the bezier curve */
  6727. x1: number;
  6728. /** Defines the y component of the start tangent in the bezier curve */
  6729. y1: number;
  6730. /** Defines the x component of the end tangent in the bezier curve */
  6731. x2: number;
  6732. /** Defines the y component of the end tangent in the bezier curve */
  6733. y2: number;
  6734. /**
  6735. * Instantiates a bezier function
  6736. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6737. * @param x1 Defines the x component of the start tangent in the bezier curve
  6738. * @param y1 Defines the y component of the start tangent in the bezier curve
  6739. * @param x2 Defines the x component of the end tangent in the bezier curve
  6740. * @param y2 Defines the y component of the end tangent in the bezier curve
  6741. */
  6742. constructor(
  6743. /** Defines the x component of the start tangent in the bezier curve */
  6744. x1?: number,
  6745. /** Defines the y component of the start tangent in the bezier curve */
  6746. y1?: number,
  6747. /** Defines the x component of the end tangent in the bezier curve */
  6748. x2?: number,
  6749. /** Defines the y component of the end tangent in the bezier curve */
  6750. y2?: number);
  6751. /** @hidden */
  6752. easeInCore(gradient: number): number;
  6753. }
  6754. }
  6755. declare module "babylonjs/Animations/animationKey" {
  6756. /**
  6757. * Defines an interface which represents an animation key frame
  6758. */
  6759. export interface IAnimationKey {
  6760. /**
  6761. * Frame of the key frame
  6762. */
  6763. frame: number;
  6764. /**
  6765. * Value at the specifies key frame
  6766. */
  6767. value: any;
  6768. /**
  6769. * The input tangent for the cubic hermite spline
  6770. */
  6771. inTangent?: any;
  6772. /**
  6773. * The output tangent for the cubic hermite spline
  6774. */
  6775. outTangent?: any;
  6776. /**
  6777. * The animation interpolation type
  6778. */
  6779. interpolation?: AnimationKeyInterpolation;
  6780. }
  6781. /**
  6782. * Enum for the animation key frame interpolation type
  6783. */
  6784. export enum AnimationKeyInterpolation {
  6785. /**
  6786. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6787. */
  6788. STEP = 1
  6789. }
  6790. }
  6791. declare module "babylonjs/Animations/animationRange" {
  6792. /**
  6793. * Represents the range of an animation
  6794. */
  6795. export class AnimationRange {
  6796. /**The name of the animation range**/
  6797. name: string;
  6798. /**The starting frame of the animation */
  6799. from: number;
  6800. /**The ending frame of the animation*/
  6801. to: number;
  6802. /**
  6803. * Initializes the range of an animation
  6804. * @param name The name of the animation range
  6805. * @param from The starting frame of the animation
  6806. * @param to The ending frame of the animation
  6807. */
  6808. constructor(
  6809. /**The name of the animation range**/
  6810. name: string,
  6811. /**The starting frame of the animation */
  6812. from: number,
  6813. /**The ending frame of the animation*/
  6814. to: number);
  6815. /**
  6816. * Makes a copy of the animation range
  6817. * @returns A copy of the animation range
  6818. */
  6819. clone(): AnimationRange;
  6820. }
  6821. }
  6822. declare module "babylonjs/Animations/animationEvent" {
  6823. /**
  6824. * Composed of a frame, and an action function
  6825. */
  6826. export class AnimationEvent {
  6827. /** The frame for which the event is triggered **/
  6828. frame: number;
  6829. /** The event to perform when triggered **/
  6830. action: (currentFrame: number) => void;
  6831. /** Specifies if the event should be triggered only once**/
  6832. onlyOnce?: boolean | undefined;
  6833. /**
  6834. * Specifies if the animation event is done
  6835. */
  6836. isDone: boolean;
  6837. /**
  6838. * Initializes the animation event
  6839. * @param frame The frame for which the event is triggered
  6840. * @param action The event to perform when triggered
  6841. * @param onlyOnce Specifies if the event should be triggered only once
  6842. */
  6843. constructor(
  6844. /** The frame for which the event is triggered **/
  6845. frame: number,
  6846. /** The event to perform when triggered **/
  6847. action: (currentFrame: number) => void,
  6848. /** Specifies if the event should be triggered only once**/
  6849. onlyOnce?: boolean | undefined);
  6850. /** @hidden */
  6851. _clone(): AnimationEvent;
  6852. }
  6853. }
  6854. declare module "babylonjs/Behaviors/behavior" {
  6855. import { Nullable } from "babylonjs/types";
  6856. /**
  6857. * Interface used to define a behavior
  6858. */
  6859. export interface Behavior<T> {
  6860. /** gets or sets behavior's name */
  6861. name: string;
  6862. /**
  6863. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6864. */
  6865. init(): void;
  6866. /**
  6867. * Called when the behavior is attached to a target
  6868. * @param target defines the target where the behavior is attached to
  6869. */
  6870. attach(target: T): void;
  6871. /**
  6872. * Called when the behavior is detached from its target
  6873. */
  6874. detach(): void;
  6875. }
  6876. /**
  6877. * Interface implemented by classes supporting behaviors
  6878. */
  6879. export interface IBehaviorAware<T> {
  6880. /**
  6881. * Attach a behavior
  6882. * @param behavior defines the behavior to attach
  6883. * @returns the current host
  6884. */
  6885. addBehavior(behavior: Behavior<T>): T;
  6886. /**
  6887. * Remove a behavior from the current object
  6888. * @param behavior defines the behavior to detach
  6889. * @returns the current host
  6890. */
  6891. removeBehavior(behavior: Behavior<T>): T;
  6892. /**
  6893. * Gets a behavior using its name to search
  6894. * @param name defines the name to search
  6895. * @returns the behavior or null if not found
  6896. */
  6897. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6898. }
  6899. }
  6900. declare module "babylonjs/Collisions/intersectionInfo" {
  6901. import { Nullable } from "babylonjs/types";
  6902. /**
  6903. * @hidden
  6904. */
  6905. export class IntersectionInfo {
  6906. bu: Nullable<number>;
  6907. bv: Nullable<number>;
  6908. distance: number;
  6909. faceId: number;
  6910. subMeshId: number;
  6911. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6912. }
  6913. }
  6914. declare module "babylonjs/Culling/boundingSphere" {
  6915. import { DeepImmutable } from "babylonjs/types";
  6916. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  6917. /**
  6918. * Class used to store bounding sphere information
  6919. */
  6920. export class BoundingSphere {
  6921. /**
  6922. * Gets the center of the bounding sphere in local space
  6923. */
  6924. readonly center: Vector3;
  6925. /**
  6926. * Radius of the bounding sphere in local space
  6927. */
  6928. radius: number;
  6929. /**
  6930. * Gets the center of the bounding sphere in world space
  6931. */
  6932. readonly centerWorld: Vector3;
  6933. /**
  6934. * Radius of the bounding sphere in world space
  6935. */
  6936. radiusWorld: number;
  6937. /**
  6938. * Gets the minimum vector in local space
  6939. */
  6940. readonly minimum: Vector3;
  6941. /**
  6942. * Gets the maximum vector in local space
  6943. */
  6944. readonly maximum: Vector3;
  6945. private _worldMatrix;
  6946. private static readonly TmpVector3;
  6947. /**
  6948. * Creates a new bounding sphere
  6949. * @param min defines the minimum vector (in local space)
  6950. * @param max defines the maximum vector (in local space)
  6951. * @param worldMatrix defines the new world matrix
  6952. */
  6953. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6954. /**
  6955. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6956. * @param min defines the new minimum vector (in local space)
  6957. * @param max defines the new maximum vector (in local space)
  6958. * @param worldMatrix defines the new world matrix
  6959. */
  6960. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6961. /**
  6962. * Scale the current bounding sphere by applying a scale factor
  6963. * @param factor defines the scale factor to apply
  6964. * @returns the current bounding box
  6965. */
  6966. scale(factor: number): BoundingSphere;
  6967. /**
  6968. * Gets the world matrix of the bounding box
  6969. * @returns a matrix
  6970. */
  6971. getWorldMatrix(): DeepImmutable<Matrix>;
  6972. /** @hidden */
  6973. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6974. /**
  6975. * Tests if the bounding sphere is intersecting the frustum planes
  6976. * @param frustumPlanes defines the frustum planes to test
  6977. * @returns true if there is an intersection
  6978. */
  6979. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6980. /**
  6981. * Tests if the bounding sphere center is in between the frustum planes.
  6982. * Used for optimistic fast inclusion.
  6983. * @param frustumPlanes defines the frustum planes to test
  6984. * @returns true if the sphere center is in between the frustum planes
  6985. */
  6986. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6987. /**
  6988. * Tests if a point is inside the bounding sphere
  6989. * @param point defines the point to test
  6990. * @returns true if the point is inside the bounding sphere
  6991. */
  6992. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6993. /**
  6994. * Checks if two sphere intersct
  6995. * @param sphere0 sphere 0
  6996. * @param sphere1 sphere 1
  6997. * @returns true if the speres intersect
  6998. */
  6999. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  7000. }
  7001. }
  7002. declare module "babylonjs/Culling/boundingBox" {
  7003. import { DeepImmutable } from "babylonjs/types";
  7004. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7005. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7006. import { ICullable } from "babylonjs/Culling/boundingInfo";
  7007. /**
  7008. * Class used to store bounding box information
  7009. */
  7010. export class BoundingBox implements ICullable {
  7011. /**
  7012. * Gets the 8 vectors representing the bounding box in local space
  7013. */
  7014. readonly vectors: Vector3[];
  7015. /**
  7016. * Gets the center of the bounding box in local space
  7017. */
  7018. readonly center: Vector3;
  7019. /**
  7020. * Gets the center of the bounding box in world space
  7021. */
  7022. readonly centerWorld: Vector3;
  7023. /**
  7024. * Gets the extend size in local space
  7025. */
  7026. readonly extendSize: Vector3;
  7027. /**
  7028. * Gets the extend size in world space
  7029. */
  7030. readonly extendSizeWorld: Vector3;
  7031. /**
  7032. * Gets the OBB (object bounding box) directions
  7033. */
  7034. readonly directions: Vector3[];
  7035. /**
  7036. * Gets the 8 vectors representing the bounding box in world space
  7037. */
  7038. readonly vectorsWorld: Vector3[];
  7039. /**
  7040. * Gets the minimum vector in world space
  7041. */
  7042. readonly minimumWorld: Vector3;
  7043. /**
  7044. * Gets the maximum vector in world space
  7045. */
  7046. readonly maximumWorld: Vector3;
  7047. /**
  7048. * Gets the minimum vector in local space
  7049. */
  7050. readonly minimum: Vector3;
  7051. /**
  7052. * Gets the maximum vector in local space
  7053. */
  7054. readonly maximum: Vector3;
  7055. private _worldMatrix;
  7056. private static readonly TmpVector3;
  7057. /**
  7058. * @hidden
  7059. */
  7060. _tag: number;
  7061. /**
  7062. * Creates a new bounding box
  7063. * @param min defines the minimum vector (in local space)
  7064. * @param max defines the maximum vector (in local space)
  7065. * @param worldMatrix defines the new world matrix
  7066. */
  7067. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7068. /**
  7069. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7070. * @param min defines the new minimum vector (in local space)
  7071. * @param max defines the new maximum vector (in local space)
  7072. * @param worldMatrix defines the new world matrix
  7073. */
  7074. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7075. /**
  7076. * Scale the current bounding box by applying a scale factor
  7077. * @param factor defines the scale factor to apply
  7078. * @returns the current bounding box
  7079. */
  7080. scale(factor: number): BoundingBox;
  7081. /**
  7082. * Gets the world matrix of the bounding box
  7083. * @returns a matrix
  7084. */
  7085. getWorldMatrix(): DeepImmutable<Matrix>;
  7086. /** @hidden */
  7087. _update(world: DeepImmutable<Matrix>): void;
  7088. /**
  7089. * Tests if the bounding box is intersecting the frustum planes
  7090. * @param frustumPlanes defines the frustum planes to test
  7091. * @returns true if there is an intersection
  7092. */
  7093. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7094. /**
  7095. * Tests if the bounding box is entirely inside the frustum planes
  7096. * @param frustumPlanes defines the frustum planes to test
  7097. * @returns true if there is an inclusion
  7098. */
  7099. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7100. /**
  7101. * Tests if a point is inside the bounding box
  7102. * @param point defines the point to test
  7103. * @returns true if the point is inside the bounding box
  7104. */
  7105. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7106. /**
  7107. * Tests if the bounding box intersects with a bounding sphere
  7108. * @param sphere defines the sphere to test
  7109. * @returns true if there is an intersection
  7110. */
  7111. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7112. /**
  7113. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7114. * @param min defines the min vector to use
  7115. * @param max defines the max vector to use
  7116. * @returns true if there is an intersection
  7117. */
  7118. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7119. /**
  7120. * Tests if two bounding boxes are intersections
  7121. * @param box0 defines the first box to test
  7122. * @param box1 defines the second box to test
  7123. * @returns true if there is an intersection
  7124. */
  7125. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7126. /**
  7127. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7128. * @param minPoint defines the minimum vector of the bounding box
  7129. * @param maxPoint defines the maximum vector of the bounding box
  7130. * @param sphereCenter defines the sphere center
  7131. * @param sphereRadius defines the sphere radius
  7132. * @returns true if there is an intersection
  7133. */
  7134. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7135. /**
  7136. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7137. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7138. * @param frustumPlanes defines the frustum planes to test
  7139. * @return true if there is an inclusion
  7140. */
  7141. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7142. /**
  7143. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7144. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7145. * @param frustumPlanes defines the frustum planes to test
  7146. * @return true if there is an intersection
  7147. */
  7148. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7149. }
  7150. }
  7151. declare module "babylonjs/Collisions/collider" {
  7152. import { Nullable, IndicesArray } from "babylonjs/types";
  7153. import { Vector3, Plane } from "babylonjs/Maths/math";
  7154. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7155. /** @hidden */
  7156. export class Collider {
  7157. /** Define if a collision was found */
  7158. collisionFound: boolean;
  7159. /**
  7160. * Define last intersection point in local space
  7161. */
  7162. intersectionPoint: Vector3;
  7163. /**
  7164. * Define last collided mesh
  7165. */
  7166. collidedMesh: Nullable<AbstractMesh>;
  7167. private _collisionPoint;
  7168. private _planeIntersectionPoint;
  7169. private _tempVector;
  7170. private _tempVector2;
  7171. private _tempVector3;
  7172. private _tempVector4;
  7173. private _edge;
  7174. private _baseToVertex;
  7175. private _destinationPoint;
  7176. private _slidePlaneNormal;
  7177. private _displacementVector;
  7178. /** @hidden */
  7179. _radius: Vector3;
  7180. /** @hidden */
  7181. _retry: number;
  7182. private _velocity;
  7183. private _basePoint;
  7184. private _epsilon;
  7185. /** @hidden */
  7186. _velocityWorldLength: number;
  7187. /** @hidden */
  7188. _basePointWorld: Vector3;
  7189. private _velocityWorld;
  7190. private _normalizedVelocity;
  7191. /** @hidden */
  7192. _initialVelocity: Vector3;
  7193. /** @hidden */
  7194. _initialPosition: Vector3;
  7195. private _nearestDistance;
  7196. private _collisionMask;
  7197. collisionMask: number;
  7198. /**
  7199. * Gets the plane normal used to compute the sliding response (in local space)
  7200. */
  7201. readonly slidePlaneNormal: Vector3;
  7202. /** @hidden */
  7203. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7204. /** @hidden */
  7205. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7206. /** @hidden */
  7207. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7208. /** @hidden */
  7209. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  7210. /** @hidden */
  7211. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  7212. /** @hidden */
  7213. _getResponse(pos: Vector3, vel: Vector3): void;
  7214. }
  7215. }
  7216. declare module "babylonjs/Culling/boundingInfo" {
  7217. import { DeepImmutable } from "babylonjs/types";
  7218. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7219. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7220. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7221. import { Collider } from "babylonjs/Collisions/collider";
  7222. /**
  7223. * Interface for cullable objects
  7224. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7225. */
  7226. export interface ICullable {
  7227. /**
  7228. * Checks if the object or part of the object is in the frustum
  7229. * @param frustumPlanes Camera near/planes
  7230. * @returns true if the object is in frustum otherwise false
  7231. */
  7232. isInFrustum(frustumPlanes: Plane[]): boolean;
  7233. /**
  7234. * Checks if a cullable object (mesh...) is in the camera frustum
  7235. * Unlike isInFrustum this cheks the full bounding box
  7236. * @param frustumPlanes Camera near/planes
  7237. * @returns true if the object is in frustum otherwise false
  7238. */
  7239. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7240. }
  7241. /**
  7242. * Info for a bounding data of a mesh
  7243. */
  7244. export class BoundingInfo implements ICullable {
  7245. /**
  7246. * Bounding box for the mesh
  7247. */
  7248. readonly boundingBox: BoundingBox;
  7249. /**
  7250. * Bounding sphere for the mesh
  7251. */
  7252. readonly boundingSphere: BoundingSphere;
  7253. private _isLocked;
  7254. private static readonly TmpVector3;
  7255. /**
  7256. * Constructs bounding info
  7257. * @param minimum min vector of the bounding box/sphere
  7258. * @param maximum max vector of the bounding box/sphere
  7259. * @param worldMatrix defines the new world matrix
  7260. */
  7261. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7262. /**
  7263. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7264. * @param min defines the new minimum vector (in local space)
  7265. * @param max defines the new maximum vector (in local space)
  7266. * @param worldMatrix defines the new world matrix
  7267. */
  7268. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7269. /**
  7270. * min vector of the bounding box/sphere
  7271. */
  7272. readonly minimum: Vector3;
  7273. /**
  7274. * max vector of the bounding box/sphere
  7275. */
  7276. readonly maximum: Vector3;
  7277. /**
  7278. * If the info is locked and won't be updated to avoid perf overhead
  7279. */
  7280. isLocked: boolean;
  7281. /**
  7282. * Updates the bounding sphere and box
  7283. * @param world world matrix to be used to update
  7284. */
  7285. update(world: DeepImmutable<Matrix>): void;
  7286. /**
  7287. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7288. * @param center New center of the bounding info
  7289. * @param extend New extend of the bounding info
  7290. * @returns the current bounding info
  7291. */
  7292. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7293. /**
  7294. * Scale the current bounding info by applying a scale factor
  7295. * @param factor defines the scale factor to apply
  7296. * @returns the current bounding info
  7297. */
  7298. scale(factor: number): BoundingInfo;
  7299. /**
  7300. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7301. * @param frustumPlanes defines the frustum to test
  7302. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7303. * @returns true if the bounding info is in the frustum planes
  7304. */
  7305. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7306. /**
  7307. * Gets the world distance between the min and max points of the bounding box
  7308. */
  7309. readonly diagonalLength: number;
  7310. /**
  7311. * Checks if a cullable object (mesh...) is in the camera frustum
  7312. * Unlike isInFrustum this cheks the full bounding box
  7313. * @param frustumPlanes Camera near/planes
  7314. * @returns true if the object is in frustum otherwise false
  7315. */
  7316. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7317. /** @hidden */
  7318. _checkCollision(collider: Collider): boolean;
  7319. /**
  7320. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7321. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7322. * @param point the point to check intersection with
  7323. * @returns if the point intersects
  7324. */
  7325. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7326. /**
  7327. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7328. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7329. * @param boundingInfo the bounding info to check intersection with
  7330. * @param precise if the intersection should be done using OBB
  7331. * @returns if the bounding info intersects
  7332. */
  7333. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7334. }
  7335. }
  7336. declare module "babylonjs/Misc/smartArray" {
  7337. /**
  7338. * Defines an array and its length.
  7339. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  7340. */
  7341. export interface ISmartArrayLike<T> {
  7342. /**
  7343. * The data of the array.
  7344. */
  7345. data: Array<T>;
  7346. /**
  7347. * The active length of the array.
  7348. */
  7349. length: number;
  7350. }
  7351. /**
  7352. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7353. */
  7354. export class SmartArray<T> implements ISmartArrayLike<T> {
  7355. /**
  7356. * The full set of data from the array.
  7357. */
  7358. data: Array<T>;
  7359. /**
  7360. * The active length of the array.
  7361. */
  7362. length: number;
  7363. protected _id: number;
  7364. /**
  7365. * Instantiates a Smart Array.
  7366. * @param capacity defines the default capacity of the array.
  7367. */
  7368. constructor(capacity: number);
  7369. /**
  7370. * Pushes a value at the end of the active data.
  7371. * @param value defines the object to push in the array.
  7372. */
  7373. push(value: T): void;
  7374. /**
  7375. * Iterates over the active data and apply the lambda to them.
  7376. * @param func defines the action to apply on each value.
  7377. */
  7378. forEach(func: (content: T) => void): void;
  7379. /**
  7380. * Sorts the full sets of data.
  7381. * @param compareFn defines the comparison function to apply.
  7382. */
  7383. sort(compareFn: (a: T, b: T) => number): void;
  7384. /**
  7385. * Resets the active data to an empty array.
  7386. */
  7387. reset(): void;
  7388. /**
  7389. * Releases all the data from the array as well as the array.
  7390. */
  7391. dispose(): void;
  7392. /**
  7393. * Concats the active data with a given array.
  7394. * @param array defines the data to concatenate with.
  7395. */
  7396. concat(array: any): void;
  7397. /**
  7398. * Returns the position of a value in the active data.
  7399. * @param value defines the value to find the index for
  7400. * @returns the index if found in the active data otherwise -1
  7401. */
  7402. indexOf(value: T): number;
  7403. /**
  7404. * Returns whether an element is part of the active data.
  7405. * @param value defines the value to look for
  7406. * @returns true if found in the active data otherwise false
  7407. */
  7408. contains(value: T): boolean;
  7409. private static _GlobalId;
  7410. }
  7411. /**
  7412. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7413. * The data in this array can only be present once
  7414. */
  7415. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  7416. private _duplicateId;
  7417. /**
  7418. * Pushes a value at the end of the active data.
  7419. * THIS DOES NOT PREVENT DUPPLICATE DATA
  7420. * @param value defines the object to push in the array.
  7421. */
  7422. push(value: T): void;
  7423. /**
  7424. * Pushes a value at the end of the active data.
  7425. * If the data is already present, it won t be added again
  7426. * @param value defines the object to push in the array.
  7427. * @returns true if added false if it was already present
  7428. */
  7429. pushNoDuplicate(value: T): boolean;
  7430. /**
  7431. * Resets the active data to an empty array.
  7432. */
  7433. reset(): void;
  7434. /**
  7435. * Concats the active data with a given array.
  7436. * This ensures no dupplicate will be present in the result.
  7437. * @param array defines the data to concatenate with.
  7438. */
  7439. concatWithNoDuplicate(array: any): void;
  7440. }
  7441. }
  7442. declare module "babylonjs/Materials/multiMaterial" {
  7443. import { Nullable } from "babylonjs/types";
  7444. import { Scene } from "babylonjs/scene";
  7445. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7446. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  7447. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7448. import { Material } from "babylonjs/Materials/material";
  7449. /**
  7450. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7451. * separate meshes. This can be use to improve performances.
  7452. * @see http://doc.babylonjs.com/how_to/multi_materials
  7453. */
  7454. export class MultiMaterial extends Material {
  7455. private _subMaterials;
  7456. /**
  7457. * Gets or Sets the list of Materials used within the multi material.
  7458. * They need to be ordered according to the submeshes order in the associated mesh
  7459. */
  7460. subMaterials: Nullable<Material>[];
  7461. /**
  7462. * Function used to align with Node.getChildren()
  7463. * @returns the list of Materials used within the multi material
  7464. */
  7465. getChildren(): Nullable<Material>[];
  7466. /**
  7467. * Instantiates a new Multi Material
  7468. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7469. * separate meshes. This can be use to improve performances.
  7470. * @see http://doc.babylonjs.com/how_to/multi_materials
  7471. * @param name Define the name in the scene
  7472. * @param scene Define the scene the material belongs to
  7473. */
  7474. constructor(name: string, scene: Scene);
  7475. private _hookArray;
  7476. /**
  7477. * Get one of the submaterial by its index in the submaterials array
  7478. * @param index The index to look the sub material at
  7479. * @returns The Material if the index has been defined
  7480. */
  7481. getSubMaterial(index: number): Nullable<Material>;
  7482. /**
  7483. * Get the list of active textures for the whole sub materials list.
  7484. * @returns All the textures that will be used during the rendering
  7485. */
  7486. getActiveTextures(): BaseTexture[];
  7487. /**
  7488. * Gets the current class name of the material e.g. "MultiMaterial"
  7489. * Mainly use in serialization.
  7490. * @returns the class name
  7491. */
  7492. getClassName(): string;
  7493. /**
  7494. * Checks if the material is ready to render the requested sub mesh
  7495. * @param mesh Define the mesh the submesh belongs to
  7496. * @param subMesh Define the sub mesh to look readyness for
  7497. * @param useInstances Define whether or not the material is used with instances
  7498. * @returns true if ready, otherwise false
  7499. */
  7500. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  7501. /**
  7502. * Clones the current material and its related sub materials
  7503. * @param name Define the name of the newly cloned material
  7504. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  7505. * @returns the cloned material
  7506. */
  7507. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  7508. /**
  7509. * Serializes the materials into a JSON representation.
  7510. * @returns the JSON representation
  7511. */
  7512. serialize(): any;
  7513. /**
  7514. * Dispose the material and release its associated resources
  7515. * @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)
  7516. * @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)
  7517. * @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)
  7518. */
  7519. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  7520. /**
  7521. * Creates a MultiMaterial from parsed MultiMaterial data.
  7522. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  7523. * @param scene defines the hosting scene
  7524. * @returns a new MultiMaterial
  7525. */
  7526. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  7527. }
  7528. }
  7529. declare module "babylonjs/Loading/sceneLoaderFlags" {
  7530. /**
  7531. * Class used to represent data loading progression
  7532. */
  7533. export class SceneLoaderFlags {
  7534. private static _ForceFullSceneLoadingForIncremental;
  7535. private static _ShowLoadingScreen;
  7536. private static _CleanBoneMatrixWeights;
  7537. private static _loggingLevel;
  7538. /**
  7539. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  7540. */
  7541. static ForceFullSceneLoadingForIncremental: boolean;
  7542. /**
  7543. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  7544. */
  7545. static ShowLoadingScreen: boolean;
  7546. /**
  7547. * Defines the current logging level (while loading the scene)
  7548. * @ignorenaming
  7549. */
  7550. static loggingLevel: number;
  7551. /**
  7552. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  7553. */
  7554. static CleanBoneMatrixWeights: boolean;
  7555. }
  7556. }
  7557. declare module "babylonjs/Meshes/transformNode" {
  7558. import { DeepImmutable } from "babylonjs/types";
  7559. import { Observable } from "babylonjs/Misc/observable";
  7560. import { Nullable } from "babylonjs/types";
  7561. import { Camera } from "babylonjs/Cameras/camera";
  7562. import { Scene } from "babylonjs/scene";
  7563. import { Quaternion, Matrix, Vector3, Space } from "babylonjs/Maths/math";
  7564. import { Node } from "babylonjs/node";
  7565. import { Bone } from "babylonjs/Bones/bone";
  7566. /**
  7567. * 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.
  7568. * @see https://doc.babylonjs.com/how_to/transformnode
  7569. */
  7570. export class TransformNode extends Node {
  7571. /**
  7572. * Object will not rotate to face the camera
  7573. */
  7574. static BILLBOARDMODE_NONE: number;
  7575. /**
  7576. * Object will rotate to face the camera but only on the x axis
  7577. */
  7578. static BILLBOARDMODE_X: number;
  7579. /**
  7580. * Object will rotate to face the camera but only on the y axis
  7581. */
  7582. static BILLBOARDMODE_Y: number;
  7583. /**
  7584. * Object will rotate to face the camera but only on the z axis
  7585. */
  7586. static BILLBOARDMODE_Z: number;
  7587. /**
  7588. * Object will rotate to face the camera
  7589. */
  7590. static BILLBOARDMODE_ALL: number;
  7591. private _forward;
  7592. private _forwardInverted;
  7593. private _up;
  7594. private _right;
  7595. private _rightInverted;
  7596. private _position;
  7597. private _rotation;
  7598. private _rotationQuaternion;
  7599. protected _scaling: Vector3;
  7600. protected _isDirty: boolean;
  7601. private _transformToBoneReferal;
  7602. private _billboardMode;
  7603. /**
  7604. * Gets or sets the billboard mode. Default is 0.
  7605. *
  7606. * | Value | Type | Description |
  7607. * | --- | --- | --- |
  7608. * | 0 | BILLBOARDMODE_NONE | |
  7609. * | 1 | BILLBOARDMODE_X | |
  7610. * | 2 | BILLBOARDMODE_Y | |
  7611. * | 4 | BILLBOARDMODE_Z | |
  7612. * | 7 | BILLBOARDMODE_ALL | |
  7613. *
  7614. */
  7615. billboardMode: number;
  7616. private _preserveParentRotationForBillboard;
  7617. /**
  7618. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  7619. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  7620. */
  7621. preserveParentRotationForBillboard: boolean;
  7622. /**
  7623. * 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
  7624. */
  7625. scalingDeterminant: number;
  7626. private _infiniteDistance;
  7627. /**
  7628. * Gets or sets the distance of the object to max, often used by skybox
  7629. */
  7630. infiniteDistance: boolean;
  7631. /**
  7632. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  7633. * By default the system will update normals to compensate
  7634. */
  7635. ignoreNonUniformScaling: boolean;
  7636. /**
  7637. * Gets or sets a boolean indicating that even if rotationQuaternion is defined, you can keep updating rotation property and Babylon.js will just mix both
  7638. */
  7639. reIntegrateRotationIntoRotationQuaternion: boolean;
  7640. /** @hidden */
  7641. _poseMatrix: Nullable<Matrix>;
  7642. /** @hidden */
  7643. _localMatrix: Matrix;
  7644. private _usePivotMatrix;
  7645. private _absolutePosition;
  7646. private _pivotMatrix;
  7647. private _pivotMatrixInverse;
  7648. protected _postMultiplyPivotMatrix: boolean;
  7649. protected _isWorldMatrixFrozen: boolean;
  7650. /** @hidden */
  7651. _indexInSceneTransformNodesArray: number;
  7652. /**
  7653. * An event triggered after the world matrix is updated
  7654. */
  7655. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  7656. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  7657. /**
  7658. * Gets a string identifying the name of the class
  7659. * @returns "TransformNode" string
  7660. */
  7661. getClassName(): string;
  7662. /**
  7663. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  7664. */
  7665. position: Vector3;
  7666. /**
  7667. * 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)).
  7668. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  7669. */
  7670. rotation: Vector3;
  7671. /**
  7672. * 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)).
  7673. */
  7674. scaling: Vector3;
  7675. /**
  7676. * 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).
  7677. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  7678. */
  7679. rotationQuaternion: Nullable<Quaternion>;
  7680. /**
  7681. * The forward direction of that transform in world space.
  7682. */
  7683. readonly forward: Vector3;
  7684. /**
  7685. * The up direction of that transform in world space.
  7686. */
  7687. readonly up: Vector3;
  7688. /**
  7689. * The right direction of that transform in world space.
  7690. */
  7691. readonly right: Vector3;
  7692. /**
  7693. * Copies the parameter passed Matrix into the mesh Pose matrix.
  7694. * @param matrix the matrix to copy the pose from
  7695. * @returns this TransformNode.
  7696. */
  7697. updatePoseMatrix(matrix: Matrix): TransformNode;
  7698. /**
  7699. * Returns the mesh Pose matrix.
  7700. * @returns the pose matrix
  7701. */
  7702. getPoseMatrix(): Matrix;
  7703. /** @hidden */
  7704. _isSynchronized(): boolean;
  7705. /** @hidden */
  7706. _initCache(): void;
  7707. /**
  7708. * Flag the transform node as dirty (Forcing it to update everything)
  7709. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  7710. * @returns this transform node
  7711. */
  7712. markAsDirty(property: string): TransformNode;
  7713. /**
  7714. * Returns the current mesh absolute position.
  7715. * Returns a Vector3.
  7716. */
  7717. readonly absolutePosition: Vector3;
  7718. /**
  7719. * Sets a new matrix to apply before all other transformation
  7720. * @param matrix defines the transform matrix
  7721. * @returns the current TransformNode
  7722. */
  7723. setPreTransformMatrix(matrix: Matrix): TransformNode;
  7724. /**
  7725. * Sets a new pivot matrix to the current node
  7726. * @param matrix defines the new pivot matrix to use
  7727. * @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
  7728. * @returns the current TransformNode
  7729. */
  7730. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  7731. /**
  7732. * Returns the mesh pivot matrix.
  7733. * Default : Identity.
  7734. * @returns the matrix
  7735. */
  7736. getPivotMatrix(): Matrix;
  7737. /**
  7738. * Prevents the World matrix to be computed any longer.
  7739. * @returns the TransformNode.
  7740. */
  7741. freezeWorldMatrix(): TransformNode;
  7742. /**
  7743. * Allows back the World matrix computation.
  7744. * @returns the TransformNode.
  7745. */
  7746. unfreezeWorldMatrix(): this;
  7747. /**
  7748. * True if the World matrix has been frozen.
  7749. */
  7750. readonly isWorldMatrixFrozen: boolean;
  7751. /**
  7752. * Retuns the mesh absolute position in the World.
  7753. * @returns a Vector3.
  7754. */
  7755. getAbsolutePosition(): Vector3;
  7756. /**
  7757. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  7758. * @param absolutePosition the absolute position to set
  7759. * @returns the TransformNode.
  7760. */
  7761. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  7762. /**
  7763. * Sets the mesh position in its local space.
  7764. * @param vector3 the position to set in localspace
  7765. * @returns the TransformNode.
  7766. */
  7767. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  7768. /**
  7769. * Returns the mesh position in the local space from the current World matrix values.
  7770. * @returns a new Vector3.
  7771. */
  7772. getPositionExpressedInLocalSpace(): Vector3;
  7773. /**
  7774. * Translates the mesh along the passed Vector3 in its local space.
  7775. * @param vector3 the distance to translate in localspace
  7776. * @returns the TransformNode.
  7777. */
  7778. locallyTranslate(vector3: Vector3): TransformNode;
  7779. private static _lookAtVectorCache;
  7780. /**
  7781. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  7782. * @param targetPoint the position (must be in same space as current mesh) to look at
  7783. * @param yawCor optional yaw (y-axis) correction in radians
  7784. * @param pitchCor optional pitch (x-axis) correction in radians
  7785. * @param rollCor optional roll (z-axis) correction in radians
  7786. * @param space the choosen space of the target
  7787. * @returns the TransformNode.
  7788. */
  7789. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  7790. /**
  7791. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7792. * This Vector3 is expressed in the World space.
  7793. * @param localAxis axis to rotate
  7794. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7795. */
  7796. getDirection(localAxis: Vector3): Vector3;
  7797. /**
  7798. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  7799. * localAxis is expressed in the mesh local space.
  7800. * result is computed in the Wordl space from the mesh World matrix.
  7801. * @param localAxis axis to rotate
  7802. * @param result the resulting transformnode
  7803. * @returns this TransformNode.
  7804. */
  7805. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  7806. /**
  7807. * Sets this transform node rotation to the given local axis.
  7808. * @param localAxis the axis in local space
  7809. * @param yawCor optional yaw (y-axis) correction in radians
  7810. * @param pitchCor optional pitch (x-axis) correction in radians
  7811. * @param rollCor optional roll (z-axis) correction in radians
  7812. * @returns this TransformNode
  7813. */
  7814. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  7815. /**
  7816. * Sets a new pivot point to the current node
  7817. * @param point defines the new pivot point to use
  7818. * @param space defines if the point is in world or local space (local by default)
  7819. * @returns the current TransformNode
  7820. */
  7821. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  7822. /**
  7823. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  7824. * @returns the pivot point
  7825. */
  7826. getPivotPoint(): Vector3;
  7827. /**
  7828. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  7829. * @param result the vector3 to store the result
  7830. * @returns this TransformNode.
  7831. */
  7832. getPivotPointToRef(result: Vector3): TransformNode;
  7833. /**
  7834. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  7835. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  7836. */
  7837. getAbsolutePivotPoint(): Vector3;
  7838. /**
  7839. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  7840. * @param result vector3 to store the result
  7841. * @returns this TransformNode.
  7842. */
  7843. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  7844. /**
  7845. * Defines the passed node as the parent of the current node.
  7846. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  7847. * @see https://doc.babylonjs.com/how_to/parenting
  7848. * @param node the node ot set as the parent
  7849. * @returns this TransformNode.
  7850. */
  7851. setParent(node: Nullable<Node>): TransformNode;
  7852. private _nonUniformScaling;
  7853. /**
  7854. * True if the scaling property of this object is non uniform eg. (1,2,1)
  7855. */
  7856. readonly nonUniformScaling: boolean;
  7857. /** @hidden */
  7858. _updateNonUniformScalingState(value: boolean): boolean;
  7859. /**
  7860. * Attach the current TransformNode to another TransformNode associated with a bone
  7861. * @param bone Bone affecting the TransformNode
  7862. * @param affectedTransformNode TransformNode associated with the bone
  7863. * @returns this object
  7864. */
  7865. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  7866. /**
  7867. * Detach the transform node if its associated with a bone
  7868. * @returns this object
  7869. */
  7870. detachFromBone(): TransformNode;
  7871. private static _rotationAxisCache;
  7872. /**
  7873. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  7874. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7875. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7876. * The passed axis is also normalized.
  7877. * @param axis the axis to rotate around
  7878. * @param amount the amount to rotate in radians
  7879. * @param space Space to rotate in (Default: local)
  7880. * @returns the TransformNode.
  7881. */
  7882. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  7883. /**
  7884. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  7885. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7886. * The passed axis is also normalized. .
  7887. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  7888. * @param point the point to rotate around
  7889. * @param axis the axis to rotate around
  7890. * @param amount the amount to rotate in radians
  7891. * @returns the TransformNode
  7892. */
  7893. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  7894. /**
  7895. * Translates the mesh along the axis vector for the passed distance in the given space.
  7896. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7897. * @param axis the axis to translate in
  7898. * @param distance the distance to translate
  7899. * @param space Space to rotate in (Default: local)
  7900. * @returns the TransformNode.
  7901. */
  7902. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  7903. /**
  7904. * Adds a rotation step to the mesh current rotation.
  7905. * x, y, z are Euler angles expressed in radians.
  7906. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  7907. * This means this rotation is made in the mesh local space only.
  7908. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  7909. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  7910. * ```javascript
  7911. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  7912. * ```
  7913. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  7914. * 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.
  7915. * @param x Rotation to add
  7916. * @param y Rotation to add
  7917. * @param z Rotation to add
  7918. * @returns the TransformNode.
  7919. */
  7920. addRotation(x: number, y: number, z: number): TransformNode;
  7921. /**
  7922. * @hidden
  7923. */
  7924. protected _getEffectiveParent(): Nullable<Node>;
  7925. /**
  7926. * Computes the world matrix of the node
  7927. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  7928. * @returns the world matrix
  7929. */
  7930. computeWorldMatrix(force?: boolean): Matrix;
  7931. protected _afterComputeWorldMatrix(): void;
  7932. /**
  7933. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  7934. * @param func callback function to add
  7935. *
  7936. * @returns the TransformNode.
  7937. */
  7938. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7939. /**
  7940. * Removes a registered callback function.
  7941. * @param func callback function to remove
  7942. * @returns the TransformNode.
  7943. */
  7944. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7945. /**
  7946. * Gets the position of the current mesh in camera space
  7947. * @param camera defines the camera to use
  7948. * @returns a position
  7949. */
  7950. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  7951. /**
  7952. * Returns the distance from the mesh to the active camera
  7953. * @param camera defines the camera to use
  7954. * @returns the distance
  7955. */
  7956. getDistanceToCamera(camera?: Nullable<Camera>): number;
  7957. /**
  7958. * Clone the current transform node
  7959. * @param name Name of the new clone
  7960. * @param newParent New parent for the clone
  7961. * @param doNotCloneChildren Do not clone children hierarchy
  7962. * @returns the new transform node
  7963. */
  7964. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  7965. /**
  7966. * Serializes the objects information.
  7967. * @param currentSerializationObject defines the object to serialize in
  7968. * @returns the serialized object
  7969. */
  7970. serialize(currentSerializationObject?: any): any;
  7971. /**
  7972. * Returns a new TransformNode object parsed from the source provided.
  7973. * @param parsedTransformNode is the source.
  7974. * @param scene the scne the object belongs to
  7975. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  7976. * @returns a new TransformNode object parsed from the source provided.
  7977. */
  7978. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  7979. /**
  7980. * Get all child-transformNodes of this node
  7981. * @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
  7982. * @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
  7983. * @returns an array of TransformNode
  7984. */
  7985. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  7986. /**
  7987. * Releases resources associated with this transform node.
  7988. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  7989. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  7990. */
  7991. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  7992. }
  7993. }
  7994. declare module "babylonjs/Animations/animationPropertiesOverride" {
  7995. /**
  7996. * Class used to override all child animations of a given target
  7997. */
  7998. export class AnimationPropertiesOverride {
  7999. /**
  8000. * Gets or sets a value indicating if animation blending must be used
  8001. */
  8002. enableBlending: boolean;
  8003. /**
  8004. * Gets or sets the blending speed to use when enableBlending is true
  8005. */
  8006. blendingSpeed: number;
  8007. /**
  8008. * Gets or sets the default loop mode to use
  8009. */
  8010. loopMode: number;
  8011. }
  8012. }
  8013. declare module "babylonjs/Bones/bone" {
  8014. import { Skeleton } from "babylonjs/Bones/skeleton";
  8015. import { Vector3, Quaternion, Matrix, Space } from "babylonjs/Maths/math";
  8016. import { Nullable } from "babylonjs/types";
  8017. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8018. import { TransformNode } from "babylonjs/Meshes/transformNode";
  8019. import { Node } from "babylonjs/node";
  8020. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  8021. /**
  8022. * Class used to store bone information
  8023. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  8024. */
  8025. export class Bone extends Node {
  8026. /**
  8027. * defines the bone name
  8028. */
  8029. name: string;
  8030. private static _tmpVecs;
  8031. private static _tmpQuat;
  8032. private static _tmpMats;
  8033. /**
  8034. * Gets the list of child bones
  8035. */
  8036. children: Bone[];
  8037. /** Gets the animations associated with this bone */
  8038. animations: import("babylonjs/Animations/animation").Animation[];
  8039. /**
  8040. * Gets or sets bone length
  8041. */
  8042. length: number;
  8043. /**
  8044. * @hidden Internal only
  8045. * Set this value to map this bone to a different index in the transform matrices
  8046. * Set this value to -1 to exclude the bone from the transform matrices
  8047. */
  8048. _index: Nullable<number>;
  8049. private _skeleton;
  8050. private _localMatrix;
  8051. private _restPose;
  8052. private _baseMatrix;
  8053. private _absoluteTransform;
  8054. private _invertedAbsoluteTransform;
  8055. private _parent;
  8056. private _scalingDeterminant;
  8057. private _worldTransform;
  8058. private _localScaling;
  8059. private _localRotation;
  8060. private _localPosition;
  8061. private _needToDecompose;
  8062. private _needToCompose;
  8063. /** @hidden */
  8064. _linkedTransformNode: Nullable<TransformNode>;
  8065. /** @hidden */
  8066. _waitingTransformNodeId: Nullable<string>;
  8067. /** @hidden */
  8068. /** @hidden */
  8069. _matrix: Matrix;
  8070. /**
  8071. * Create a new bone
  8072. * @param name defines the bone name
  8073. * @param skeleton defines the parent skeleton
  8074. * @param parentBone defines the parent (can be null if the bone is the root)
  8075. * @param localMatrix defines the local matrix
  8076. * @param restPose defines the rest pose matrix
  8077. * @param baseMatrix defines the base matrix
  8078. * @param index defines index of the bone in the hiearchy
  8079. */
  8080. constructor(
  8081. /**
  8082. * defines the bone name
  8083. */
  8084. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  8085. /**
  8086. * Gets the current object class name.
  8087. * @return the class name
  8088. */
  8089. getClassName(): string;
  8090. /**
  8091. * Gets the parent skeleton
  8092. * @returns a skeleton
  8093. */
  8094. getSkeleton(): Skeleton;
  8095. /**
  8096. * Gets parent bone
  8097. * @returns a bone or null if the bone is the root of the bone hierarchy
  8098. */
  8099. getParent(): Nullable<Bone>;
  8100. /**
  8101. * Returns an array containing the root bones
  8102. * @returns an array containing the root bones
  8103. */
  8104. getChildren(): Array<Bone>;
  8105. /**
  8106. * Sets the parent bone
  8107. * @param parent defines the parent (can be null if the bone is the root)
  8108. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8109. */
  8110. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  8111. /**
  8112. * Gets the local matrix
  8113. * @returns a matrix
  8114. */
  8115. getLocalMatrix(): Matrix;
  8116. /**
  8117. * Gets the base matrix (initial matrix which remains unchanged)
  8118. * @returns a matrix
  8119. */
  8120. getBaseMatrix(): Matrix;
  8121. /**
  8122. * Gets the rest pose matrix
  8123. * @returns a matrix
  8124. */
  8125. getRestPose(): Matrix;
  8126. /**
  8127. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  8128. */
  8129. getWorldMatrix(): Matrix;
  8130. /**
  8131. * Sets the local matrix to rest pose matrix
  8132. */
  8133. returnToRest(): void;
  8134. /**
  8135. * Gets the inverse of the absolute transform matrix.
  8136. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  8137. * @returns a matrix
  8138. */
  8139. getInvertedAbsoluteTransform(): Matrix;
  8140. /**
  8141. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  8142. * @returns a matrix
  8143. */
  8144. getAbsoluteTransform(): Matrix;
  8145. /**
  8146. * Links with the given transform node.
  8147. * The local matrix of this bone is copied from the transform node every frame.
  8148. * @param transformNode defines the transform node to link to
  8149. */
  8150. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  8151. /** Gets or sets current position (in local space) */
  8152. position: Vector3;
  8153. /** Gets or sets current rotation (in local space) */
  8154. rotation: Vector3;
  8155. /** Gets or sets current rotation quaternion (in local space) */
  8156. rotationQuaternion: Quaternion;
  8157. /** Gets or sets current scaling (in local space) */
  8158. scaling: Vector3;
  8159. /**
  8160. * Gets the animation properties override
  8161. */
  8162. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  8163. private _decompose;
  8164. private _compose;
  8165. /**
  8166. * Update the base and local matrices
  8167. * @param matrix defines the new base or local matrix
  8168. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8169. * @param updateLocalMatrix defines if the local matrix should be updated
  8170. */
  8171. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  8172. /** @hidden */
  8173. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  8174. /**
  8175. * Flag the bone as dirty (Forcing it to update everything)
  8176. */
  8177. markAsDirty(): void;
  8178. private _markAsDirtyAndCompose;
  8179. private _markAsDirtyAndDecompose;
  8180. /**
  8181. * Translate the bone in local or world space
  8182. * @param vec The amount to translate the bone
  8183. * @param space The space that the translation is in
  8184. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8185. */
  8186. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8187. /**
  8188. * Set the postion of the bone in local or world space
  8189. * @param position The position to set the bone
  8190. * @param space The space that the position is in
  8191. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8192. */
  8193. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8194. /**
  8195. * Set the absolute position of the bone (world space)
  8196. * @param position The position to set the bone
  8197. * @param mesh The mesh that this bone is attached to
  8198. */
  8199. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  8200. /**
  8201. * Scale the bone on the x, y and z axes (in local space)
  8202. * @param x The amount to scale the bone on the x axis
  8203. * @param y The amount to scale the bone on the y axis
  8204. * @param z The amount to scale the bone on the z axis
  8205. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  8206. */
  8207. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  8208. /**
  8209. * Set the bone scaling in local space
  8210. * @param scale defines the scaling vector
  8211. */
  8212. setScale(scale: Vector3): void;
  8213. /**
  8214. * Gets the current scaling in local space
  8215. * @returns the current scaling vector
  8216. */
  8217. getScale(): Vector3;
  8218. /**
  8219. * Gets the current scaling in local space and stores it in a target vector
  8220. * @param result defines the target vector
  8221. */
  8222. getScaleToRef(result: Vector3): void;
  8223. /**
  8224. * Set the yaw, pitch, and roll of the bone in local or world space
  8225. * @param yaw The rotation of the bone on the y axis
  8226. * @param pitch The rotation of the bone on the x axis
  8227. * @param roll The rotation of the bone on the z axis
  8228. * @param space The space that the axes of rotation are in
  8229. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8230. */
  8231. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  8232. /**
  8233. * Add a rotation to the bone on an axis in local or world space
  8234. * @param axis The axis to rotate the bone on
  8235. * @param amount The amount to rotate the bone
  8236. * @param space The space that the axis is in
  8237. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8238. */
  8239. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  8240. /**
  8241. * Set the rotation of the bone to a particular axis angle in local or world space
  8242. * @param axis The axis to rotate the bone on
  8243. * @param angle The angle that the bone should be rotated to
  8244. * @param space The space that the axis is in
  8245. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8246. */
  8247. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  8248. /**
  8249. * Set the euler rotation of the bone in local of world space
  8250. * @param rotation The euler rotation that the bone should be set to
  8251. * @param space The space that the rotation is in
  8252. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8253. */
  8254. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8255. /**
  8256. * Set the quaternion rotation of the bone in local of world space
  8257. * @param quat The quaternion rotation that the bone should be set to
  8258. * @param space The space that the rotation is in
  8259. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8260. */
  8261. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  8262. /**
  8263. * Set the rotation matrix of the bone in local of world space
  8264. * @param rotMat The rotation matrix that the bone should be set to
  8265. * @param space The space that the rotation is in
  8266. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8267. */
  8268. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  8269. private _rotateWithMatrix;
  8270. private _getNegativeRotationToRef;
  8271. /**
  8272. * Get the position of the bone in local or world space
  8273. * @param space The space that the returned position is in
  8274. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8275. * @returns The position of the bone
  8276. */
  8277. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8278. /**
  8279. * Copy the position of the bone to a vector3 in local or world space
  8280. * @param space The space that the returned position is in
  8281. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8282. * @param result The vector3 to copy the position to
  8283. */
  8284. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  8285. /**
  8286. * Get the absolute position of the bone (world space)
  8287. * @param mesh The mesh that this bone is attached to
  8288. * @returns The absolute position of the bone
  8289. */
  8290. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  8291. /**
  8292. * Copy the absolute position of the bone (world space) to the result param
  8293. * @param mesh The mesh that this bone is attached to
  8294. * @param result The vector3 to copy the absolute position to
  8295. */
  8296. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  8297. /**
  8298. * Compute the absolute transforms of this bone and its children
  8299. */
  8300. computeAbsoluteTransforms(): void;
  8301. /**
  8302. * Get the world direction from an axis that is in the local space of the bone
  8303. * @param localAxis The local direction that is used to compute the world direction
  8304. * @param mesh The mesh that this bone is attached to
  8305. * @returns The world direction
  8306. */
  8307. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8308. /**
  8309. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  8310. * @param localAxis The local direction that is used to compute the world direction
  8311. * @param mesh The mesh that this bone is attached to
  8312. * @param result The vector3 that the world direction will be copied to
  8313. */
  8314. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8315. /**
  8316. * Get the euler rotation of the bone in local or world space
  8317. * @param space The space that the rotation should be in
  8318. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8319. * @returns The euler rotation
  8320. */
  8321. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8322. /**
  8323. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  8324. * @param space The space that the rotation should be in
  8325. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8326. * @param result The vector3 that the rotation should be copied to
  8327. */
  8328. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8329. /**
  8330. * Get the quaternion rotation of the bone in either local or world space
  8331. * @param space The space that the rotation should be in
  8332. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8333. * @returns The quaternion rotation
  8334. */
  8335. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  8336. /**
  8337. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  8338. * @param space The space that the rotation should be in
  8339. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8340. * @param result The quaternion that the rotation should be copied to
  8341. */
  8342. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  8343. /**
  8344. * Get the rotation matrix of the bone in local or world space
  8345. * @param space The space that the rotation should be in
  8346. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8347. * @returns The rotation matrix
  8348. */
  8349. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  8350. /**
  8351. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  8352. * @param space The space that the rotation should be in
  8353. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8354. * @param result The quaternion that the rotation should be copied to
  8355. */
  8356. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  8357. /**
  8358. * Get the world position of a point that is in the local space of the bone
  8359. * @param position The local position
  8360. * @param mesh The mesh that this bone is attached to
  8361. * @returns The world position
  8362. */
  8363. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8364. /**
  8365. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  8366. * @param position The local position
  8367. * @param mesh The mesh that this bone is attached to
  8368. * @param result The vector3 that the world position should be copied to
  8369. */
  8370. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8371. /**
  8372. * Get the local position of a point that is in world space
  8373. * @param position The world position
  8374. * @param mesh The mesh that this bone is attached to
  8375. * @returns The local position
  8376. */
  8377. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8378. /**
  8379. * Get the local position of a point that is in world space and copy it to the result param
  8380. * @param position The world position
  8381. * @param mesh The mesh that this bone is attached to
  8382. * @param result The vector3 that the local position should be copied to
  8383. */
  8384. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8385. }
  8386. }
  8387. declare module "babylonjs/Misc/iInspectable" {
  8388. /**
  8389. * Enum that determines the text-wrapping mode to use.
  8390. */
  8391. export enum InspectableType {
  8392. /**
  8393. * Checkbox for booleans
  8394. */
  8395. Checkbox = 0,
  8396. /**
  8397. * Sliders for numbers
  8398. */
  8399. Slider = 1,
  8400. /**
  8401. * Vector3
  8402. */
  8403. Vector3 = 2,
  8404. /**
  8405. * Quaternions
  8406. */
  8407. Quaternion = 3,
  8408. /**
  8409. * Color3
  8410. */
  8411. Color3 = 4
  8412. }
  8413. /**
  8414. * Interface used to define custom inspectable properties.
  8415. * This interface is used by the inspector to display custom property grids
  8416. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  8417. */
  8418. export interface IInspectable {
  8419. /**
  8420. * Gets the label to display
  8421. */
  8422. label: string;
  8423. /**
  8424. * Gets the name of the property to edit
  8425. */
  8426. propertyName: string;
  8427. /**
  8428. * Gets the type of the editor to use
  8429. */
  8430. type: InspectableType;
  8431. /**
  8432. * Gets the minimum value of the property when using in "slider" mode
  8433. */
  8434. min?: number;
  8435. /**
  8436. * Gets the maximum value of the property when using in "slider" mode
  8437. */
  8438. max?: number;
  8439. /**
  8440. * Gets the setp to use when using in "slider" mode
  8441. */
  8442. step?: number;
  8443. }
  8444. }
  8445. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  8446. import { Nullable } from "babylonjs/types";
  8447. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8448. /**
  8449. * This represents the required contract to create a new type of texture loader.
  8450. */
  8451. export interface IInternalTextureLoader {
  8452. /**
  8453. * Defines wether the loader supports cascade loading the different faces.
  8454. */
  8455. supportCascades: boolean;
  8456. /**
  8457. * This returns if the loader support the current file information.
  8458. * @param extension defines the file extension of the file being loaded
  8459. * @param textureFormatInUse defines the current compressed format in use iun the engine
  8460. * @param fallback defines the fallback internal texture if any
  8461. * @param isBase64 defines whether the texture is encoded as a base64
  8462. * @param isBuffer defines whether the texture data are stored as a buffer
  8463. * @returns true if the loader can load the specified file
  8464. */
  8465. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  8466. /**
  8467. * Transform the url before loading if required.
  8468. * @param rootUrl the url of the texture
  8469. * @param textureFormatInUse defines the current compressed format in use iun the engine
  8470. * @returns the transformed texture
  8471. */
  8472. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  8473. /**
  8474. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  8475. * @param rootUrl the url of the texture
  8476. * @param textureFormatInUse defines the current compressed format in use iun the engine
  8477. * @returns the fallback texture
  8478. */
  8479. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  8480. /**
  8481. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  8482. * @param data contains the texture data
  8483. * @param texture defines the BabylonJS internal texture
  8484. * @param createPolynomials will be true if polynomials have been requested
  8485. * @param onLoad defines the callback to trigger once the texture is ready
  8486. * @param onError defines the callback to trigger in case of error
  8487. */
  8488. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  8489. /**
  8490. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  8491. * @param data contains the texture data
  8492. * @param texture defines the BabylonJS internal texture
  8493. * @param callback defines the method to call once ready to upload
  8494. */
  8495. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  8496. }
  8497. }
  8498. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  8499. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8500. import { Nullable } from "babylonjs/types";
  8501. import { Scene } from "babylonjs/scene";
  8502. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  8503. module "babylonjs/Engines/engine" {
  8504. interface Engine {
  8505. /**
  8506. * Creates a depth stencil cube texture.
  8507. * This is only available in WebGL 2.
  8508. * @param size The size of face edge in the cube texture.
  8509. * @param options The options defining the cube texture.
  8510. * @returns The cube texture
  8511. */
  8512. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  8513. /**
  8514. * Creates a cube texture
  8515. * @param rootUrl defines the url where the files to load is located
  8516. * @param scene defines the current scene
  8517. * @param files defines the list of files to load (1 per face)
  8518. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8519. * @param onLoad defines an optional callback raised when the texture is loaded
  8520. * @param onError defines an optional callback raised if there is an issue to load the texture
  8521. * @param format defines the format of the data
  8522. * @param forcedExtension defines the extension to use to pick the right loader
  8523. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  8524. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8525. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8526. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  8527. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  8528. * @returns the cube texture as an InternalTexture
  8529. */
  8530. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>, excludeLoaders: Array<IInternalTextureLoader>): InternalTexture;
  8531. /**
  8532. * Creates a cube texture
  8533. * @param rootUrl defines the url where the files to load is located
  8534. * @param scene defines the current scene
  8535. * @param files defines the list of files to load (1 per face)
  8536. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8537. * @param onLoad defines an optional callback raised when the texture is loaded
  8538. * @param onError defines an optional callback raised if there is an issue to load the texture
  8539. * @param format defines the format of the data
  8540. * @param forcedExtension defines the extension to use to pick the right loader
  8541. * @returns the cube texture as an InternalTexture
  8542. */
  8543. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any): InternalTexture;
  8544. /**
  8545. * Creates a cube texture
  8546. * @param rootUrl defines the url where the files to load is located
  8547. * @param scene defines the current scene
  8548. * @param files defines the list of files to load (1 per face)
  8549. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8550. * @param onLoad defines an optional callback raised when the texture is loaded
  8551. * @param onError defines an optional callback raised if there is an issue to load the texture
  8552. * @param format defines the format of the data
  8553. * @param forcedExtension defines the extension to use to pick the right loader
  8554. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  8555. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8556. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8557. * @returns the cube texture as an InternalTexture
  8558. */
  8559. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  8560. /** @hidden */
  8561. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  8562. /** @hidden */
  8563. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  8564. /** @hidden */
  8565. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  8566. /** @hidden */
  8567. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  8568. }
  8569. }
  8570. }
  8571. declare module "babylonjs/Materials/Textures/cubeTexture" {
  8572. import { Nullable } from "babylonjs/types";
  8573. import { Scene } from "babylonjs/scene";
  8574. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  8575. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8576. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  8577. /**
  8578. * Class for creating a cube texture
  8579. */
  8580. export class CubeTexture extends BaseTexture {
  8581. private _delayedOnLoad;
  8582. /**
  8583. * The url of the texture
  8584. */
  8585. url: string;
  8586. /**
  8587. * Gets or sets the center of the bounding box associated with the cube texture.
  8588. * It must define where the camera used to render the texture was set
  8589. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8590. */
  8591. boundingBoxPosition: Vector3;
  8592. private _boundingBoxSize;
  8593. /**
  8594. * Gets or sets the size of the bounding box associated with the cube texture
  8595. * When defined, the cubemap will switch to local mode
  8596. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  8597. * @example https://www.babylonjs-playground.com/#RNASML
  8598. */
  8599. /**
  8600. * Returns the bounding box size
  8601. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8602. */
  8603. boundingBoxSize: Vector3;
  8604. protected _rotationY: number;
  8605. /**
  8606. * Sets texture matrix rotation angle around Y axis in radians.
  8607. */
  8608. /**
  8609. * Gets texture matrix rotation angle around Y axis radians.
  8610. */
  8611. rotationY: number;
  8612. /**
  8613. * Are mip maps generated for this texture or not.
  8614. */
  8615. readonly noMipmap: boolean;
  8616. private _noMipmap;
  8617. private _files;
  8618. private _extensions;
  8619. private _textureMatrix;
  8620. private _format;
  8621. private _createPolynomials;
  8622. /** @hidden */
  8623. _prefiltered: boolean;
  8624. /**
  8625. * Creates a cube texture from an array of image urls
  8626. * @param files defines an array of image urls
  8627. * @param scene defines the hosting scene
  8628. * @param noMipmap specifies if mip maps are not used
  8629. * @returns a cube texture
  8630. */
  8631. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  8632. /**
  8633. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  8634. * @param url defines the url of the prefiltered texture
  8635. * @param scene defines the scene the texture is attached to
  8636. * @param forcedExtension defines the extension of the file if different from the url
  8637. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8638. * @return the prefiltered texture
  8639. */
  8640. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  8641. /**
  8642. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  8643. * as prefiltered data.
  8644. * @param rootUrl defines the url of the texture or the root name of the six images
  8645. * @param scene defines the scene the texture is attached to
  8646. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  8647. * @param noMipmap defines if mipmaps should be created or not
  8648. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  8649. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  8650. * @param onError defines a callback triggered in case of error during load
  8651. * @param format defines the internal format to use for the texture once loaded
  8652. * @param prefiltered defines whether or not the texture is created from prefiltered data
  8653. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  8654. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8655. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8656. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8657. * @return the cube texture
  8658. */
  8659. 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);
  8660. /**
  8661. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  8662. */
  8663. readonly isPrefiltered: boolean;
  8664. /**
  8665. * Get the current class name of the texture useful for serialization or dynamic coding.
  8666. * @returns "CubeTexture"
  8667. */
  8668. getClassName(): string;
  8669. /**
  8670. * Update the url (and optional buffer) of this texture if url was null during construction.
  8671. * @param url the url of the texture
  8672. * @param forcedExtension defines the extension to use
  8673. * @param onLoad callback called when the texture is loaded (defaults to null)
  8674. */
  8675. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  8676. /**
  8677. * Delays loading of the cube texture
  8678. * @param forcedExtension defines the extension to use
  8679. */
  8680. delayLoad(forcedExtension?: string): void;
  8681. /**
  8682. * Returns the reflection texture matrix
  8683. * @returns the reflection texture matrix
  8684. */
  8685. getReflectionTextureMatrix(): Matrix;
  8686. /**
  8687. * Sets the reflection texture matrix
  8688. * @param value Reflection texture matrix
  8689. */
  8690. setReflectionTextureMatrix(value: Matrix): void;
  8691. /**
  8692. * Parses text to create a cube texture
  8693. * @param parsedTexture define the serialized text to read from
  8694. * @param scene defines the hosting scene
  8695. * @param rootUrl defines the root url of the cube texture
  8696. * @returns a cube texture
  8697. */
  8698. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8699. /**
  8700. * Makes a clone, or deep copy, of the cube texture
  8701. * @returns a new cube texture
  8702. */
  8703. clone(): CubeTexture;
  8704. }
  8705. }
  8706. declare module "babylonjs/Shaders/postprocess.vertex" {
  8707. /** @hidden */
  8708. export var postprocessVertexShader: {
  8709. name: string;
  8710. shader: string;
  8711. };
  8712. }
  8713. declare module "babylonjs/Cameras/targetCamera" {
  8714. import { Nullable } from "babylonjs/types";
  8715. import { Camera } from "babylonjs/Cameras/camera";
  8716. import { Scene } from "babylonjs/scene";
  8717. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  8718. /**
  8719. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8720. * This is the base of the follow, arc rotate cameras and Free camera
  8721. * @see http://doc.babylonjs.com/features/cameras
  8722. */
  8723. export class TargetCamera extends Camera {
  8724. private static _RigCamTransformMatrix;
  8725. private static _TargetTransformMatrix;
  8726. private static _TargetFocalPoint;
  8727. /**
  8728. * Define the current direction the camera is moving to
  8729. */
  8730. cameraDirection: Vector3;
  8731. /**
  8732. * Define the current rotation the camera is rotating to
  8733. */
  8734. cameraRotation: Vector2;
  8735. /**
  8736. * When set, the up vector of the camera will be updated by the rotation of the camera
  8737. */
  8738. updateUpVectorFromRotation: boolean;
  8739. private _tmpQuaternion;
  8740. /**
  8741. * Define the current rotation of the camera
  8742. */
  8743. rotation: Vector3;
  8744. /**
  8745. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8746. */
  8747. rotationQuaternion: Quaternion;
  8748. /**
  8749. * Define the current speed of the camera
  8750. */
  8751. speed: number;
  8752. /**
  8753. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8754. * around all axis.
  8755. */
  8756. noRotationConstraint: boolean;
  8757. /**
  8758. * Define the current target of the camera as an object or a position.
  8759. */
  8760. lockedTarget: any;
  8761. /** @hidden */
  8762. _currentTarget: Vector3;
  8763. /** @hidden */
  8764. _initialFocalDistance: number;
  8765. /** @hidden */
  8766. _viewMatrix: Matrix;
  8767. /** @hidden */
  8768. _camMatrix: Matrix;
  8769. /** @hidden */
  8770. _cameraTransformMatrix: Matrix;
  8771. /** @hidden */
  8772. _cameraRotationMatrix: Matrix;
  8773. /** @hidden */
  8774. _referencePoint: Vector3;
  8775. /** @hidden */
  8776. _transformedReferencePoint: Vector3;
  8777. protected _globalCurrentTarget: Vector3;
  8778. protected _globalCurrentUpVector: Vector3;
  8779. /** @hidden */
  8780. _reset: () => void;
  8781. private _defaultUp;
  8782. /**
  8783. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8784. * This is the base of the follow, arc rotate cameras and Free camera
  8785. * @see http://doc.babylonjs.com/features/cameras
  8786. * @param name Defines the name of the camera in the scene
  8787. * @param position Defines the start position of the camera in the scene
  8788. * @param scene Defines the scene the camera belongs to
  8789. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8790. */
  8791. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8792. /**
  8793. * Gets the position in front of the camera at a given distance.
  8794. * @param distance The distance from the camera we want the position to be
  8795. * @returns the position
  8796. */
  8797. getFrontPosition(distance: number): Vector3;
  8798. /** @hidden */
  8799. _getLockedTargetPosition(): Nullable<Vector3>;
  8800. private _storedPosition;
  8801. private _storedRotation;
  8802. private _storedRotationQuaternion;
  8803. /**
  8804. * Store current camera state of the camera (fov, position, rotation, etc..)
  8805. * @returns the camera
  8806. */
  8807. storeState(): Camera;
  8808. /**
  8809. * Restored camera state. You must call storeState() first
  8810. * @returns whether it was successful or not
  8811. * @hidden
  8812. */
  8813. _restoreStateValues(): boolean;
  8814. /** @hidden */
  8815. _initCache(): void;
  8816. /** @hidden */
  8817. _updateCache(ignoreParentClass?: boolean): void;
  8818. /** @hidden */
  8819. _isSynchronizedViewMatrix(): boolean;
  8820. /** @hidden */
  8821. _computeLocalCameraSpeed(): number;
  8822. /**
  8823. * Defines the target the camera should look at.
  8824. * This will automatically adapt alpha beta and radius to fit within the new target.
  8825. * @param target Defines the new target as a Vector or a mesh
  8826. */
  8827. setTarget(target: Vector3): void;
  8828. /**
  8829. * Return the current target position of the camera. This value is expressed in local space.
  8830. * @returns the target position
  8831. */
  8832. getTarget(): Vector3;
  8833. /** @hidden */
  8834. _decideIfNeedsToMove(): boolean;
  8835. /** @hidden */
  8836. _updatePosition(): void;
  8837. /** @hidden */
  8838. _checkInputs(): void;
  8839. protected _updateCameraRotationMatrix(): void;
  8840. /**
  8841. * 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)
  8842. * @returns the current camera
  8843. */
  8844. private _rotateUpVectorWithCameraRotationMatrix;
  8845. private _cachedRotationZ;
  8846. private _cachedQuaternionRotationZ;
  8847. /** @hidden */
  8848. _getViewMatrix(): Matrix;
  8849. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8850. /**
  8851. * @hidden
  8852. */
  8853. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8854. /**
  8855. * @hidden
  8856. */
  8857. _updateRigCameras(): void;
  8858. private _getRigCamPositionAndTarget;
  8859. /**
  8860. * Gets the current object class name.
  8861. * @return the class name
  8862. */
  8863. getClassName(): string;
  8864. }
  8865. }
  8866. declare module "babylonjs/Cameras/cameraInputsManager" {
  8867. import { Nullable } from "babylonjs/types";
  8868. import { Camera } from "babylonjs/Cameras/camera";
  8869. /**
  8870. * @ignore
  8871. * This is a list of all the different input types that are available in the application.
  8872. * Fo instance: ArcRotateCameraGamepadInput...
  8873. */
  8874. export var CameraInputTypes: {};
  8875. /**
  8876. * This is the contract to implement in order to create a new input class.
  8877. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8878. */
  8879. export interface ICameraInput<TCamera extends Camera> {
  8880. /**
  8881. * Defines the camera the input is attached to.
  8882. */
  8883. camera: Nullable<TCamera>;
  8884. /**
  8885. * Gets the class name of the current intput.
  8886. * @returns the class name
  8887. */
  8888. getClassName(): string;
  8889. /**
  8890. * Get the friendly name associated with the input class.
  8891. * @returns the input friendly name
  8892. */
  8893. getSimpleName(): string;
  8894. /**
  8895. * Attach the input controls to a specific dom element to get the input from.
  8896. * @param element Defines the element the controls should be listened from
  8897. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8898. */
  8899. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8900. /**
  8901. * Detach the current controls from the specified dom element.
  8902. * @param element Defines the element to stop listening the inputs from
  8903. */
  8904. detachControl(element: Nullable<HTMLElement>): void;
  8905. /**
  8906. * Update the current camera state depending on the inputs that have been used this frame.
  8907. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8908. */
  8909. checkInputs?: () => void;
  8910. }
  8911. /**
  8912. * Represents a map of input types to input instance or input index to input instance.
  8913. */
  8914. export interface CameraInputsMap<TCamera extends Camera> {
  8915. /**
  8916. * Accessor to the input by input type.
  8917. */
  8918. [name: string]: ICameraInput<TCamera>;
  8919. /**
  8920. * Accessor to the input by input index.
  8921. */
  8922. [idx: number]: ICameraInput<TCamera>;
  8923. }
  8924. /**
  8925. * This represents the input manager used within a camera.
  8926. * It helps dealing with all the different kind of input attached to a camera.
  8927. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8928. */
  8929. export class CameraInputsManager<TCamera extends Camera> {
  8930. /**
  8931. * Defines the list of inputs attahed to the camera.
  8932. */
  8933. attached: CameraInputsMap<TCamera>;
  8934. /**
  8935. * Defines the dom element the camera is collecting inputs from.
  8936. * This is null if the controls have not been attached.
  8937. */
  8938. attachedElement: Nullable<HTMLElement>;
  8939. /**
  8940. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8941. */
  8942. noPreventDefault: boolean;
  8943. /**
  8944. * Defined the camera the input manager belongs to.
  8945. */
  8946. camera: TCamera;
  8947. /**
  8948. * Update the current camera state depending on the inputs that have been used this frame.
  8949. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8950. */
  8951. checkInputs: () => void;
  8952. /**
  8953. * Instantiate a new Camera Input Manager.
  8954. * @param camera Defines the camera the input manager blongs to
  8955. */
  8956. constructor(camera: TCamera);
  8957. /**
  8958. * Add an input method to a camera
  8959. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8960. * @param input camera input method
  8961. */
  8962. add(input: ICameraInput<TCamera>): void;
  8963. /**
  8964. * Remove a specific input method from a camera
  8965. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8966. * @param inputToRemove camera input method
  8967. */
  8968. remove(inputToRemove: ICameraInput<TCamera>): void;
  8969. /**
  8970. * Remove a specific input type from a camera
  8971. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8972. * @param inputType the type of the input to remove
  8973. */
  8974. removeByType(inputType: string): void;
  8975. private _addCheckInputs;
  8976. /**
  8977. * Attach the input controls to the currently attached dom element to listen the events from.
  8978. * @param input Defines the input to attach
  8979. */
  8980. attachInput(input: ICameraInput<TCamera>): void;
  8981. /**
  8982. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8983. * @param element Defines the dom element to collect the events from
  8984. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8985. */
  8986. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8987. /**
  8988. * Detach the current manager inputs controls from a specific dom element.
  8989. * @param element Defines the dom element to collect the events from
  8990. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8991. */
  8992. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8993. /**
  8994. * Rebuild the dynamic inputCheck function from the current list of
  8995. * defined inputs in the manager.
  8996. */
  8997. rebuildInputCheck(): void;
  8998. /**
  8999. * Remove all attached input methods from a camera
  9000. */
  9001. clear(): void;
  9002. /**
  9003. * Serialize the current input manager attached to a camera.
  9004. * This ensures than once parsed,
  9005. * the input associated to the camera will be identical to the current ones
  9006. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  9007. */
  9008. serialize(serializedCamera: any): void;
  9009. /**
  9010. * Parses an input manager serialized JSON to restore the previous list of inputs
  9011. * and states associated to a camera.
  9012. * @param parsedCamera Defines the JSON to parse
  9013. */
  9014. parse(parsedCamera: any): void;
  9015. }
  9016. }
  9017. declare module "babylonjs/Events/keyboardEvents" {
  9018. /**
  9019. * Gather the list of keyboard event types as constants.
  9020. */
  9021. export class KeyboardEventTypes {
  9022. /**
  9023. * The keydown event is fired when a key becomes active (pressed).
  9024. */
  9025. static readonly KEYDOWN: number;
  9026. /**
  9027. * The keyup event is fired when a key has been released.
  9028. */
  9029. static readonly KEYUP: number;
  9030. }
  9031. /**
  9032. * This class is used to store keyboard related info for the onKeyboardObservable event.
  9033. */
  9034. export class KeyboardInfo {
  9035. /**
  9036. * Defines the type of event (KeyboardEventTypes)
  9037. */
  9038. type: number;
  9039. /**
  9040. * Defines the related dom event
  9041. */
  9042. event: KeyboardEvent;
  9043. /**
  9044. * Instantiates a new keyboard info.
  9045. * This class is used to store keyboard related info for the onKeyboardObservable event.
  9046. * @param type Defines the type of event (KeyboardEventTypes)
  9047. * @param event Defines the related dom event
  9048. */
  9049. constructor(
  9050. /**
  9051. * Defines the type of event (KeyboardEventTypes)
  9052. */
  9053. type: number,
  9054. /**
  9055. * Defines the related dom event
  9056. */
  9057. event: KeyboardEvent);
  9058. }
  9059. /**
  9060. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  9061. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  9062. */
  9063. export class KeyboardInfoPre extends KeyboardInfo {
  9064. /**
  9065. * Defines the type of event (KeyboardEventTypes)
  9066. */
  9067. type: number;
  9068. /**
  9069. * Defines the related dom event
  9070. */
  9071. event: KeyboardEvent;
  9072. /**
  9073. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  9074. */
  9075. skipOnPointerObservable: boolean;
  9076. /**
  9077. * Instantiates a new keyboard pre info.
  9078. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  9079. * @param type Defines the type of event (KeyboardEventTypes)
  9080. * @param event Defines the related dom event
  9081. */
  9082. constructor(
  9083. /**
  9084. * Defines the type of event (KeyboardEventTypes)
  9085. */
  9086. type: number,
  9087. /**
  9088. * Defines the related dom event
  9089. */
  9090. event: KeyboardEvent);
  9091. }
  9092. }
  9093. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  9094. import { Nullable } from "babylonjs/types";
  9095. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  9096. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  9097. /**
  9098. * Manage the keyboard inputs to control the movement of a free camera.
  9099. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  9100. */
  9101. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  9102. /**
  9103. * Defines the camera the input is attached to.
  9104. */
  9105. camera: FreeCamera;
  9106. /**
  9107. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  9108. */
  9109. keysUp: number[];
  9110. /**
  9111. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  9112. */
  9113. keysDown: number[];
  9114. /**
  9115. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  9116. */
  9117. keysLeft: number[];
  9118. /**
  9119. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  9120. */
  9121. keysRight: number[];
  9122. private _keys;
  9123. private _onCanvasBlurObserver;
  9124. private _onKeyboardObserver;
  9125. private _engine;
  9126. private _scene;
  9127. /**
  9128. * Attach the input controls to a specific dom element to get the input from.
  9129. * @param element Defines the element the controls should be listened from
  9130. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9131. */
  9132. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  9133. /**
  9134. * Detach the current controls from the specified dom element.
  9135. * @param element Defines the element to stop listening the inputs from
  9136. */
  9137. detachControl(element: Nullable<HTMLElement>): void;
  9138. /**
  9139. * Update the current camera state depending on the inputs that have been used this frame.
  9140. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  9141. */
  9142. checkInputs(): void;
  9143. /**
  9144. * Gets the class name of the current intput.
  9145. * @returns the class name
  9146. */
  9147. getClassName(): string;
  9148. /** @hidden */
  9149. _onLostFocus(): void;
  9150. /**
  9151. * Get the friendly name associated with the input class.
  9152. * @returns the input friendly name
  9153. */
  9154. getSimpleName(): string;
  9155. }
  9156. }
  9157. declare module "babylonjs/Lights/shadowLight" {
  9158. import { Camera } from "babylonjs/Cameras/camera";
  9159. import { Scene } from "babylonjs/scene";
  9160. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  9161. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9162. import { Light } from "babylonjs/Lights/light";
  9163. /**
  9164. * Interface describing all the common properties and methods a shadow light needs to implement.
  9165. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  9166. * as well as binding the different shadow properties to the effects.
  9167. */
  9168. export interface IShadowLight extends Light {
  9169. /**
  9170. * The light id in the scene (used in scene.findLighById for instance)
  9171. */
  9172. id: string;
  9173. /**
  9174. * The position the shdow will be casted from.
  9175. */
  9176. position: Vector3;
  9177. /**
  9178. * In 2d mode (needCube being false), the direction used to cast the shadow.
  9179. */
  9180. direction: Vector3;
  9181. /**
  9182. * The transformed position. Position of the light in world space taking parenting in account.
  9183. */
  9184. transformedPosition: Vector3;
  9185. /**
  9186. * The transformed direction. Direction of the light in world space taking parenting in account.
  9187. */
  9188. transformedDirection: Vector3;
  9189. /**
  9190. * The friendly name of the light in the scene.
  9191. */
  9192. name: string;
  9193. /**
  9194. * Defines the shadow projection clipping minimum z value.
  9195. */
  9196. shadowMinZ: number;
  9197. /**
  9198. * Defines the shadow projection clipping maximum z value.
  9199. */
  9200. shadowMaxZ: number;
  9201. /**
  9202. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9203. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9204. */
  9205. computeTransformedInformation(): boolean;
  9206. /**
  9207. * Gets the scene the light belongs to.
  9208. * @returns The scene
  9209. */
  9210. getScene(): Scene;
  9211. /**
  9212. * Callback defining a custom Projection Matrix Builder.
  9213. * This can be used to override the default projection matrix computation.
  9214. */
  9215. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9216. /**
  9217. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9218. * @param matrix The materix to updated with the projection information
  9219. * @param viewMatrix The transform matrix of the light
  9220. * @param renderList The list of mesh to render in the map
  9221. * @returns The current light
  9222. */
  9223. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9224. /**
  9225. * Gets the current depth scale used in ESM.
  9226. * @returns The scale
  9227. */
  9228. getDepthScale(): number;
  9229. /**
  9230. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9231. * @returns true if a cube texture needs to be use
  9232. */
  9233. needCube(): boolean;
  9234. /**
  9235. * Detects if the projection matrix requires to be recomputed this frame.
  9236. * @returns true if it requires to be recomputed otherwise, false.
  9237. */
  9238. needProjectionMatrixCompute(): boolean;
  9239. /**
  9240. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9241. */
  9242. forceProjectionMatrixCompute(): void;
  9243. /**
  9244. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9245. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9246. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9247. */
  9248. getShadowDirection(faceIndex?: number): Vector3;
  9249. /**
  9250. * Gets the minZ used for shadow according to both the scene and the light.
  9251. * @param activeCamera The camera we are returning the min for
  9252. * @returns the depth min z
  9253. */
  9254. getDepthMinZ(activeCamera: Camera): number;
  9255. /**
  9256. * Gets the maxZ used for shadow according to both the scene and the light.
  9257. * @param activeCamera The camera we are returning the max for
  9258. * @returns the depth max z
  9259. */
  9260. getDepthMaxZ(activeCamera: Camera): number;
  9261. }
  9262. /**
  9263. * Base implementation IShadowLight
  9264. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9265. */
  9266. export abstract class ShadowLight extends Light implements IShadowLight {
  9267. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9268. protected _position: Vector3;
  9269. protected _setPosition(value: Vector3): void;
  9270. /**
  9271. * Sets the position the shadow will be casted from. Also use as the light position for both
  9272. * point and spot lights.
  9273. */
  9274. /**
  9275. * Sets the position the shadow will be casted from. Also use as the light position for both
  9276. * point and spot lights.
  9277. */
  9278. position: Vector3;
  9279. protected _direction: Vector3;
  9280. protected _setDirection(value: Vector3): void;
  9281. /**
  9282. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9283. * Also use as the light direction on spot and directional lights.
  9284. */
  9285. /**
  9286. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9287. * Also use as the light direction on spot and directional lights.
  9288. */
  9289. direction: Vector3;
  9290. private _shadowMinZ;
  9291. /**
  9292. * Gets the shadow projection clipping minimum z value.
  9293. */
  9294. /**
  9295. * Sets the shadow projection clipping minimum z value.
  9296. */
  9297. shadowMinZ: number;
  9298. private _shadowMaxZ;
  9299. /**
  9300. * Sets the shadow projection clipping maximum z value.
  9301. */
  9302. /**
  9303. * Gets the shadow projection clipping maximum z value.
  9304. */
  9305. shadowMaxZ: number;
  9306. /**
  9307. * Callback defining a custom Projection Matrix Builder.
  9308. * This can be used to override the default projection matrix computation.
  9309. */
  9310. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9311. /**
  9312. * The transformed position. Position of the light in world space taking parenting in account.
  9313. */
  9314. transformedPosition: Vector3;
  9315. /**
  9316. * The transformed direction. Direction of the light in world space taking parenting in account.
  9317. */
  9318. transformedDirection: Vector3;
  9319. private _needProjectionMatrixCompute;
  9320. /**
  9321. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9322. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9323. */
  9324. computeTransformedInformation(): boolean;
  9325. /**
  9326. * Return the depth scale used for the shadow map.
  9327. * @returns the depth scale.
  9328. */
  9329. getDepthScale(): number;
  9330. /**
  9331. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9332. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9333. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9334. */
  9335. getShadowDirection(faceIndex?: number): Vector3;
  9336. /**
  9337. * Returns the ShadowLight absolute position in the World.
  9338. * @returns the position vector in world space
  9339. */
  9340. getAbsolutePosition(): Vector3;
  9341. /**
  9342. * Sets the ShadowLight direction toward the passed target.
  9343. * @param target The point to target in local space
  9344. * @returns the updated ShadowLight direction
  9345. */
  9346. setDirectionToTarget(target: Vector3): Vector3;
  9347. /**
  9348. * Returns the light rotation in euler definition.
  9349. * @returns the x y z rotation in local space.
  9350. */
  9351. getRotation(): Vector3;
  9352. /**
  9353. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9354. * @returns true if a cube texture needs to be use
  9355. */
  9356. needCube(): boolean;
  9357. /**
  9358. * Detects if the projection matrix requires to be recomputed this frame.
  9359. * @returns true if it requires to be recomputed otherwise, false.
  9360. */
  9361. needProjectionMatrixCompute(): boolean;
  9362. /**
  9363. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9364. */
  9365. forceProjectionMatrixCompute(): void;
  9366. /** @hidden */
  9367. _initCache(): void;
  9368. /** @hidden */
  9369. _isSynchronized(): boolean;
  9370. /**
  9371. * Computes the world matrix of the node
  9372. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9373. * @returns the world matrix
  9374. */
  9375. computeWorldMatrix(force?: boolean): Matrix;
  9376. /**
  9377. * Gets the minZ used for shadow according to both the scene and the light.
  9378. * @param activeCamera The camera we are returning the min for
  9379. * @returns the depth min z
  9380. */
  9381. getDepthMinZ(activeCamera: Camera): number;
  9382. /**
  9383. * Gets the maxZ used for shadow according to both the scene and the light.
  9384. * @param activeCamera The camera we are returning the max for
  9385. * @returns the depth max z
  9386. */
  9387. getDepthMaxZ(activeCamera: Camera): number;
  9388. /**
  9389. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9390. * @param matrix The materix to updated with the projection information
  9391. * @param viewMatrix The transform matrix of the light
  9392. * @param renderList The list of mesh to render in the map
  9393. * @returns The current light
  9394. */
  9395. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9396. }
  9397. }
  9398. declare module "babylonjs/Materials/materialHelper" {
  9399. import { Nullable } from "babylonjs/types";
  9400. import { Scene } from "babylonjs/scene";
  9401. import { Engine } from "babylonjs/Engines/engine";
  9402. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9403. import { Light } from "babylonjs/Lights/light";
  9404. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9405. import { Effect, EffectFallbacks, EffectCreationOptions } from "babylonjs/Materials/effect";
  9406. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  9407. /**
  9408. * "Static Class" containing the most commonly used helper while dealing with material for
  9409. * rendering purpose.
  9410. *
  9411. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9412. *
  9413. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9414. */
  9415. export class MaterialHelper {
  9416. /**
  9417. * Bind the current view position to an effect.
  9418. * @param effect The effect to be bound
  9419. * @param scene The scene the eyes position is used from
  9420. */
  9421. static BindEyePosition(effect: Effect, scene: Scene): void;
  9422. /**
  9423. * Helps preparing the defines values about the UVs in used in the effect.
  9424. * UVs are shared as much as we can accross channels in the shaders.
  9425. * @param texture The texture we are preparing the UVs for
  9426. * @param defines The defines to update
  9427. * @param key The channel key "diffuse", "specular"... used in the shader
  9428. */
  9429. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9430. /**
  9431. * Binds a texture matrix value to its corrsponding uniform
  9432. * @param texture The texture to bind the matrix for
  9433. * @param uniformBuffer The uniform buffer receivin the data
  9434. * @param key The channel key "diffuse", "specular"... used in the shader
  9435. */
  9436. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9437. /**
  9438. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9439. * @param mesh defines the current mesh
  9440. * @param scene defines the current scene
  9441. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9442. * @param pointsCloud defines if point cloud rendering has to be turned on
  9443. * @param fogEnabled defines if fog has to be turned on
  9444. * @param alphaTest defines if alpha testing has to be turned on
  9445. * @param defines defines the current list of defines
  9446. */
  9447. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9448. /**
  9449. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9450. * @param scene defines the current scene
  9451. * @param engine defines the current engine
  9452. * @param defines specifies the list of active defines
  9453. * @param useInstances defines if instances have to be turned on
  9454. * @param useClipPlane defines if clip plane have to be turned on
  9455. */
  9456. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9457. /**
  9458. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9459. * @param mesh The mesh containing the geometry data we will draw
  9460. * @param defines The defines to update
  9461. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9462. * @param useBones Precise whether bones should be used or not (override mesh info)
  9463. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9464. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9465. * @returns false if defines are considered not dirty and have not been checked
  9466. */
  9467. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9468. /**
  9469. * Prepares the defines related to multiview
  9470. * @param scene The scene we are intending to draw
  9471. * @param defines The defines to update
  9472. */
  9473. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9474. /**
  9475. * Prepares the defines related to the light information passed in parameter
  9476. * @param scene The scene we are intending to draw
  9477. * @param mesh The mesh the effect is compiling for
  9478. * @param defines The defines to update
  9479. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9480. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9481. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9482. * @returns true if normals will be required for the rest of the effect
  9483. */
  9484. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9485. /**
  9486. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  9487. * that won t be acctive due to defines being turned off.
  9488. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9489. * @param samplersList The samplers list
  9490. * @param defines The defines helping in the list generation
  9491. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9492. */
  9493. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9494. /**
  9495. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9496. * @param defines The defines to update while falling back
  9497. * @param fallbacks The authorized effect fallbacks
  9498. * @param maxSimultaneousLights The maximum number of lights allowed
  9499. * @param rank the current rank of the Effect
  9500. * @returns The newly affected rank
  9501. */
  9502. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9503. /**
  9504. * Prepares the list of attributes required for morph targets according to the effect defines.
  9505. * @param attribs The current list of supported attribs
  9506. * @param mesh The mesh to prepare the morph targets attributes for
  9507. * @param defines The current Defines of the effect
  9508. */
  9509. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9510. /**
  9511. * Prepares the list of attributes required for bones according to the effect defines.
  9512. * @param attribs The current list of supported attribs
  9513. * @param mesh The mesh to prepare the bones attributes for
  9514. * @param defines The current Defines of the effect
  9515. * @param fallbacks The current efffect fallback strategy
  9516. */
  9517. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9518. /**
  9519. * Prepares the list of attributes required for instances according to the effect defines.
  9520. * @param attribs The current list of supported attribs
  9521. * @param defines The current Defines of the effect
  9522. */
  9523. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  9524. /**
  9525. * Binds the light shadow information to the effect for the given mesh.
  9526. * @param light The light containing the generator
  9527. * @param scene The scene the lights belongs to
  9528. * @param mesh The mesh we are binding the information to render
  9529. * @param lightIndex The light index in the effect used to render the mesh
  9530. * @param effect The effect we are binding the data to
  9531. */
  9532. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9533. /**
  9534. * Binds the light information to the effect.
  9535. * @param light The light containing the generator
  9536. * @param effect The effect we are binding the data to
  9537. * @param lightIndex The light index in the effect used to render
  9538. */
  9539. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9540. /**
  9541. * Binds the lights information from the scene to the effect for the given mesh.
  9542. * @param scene The scene the lights belongs to
  9543. * @param mesh The mesh we are binding the information to render
  9544. * @param effect The effect we are binding the data to
  9545. * @param defines The generated defines for the effect
  9546. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9547. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9548. */
  9549. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  9550. private static _tempFogColor;
  9551. /**
  9552. * Binds the fog information from the scene to the effect for the given mesh.
  9553. * @param scene The scene the lights belongs to
  9554. * @param mesh The mesh we are binding the information to render
  9555. * @param effect The effect we are binding the data to
  9556. * @param linearSpace Defines if the fog effect is applied in linear space
  9557. */
  9558. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9559. /**
  9560. * Binds the bones information from the mesh to the effect.
  9561. * @param mesh The mesh we are binding the information to render
  9562. * @param effect The effect we are binding the data to
  9563. */
  9564. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9565. /**
  9566. * Binds the morph targets information from the mesh to the effect.
  9567. * @param abstractMesh The mesh we are binding the information to render
  9568. * @param effect The effect we are binding the data to
  9569. */
  9570. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9571. /**
  9572. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9573. * @param defines The generated defines used in the effect
  9574. * @param effect The effect we are binding the data to
  9575. * @param scene The scene we are willing to render with logarithmic scale for
  9576. */
  9577. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9578. /**
  9579. * Binds the clip plane information from the scene to the effect.
  9580. * @param scene The scene the clip plane information are extracted from
  9581. * @param effect The effect we are binding the data to
  9582. */
  9583. static BindClipPlane(effect: Effect, scene: Scene): void;
  9584. }
  9585. }
  9586. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  9587. /** @hidden */
  9588. export var kernelBlurVaryingDeclaration: {
  9589. name: string;
  9590. shader: string;
  9591. };
  9592. }
  9593. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  9594. /** @hidden */
  9595. export var kernelBlurFragment: {
  9596. name: string;
  9597. shader: string;
  9598. };
  9599. }
  9600. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  9601. /** @hidden */
  9602. export var kernelBlurFragment2: {
  9603. name: string;
  9604. shader: string;
  9605. };
  9606. }
  9607. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  9608. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  9609. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  9610. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  9611. /** @hidden */
  9612. export var kernelBlurPixelShader: {
  9613. name: string;
  9614. shader: string;
  9615. };
  9616. }
  9617. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  9618. /** @hidden */
  9619. export var kernelBlurVertex: {
  9620. name: string;
  9621. shader: string;
  9622. };
  9623. }
  9624. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  9625. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  9626. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  9627. /** @hidden */
  9628. export var kernelBlurVertexShader: {
  9629. name: string;
  9630. shader: string;
  9631. };
  9632. }
  9633. declare module "babylonjs/PostProcesses/blurPostProcess" {
  9634. import { Vector2 } from "babylonjs/Maths/math";
  9635. import { Nullable } from "babylonjs/types";
  9636. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  9637. import { Camera } from "babylonjs/Cameras/camera";
  9638. import { Effect } from "babylonjs/Materials/effect";
  9639. import { Engine } from "babylonjs/Engines/engine";
  9640. import "babylonjs/Shaders/kernelBlur.fragment";
  9641. import "babylonjs/Shaders/kernelBlur.vertex";
  9642. /**
  9643. * The Blur Post Process which blurs an image based on a kernel and direction.
  9644. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  9645. */
  9646. export class BlurPostProcess extends PostProcess {
  9647. /** The direction in which to blur the image. */
  9648. direction: Vector2;
  9649. private blockCompilation;
  9650. protected _kernel: number;
  9651. protected _idealKernel: number;
  9652. protected _packedFloat: boolean;
  9653. private _staticDefines;
  9654. /**
  9655. * Sets the length in pixels of the blur sample region
  9656. */
  9657. /**
  9658. * Gets the length in pixels of the blur sample region
  9659. */
  9660. kernel: number;
  9661. /**
  9662. * Sets wether or not the blur needs to unpack/repack floats
  9663. */
  9664. /**
  9665. * Gets wether or not the blur is unpacking/repacking floats
  9666. */
  9667. packedFloat: boolean;
  9668. /**
  9669. * Creates a new instance BlurPostProcess
  9670. * @param name The name of the effect.
  9671. * @param direction The direction in which to blur the image.
  9672. * @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.
  9673. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  9674. * @param camera The camera to apply the render pass to.
  9675. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  9676. * @param engine The engine which the post process will be applied. (default: current engine)
  9677. * @param reusable If the post process can be reused on the same frame. (default: false)
  9678. * @param textureType Type of textures used when performing the post process. (default: 0)
  9679. * @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)
  9680. */
  9681. constructor(name: string,
  9682. /** The direction in which to blur the image. */
  9683. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  9684. /**
  9685. * Updates the effect with the current post process compile time values and recompiles the shader.
  9686. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  9687. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  9688. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  9689. * @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
  9690. * @param onCompiled Called when the shader has been compiled.
  9691. * @param onError Called if there is an error when compiling a shader.
  9692. */
  9693. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9694. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9695. /**
  9696. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  9697. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  9698. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  9699. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  9700. * The gaps between physical kernels are compensated for in the weighting of the samples
  9701. * @param idealKernel Ideal blur kernel.
  9702. * @return Nearest best kernel.
  9703. */
  9704. protected _nearestBestKernel(idealKernel: number): number;
  9705. /**
  9706. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  9707. * @param x The point on the Gaussian distribution to sample.
  9708. * @return the value of the Gaussian function at x.
  9709. */
  9710. protected _gaussianWeight(x: number): number;
  9711. /**
  9712. * Generates a string that can be used as a floating point number in GLSL.
  9713. * @param x Value to print.
  9714. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  9715. * @return GLSL float string.
  9716. */
  9717. protected _glslFloat(x: number, decimalFigures?: number): string;
  9718. }
  9719. }
  9720. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9721. /** @hidden */
  9722. export var shadowMapPixelShader: {
  9723. name: string;
  9724. shader: string;
  9725. };
  9726. }
  9727. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9728. /** @hidden */
  9729. export var bonesDeclaration: {
  9730. name: string;
  9731. shader: string;
  9732. };
  9733. }
  9734. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9735. /** @hidden */
  9736. export var morphTargetsVertexGlobalDeclaration: {
  9737. name: string;
  9738. shader: string;
  9739. };
  9740. }
  9741. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9742. /** @hidden */
  9743. export var morphTargetsVertexDeclaration: {
  9744. name: string;
  9745. shader: string;
  9746. };
  9747. }
  9748. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9749. /** @hidden */
  9750. export var instancesDeclaration: {
  9751. name: string;
  9752. shader: string;
  9753. };
  9754. }
  9755. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9756. /** @hidden */
  9757. export var helperFunctions: {
  9758. name: string;
  9759. shader: string;
  9760. };
  9761. }
  9762. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9763. /** @hidden */
  9764. export var morphTargetsVertex: {
  9765. name: string;
  9766. shader: string;
  9767. };
  9768. }
  9769. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9770. /** @hidden */
  9771. export var instancesVertex: {
  9772. name: string;
  9773. shader: string;
  9774. };
  9775. }
  9776. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9777. /** @hidden */
  9778. export var bonesVertex: {
  9779. name: string;
  9780. shader: string;
  9781. };
  9782. }
  9783. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9784. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9785. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9786. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9787. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9788. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9789. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9790. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9791. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9792. /** @hidden */
  9793. export var shadowMapVertexShader: {
  9794. name: string;
  9795. shader: string;
  9796. };
  9797. }
  9798. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9799. /** @hidden */
  9800. export var depthBoxBlurPixelShader: {
  9801. name: string;
  9802. shader: string;
  9803. };
  9804. }
  9805. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9806. import { Nullable } from "babylonjs/types";
  9807. import { Scene } from "babylonjs/scene";
  9808. import { Matrix } from "babylonjs/Maths/math";
  9809. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9810. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9811. import { Mesh } from "babylonjs/Meshes/mesh";
  9812. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9813. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9814. import { Effect } from "babylonjs/Materials/effect";
  9815. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9816. import "babylonjs/Shaders/shadowMap.fragment";
  9817. import "babylonjs/Shaders/shadowMap.vertex";
  9818. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9819. import { Observable } from "babylonjs/Misc/observable";
  9820. /**
  9821. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9822. */
  9823. export interface ICustomShaderOptions {
  9824. /**
  9825. * Gets or sets the custom shader name to use
  9826. */
  9827. shaderName: string;
  9828. /**
  9829. * The list of attribute names used in the shader
  9830. */
  9831. attributes?: string[];
  9832. /**
  9833. * The list of unifrom names used in the shader
  9834. */
  9835. uniforms?: string[];
  9836. /**
  9837. * The list of sampler names used in the shader
  9838. */
  9839. samplers?: string[];
  9840. /**
  9841. * The list of defines used in the shader
  9842. */
  9843. defines?: string[];
  9844. }
  9845. /**
  9846. * Interface to implement to create a shadow generator compatible with BJS.
  9847. */
  9848. export interface IShadowGenerator {
  9849. /**
  9850. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9851. * @returns The render target texture if present otherwise, null
  9852. */
  9853. getShadowMap(): Nullable<RenderTargetTexture>;
  9854. /**
  9855. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9856. * @returns The render target texture if the shadow map is present otherwise, null
  9857. */
  9858. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9859. /**
  9860. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9861. * @param subMesh The submesh we want to render in the shadow map
  9862. * @param useInstances Defines wether will draw in the map using instances
  9863. * @returns true if ready otherwise, false
  9864. */
  9865. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9866. /**
  9867. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9868. * @param defines Defines of the material we want to update
  9869. * @param lightIndex Index of the light in the enabled light list of the material
  9870. */
  9871. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9872. /**
  9873. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9874. * defined in the generator but impacting the effect).
  9875. * It implies the unifroms available on the materials are the standard BJS ones.
  9876. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9877. * @param effect The effect we are binfing the information for
  9878. */
  9879. bindShadowLight(lightIndex: string, effect: Effect): void;
  9880. /**
  9881. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9882. * (eq to shadow prjection matrix * light transform matrix)
  9883. * @returns The transform matrix used to create the shadow map
  9884. */
  9885. getTransformMatrix(): Matrix;
  9886. /**
  9887. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9888. * Cube and 2D textures for instance.
  9889. */
  9890. recreateShadowMap(): void;
  9891. /**
  9892. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9893. * @param onCompiled Callback triggered at the and of the effects compilation
  9894. * @param options Sets of optional options forcing the compilation with different modes
  9895. */
  9896. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9897. useInstances: boolean;
  9898. }>): void;
  9899. /**
  9900. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9901. * @param options Sets of optional options forcing the compilation with different modes
  9902. * @returns A promise that resolves when the compilation completes
  9903. */
  9904. forceCompilationAsync(options?: Partial<{
  9905. useInstances: boolean;
  9906. }>): Promise<void>;
  9907. /**
  9908. * Serializes the shadow generator setup to a json object.
  9909. * @returns The serialized JSON object
  9910. */
  9911. serialize(): any;
  9912. /**
  9913. * Disposes the Shadow map and related Textures and effects.
  9914. */
  9915. dispose(): void;
  9916. }
  9917. /**
  9918. * Default implementation IShadowGenerator.
  9919. * This is the main object responsible of generating shadows in the framework.
  9920. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9921. */
  9922. export class ShadowGenerator implements IShadowGenerator {
  9923. /**
  9924. * Shadow generator mode None: no filtering applied.
  9925. */
  9926. static readonly FILTER_NONE: number;
  9927. /**
  9928. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9929. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9930. */
  9931. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9932. /**
  9933. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9934. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9935. */
  9936. static readonly FILTER_POISSONSAMPLING: number;
  9937. /**
  9938. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9939. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9940. */
  9941. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9942. /**
  9943. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9944. * edge artifacts on steep falloff.
  9945. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9946. */
  9947. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9948. /**
  9949. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9950. * edge artifacts on steep falloff.
  9951. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9952. */
  9953. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9954. /**
  9955. * Shadow generator mode PCF: Percentage Closer Filtering
  9956. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9957. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9958. */
  9959. static readonly FILTER_PCF: number;
  9960. /**
  9961. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9962. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9963. * Contact Hardening
  9964. */
  9965. static readonly FILTER_PCSS: number;
  9966. /**
  9967. * Reserved for PCF and PCSS
  9968. * Highest Quality.
  9969. *
  9970. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9971. *
  9972. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9973. */
  9974. static readonly QUALITY_HIGH: number;
  9975. /**
  9976. * Reserved for PCF and PCSS
  9977. * Good tradeoff for quality/perf cross devices
  9978. *
  9979. * Execute PCF on a 3*3 kernel.
  9980. *
  9981. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9982. */
  9983. static readonly QUALITY_MEDIUM: number;
  9984. /**
  9985. * Reserved for PCF and PCSS
  9986. * The lowest quality but the fastest.
  9987. *
  9988. * Execute PCF on a 1*1 kernel.
  9989. *
  9990. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9991. */
  9992. static readonly QUALITY_LOW: number;
  9993. /** Gets or sets the custom shader name to use */
  9994. customShaderOptions: ICustomShaderOptions;
  9995. /**
  9996. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9997. */
  9998. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9999. /**
  10000. * Observable triggered before a mesh is rendered in the shadow map.
  10001. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  10002. */
  10003. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  10004. private _bias;
  10005. /**
  10006. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  10007. */
  10008. /**
  10009. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  10010. */
  10011. bias: number;
  10012. private _normalBias;
  10013. /**
  10014. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  10015. */
  10016. /**
  10017. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  10018. */
  10019. normalBias: number;
  10020. private _blurBoxOffset;
  10021. /**
  10022. * Gets the blur box offset: offset applied during the blur pass.
  10023. * Only useful if useKernelBlur = false
  10024. */
  10025. /**
  10026. * Sets the blur box offset: offset applied during the blur pass.
  10027. * Only useful if useKernelBlur = false
  10028. */
  10029. blurBoxOffset: number;
  10030. private _blurScale;
  10031. /**
  10032. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  10033. * 2 means half of the size.
  10034. */
  10035. /**
  10036. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  10037. * 2 means half of the size.
  10038. */
  10039. blurScale: number;
  10040. private _blurKernel;
  10041. /**
  10042. * Gets the blur kernel: kernel size of the blur pass.
  10043. * Only useful if useKernelBlur = true
  10044. */
  10045. /**
  10046. * Sets the blur kernel: kernel size of the blur pass.
  10047. * Only useful if useKernelBlur = true
  10048. */
  10049. blurKernel: number;
  10050. private _useKernelBlur;
  10051. /**
  10052. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  10053. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  10054. */
  10055. /**
  10056. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  10057. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  10058. */
  10059. useKernelBlur: boolean;
  10060. private _depthScale;
  10061. /**
  10062. * Gets the depth scale used in ESM mode.
  10063. */
  10064. /**
  10065. * Sets the depth scale used in ESM mode.
  10066. * This can override the scale stored on the light.
  10067. */
  10068. depthScale: number;
  10069. private _filter;
  10070. /**
  10071. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  10072. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  10073. */
  10074. /**
  10075. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  10076. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  10077. */
  10078. filter: number;
  10079. /**
  10080. * Gets if the current filter is set to Poisson Sampling.
  10081. */
  10082. /**
  10083. * Sets the current filter to Poisson Sampling.
  10084. */
  10085. usePoissonSampling: boolean;
  10086. /**
  10087. * Gets if the current filter is set to ESM.
  10088. */
  10089. /**
  10090. * Sets the current filter is to ESM.
  10091. */
  10092. useExponentialShadowMap: boolean;
  10093. /**
  10094. * Gets if the current filter is set to filtered ESM.
  10095. */
  10096. /**
  10097. * Gets if the current filter is set to filtered ESM.
  10098. */
  10099. useBlurExponentialShadowMap: boolean;
  10100. /**
  10101. * Gets if the current filter is set to "close ESM" (using the inverse of the
  10102. * exponential to prevent steep falloff artifacts).
  10103. */
  10104. /**
  10105. * Sets the current filter to "close ESM" (using the inverse of the
  10106. * exponential to prevent steep falloff artifacts).
  10107. */
  10108. useCloseExponentialShadowMap: boolean;
  10109. /**
  10110. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  10111. * exponential to prevent steep falloff artifacts).
  10112. */
  10113. /**
  10114. * Sets the current filter to filtered "close ESM" (using the inverse of the
  10115. * exponential to prevent steep falloff artifacts).
  10116. */
  10117. useBlurCloseExponentialShadowMap: boolean;
  10118. /**
  10119. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  10120. */
  10121. /**
  10122. * Sets the current filter to "PCF" (percentage closer filtering).
  10123. */
  10124. usePercentageCloserFiltering: boolean;
  10125. private _filteringQuality;
  10126. /**
  10127. * Gets the PCF or PCSS Quality.
  10128. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  10129. */
  10130. /**
  10131. * Sets the PCF or PCSS Quality.
  10132. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  10133. */
  10134. filteringQuality: number;
  10135. /**
  10136. * Gets if the current filter is set to "PCSS" (contact hardening).
  10137. */
  10138. /**
  10139. * Sets the current filter to "PCSS" (contact hardening).
  10140. */
  10141. useContactHardeningShadow: boolean;
  10142. private _contactHardeningLightSizeUVRatio;
  10143. /**
  10144. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  10145. * Using a ratio helps keeping shape stability independently of the map size.
  10146. *
  10147. * It does not account for the light projection as it was having too much
  10148. * instability during the light setup or during light position changes.
  10149. *
  10150. * Only valid if useContactHardeningShadow is true.
  10151. */
  10152. /**
  10153. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  10154. * Using a ratio helps keeping shape stability independently of the map size.
  10155. *
  10156. * It does not account for the light projection as it was having too much
  10157. * instability during the light setup or during light position changes.
  10158. *
  10159. * Only valid if useContactHardeningShadow is true.
  10160. */
  10161. contactHardeningLightSizeUVRatio: number;
  10162. private _darkness;
  10163. /**
  10164. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  10165. * 0 means strongest and 1 would means no shadow.
  10166. * @returns the darkness.
  10167. */
  10168. getDarkness(): number;
  10169. /**
  10170. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  10171. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  10172. * @returns the shadow generator allowing fluent coding.
  10173. */
  10174. setDarkness(darkness: number): ShadowGenerator;
  10175. private _transparencyShadow;
  10176. /**
  10177. * Sets the ability to have transparent shadow (boolean).
  10178. * @param transparent True if transparent else False
  10179. * @returns the shadow generator allowing fluent coding
  10180. */
  10181. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  10182. private _shadowMap;
  10183. private _shadowMap2;
  10184. /**
  10185. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  10186. * @returns The render target texture if present otherwise, null
  10187. */
  10188. getShadowMap(): Nullable<RenderTargetTexture>;
  10189. /**
  10190. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  10191. * @returns The render target texture if the shadow map is present otherwise, null
  10192. */
  10193. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  10194. /**
  10195. * Helper function to add a mesh and its descendants to the list of shadow casters.
  10196. * @param mesh Mesh to add
  10197. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  10198. * @returns the Shadow Generator itself
  10199. */
  10200. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  10201. /**
  10202. * Helper function to remove a mesh and its descendants from the list of shadow casters
  10203. * @param mesh Mesh to remove
  10204. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  10205. * @returns the Shadow Generator itself
  10206. */
  10207. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  10208. /**
  10209. * Controls the extent to which the shadows fade out at the edge of the frustum
  10210. * Used only by directionals and spots
  10211. */
  10212. frustumEdgeFalloff: number;
  10213. private _light;
  10214. /**
  10215. * Returns the associated light object.
  10216. * @returns the light generating the shadow
  10217. */
  10218. getLight(): IShadowLight;
  10219. /**
  10220. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  10221. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  10222. * It might on the other hand introduce peter panning.
  10223. */
  10224. forceBackFacesOnly: boolean;
  10225. private _scene;
  10226. private _lightDirection;
  10227. private _effect;
  10228. private _viewMatrix;
  10229. private _projectionMatrix;
  10230. private _transformMatrix;
  10231. private _cachedPosition;
  10232. private _cachedDirection;
  10233. private _cachedDefines;
  10234. private _currentRenderID;
  10235. private _boxBlurPostprocess;
  10236. private _kernelBlurXPostprocess;
  10237. private _kernelBlurYPostprocess;
  10238. private _blurPostProcesses;
  10239. private _mapSize;
  10240. private _currentFaceIndex;
  10241. private _currentFaceIndexCache;
  10242. private _textureType;
  10243. private _defaultTextureMatrix;
  10244. /** @hidden */
  10245. static _SceneComponentInitialization: (scene: Scene) => void;
  10246. /**
  10247. * Creates a ShadowGenerator object.
  10248. * A ShadowGenerator is the required tool to use the shadows.
  10249. * Each light casting shadows needs to use its own ShadowGenerator.
  10250. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  10251. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  10252. * @param light The light object generating the shadows.
  10253. * @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.
  10254. */
  10255. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  10256. private _initializeGenerator;
  10257. private _initializeShadowMap;
  10258. private _initializeBlurRTTAndPostProcesses;
  10259. private _renderForShadowMap;
  10260. private _renderSubMeshForShadowMap;
  10261. private _applyFilterValues;
  10262. /**
  10263. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10264. * @param onCompiled Callback triggered at the and of the effects compilation
  10265. * @param options Sets of optional options forcing the compilation with different modes
  10266. */
  10267. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  10268. useInstances: boolean;
  10269. }>): void;
  10270. /**
  10271. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10272. * @param options Sets of optional options forcing the compilation with different modes
  10273. * @returns A promise that resolves when the compilation completes
  10274. */
  10275. forceCompilationAsync(options?: Partial<{
  10276. useInstances: boolean;
  10277. }>): Promise<void>;
  10278. /**
  10279. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  10280. * @param subMesh The submesh we want to render in the shadow map
  10281. * @param useInstances Defines wether will draw in the map using instances
  10282. * @returns true if ready otherwise, false
  10283. */
  10284. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10285. /**
  10286. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  10287. * @param defines Defines of the material we want to update
  10288. * @param lightIndex Index of the light in the enabled light list of the material
  10289. */
  10290. prepareDefines(defines: any, lightIndex: number): void;
  10291. /**
  10292. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  10293. * defined in the generator but impacting the effect).
  10294. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  10295. * @param effect The effect we are binfing the information for
  10296. */
  10297. bindShadowLight(lightIndex: string, effect: Effect): void;
  10298. /**
  10299. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  10300. * (eq to shadow prjection matrix * light transform matrix)
  10301. * @returns The transform matrix used to create the shadow map
  10302. */
  10303. getTransformMatrix(): Matrix;
  10304. /**
  10305. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  10306. * Cube and 2D textures for instance.
  10307. */
  10308. recreateShadowMap(): void;
  10309. private _disposeBlurPostProcesses;
  10310. private _disposeRTTandPostProcesses;
  10311. /**
  10312. * Disposes the ShadowGenerator.
  10313. * Returns nothing.
  10314. */
  10315. dispose(): void;
  10316. /**
  10317. * Serializes the shadow generator setup to a json object.
  10318. * @returns The serialized JSON object
  10319. */
  10320. serialize(): any;
  10321. /**
  10322. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  10323. * @param parsedShadowGenerator The JSON object to parse
  10324. * @param scene The scene to create the shadow map for
  10325. * @returns The parsed shadow generator
  10326. */
  10327. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  10328. }
  10329. }
  10330. declare module "babylonjs/Lights/light" {
  10331. import { Nullable } from "babylonjs/types";
  10332. import { Scene } from "babylonjs/scene";
  10333. import { Vector3, Color3 } from "babylonjs/Maths/math";
  10334. import { Node } from "babylonjs/node";
  10335. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10336. import { Effect } from "babylonjs/Materials/effect";
  10337. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  10338. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  10339. /**
  10340. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  10341. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  10342. * 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.
  10343. */
  10344. export abstract class Light extends Node {
  10345. /**
  10346. * Falloff Default: light is falling off following the material specification:
  10347. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  10348. */
  10349. static readonly FALLOFF_DEFAULT: number;
  10350. /**
  10351. * Falloff Physical: light is falling off following the inverse squared distance law.
  10352. */
  10353. static readonly FALLOFF_PHYSICAL: number;
  10354. /**
  10355. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  10356. * to enhance interoperability with other engines.
  10357. */
  10358. static readonly FALLOFF_GLTF: number;
  10359. /**
  10360. * Falloff Standard: light is falling off like in the standard material
  10361. * to enhance interoperability with other materials.
  10362. */
  10363. static readonly FALLOFF_STANDARD: number;
  10364. /**
  10365. * If every light affecting the material is in this lightmapMode,
  10366. * material.lightmapTexture adds or multiplies
  10367. * (depends on material.useLightmapAsShadowmap)
  10368. * after every other light calculations.
  10369. */
  10370. static readonly LIGHTMAP_DEFAULT: number;
  10371. /**
  10372. * material.lightmapTexture as only diffuse lighting from this light
  10373. * adds only specular lighting from this light
  10374. * adds dynamic shadows
  10375. */
  10376. static readonly LIGHTMAP_SPECULAR: number;
  10377. /**
  10378. * material.lightmapTexture as only lighting
  10379. * no light calculation from this light
  10380. * only adds dynamic shadows from this light
  10381. */
  10382. static readonly LIGHTMAP_SHADOWSONLY: number;
  10383. /**
  10384. * Each light type uses the default quantity according to its type:
  10385. * point/spot lights use luminous intensity
  10386. * directional lights use illuminance
  10387. */
  10388. static readonly INTENSITYMODE_AUTOMATIC: number;
  10389. /**
  10390. * lumen (lm)
  10391. */
  10392. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10393. /**
  10394. * candela (lm/sr)
  10395. */
  10396. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10397. /**
  10398. * lux (lm/m^2)
  10399. */
  10400. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10401. /**
  10402. * nit (cd/m^2)
  10403. */
  10404. static readonly INTENSITYMODE_LUMINANCE: number;
  10405. /**
  10406. * Light type const id of the point light.
  10407. */
  10408. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10409. /**
  10410. * Light type const id of the directional light.
  10411. */
  10412. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10413. /**
  10414. * Light type const id of the spot light.
  10415. */
  10416. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10417. /**
  10418. * Light type const id of the hemispheric light.
  10419. */
  10420. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10421. /**
  10422. * Diffuse gives the basic color to an object.
  10423. */
  10424. diffuse: Color3;
  10425. /**
  10426. * Specular produces a highlight color on an object.
  10427. * Note: This is note affecting PBR materials.
  10428. */
  10429. specular: Color3;
  10430. /**
  10431. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10432. * falling off base on range or angle.
  10433. * This can be set to any values in Light.FALLOFF_x.
  10434. *
  10435. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10436. * other types of materials.
  10437. */
  10438. falloffType: number;
  10439. /**
  10440. * Strength of the light.
  10441. * Note: By default it is define in the framework own unit.
  10442. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10443. */
  10444. intensity: number;
  10445. private _range;
  10446. protected _inverseSquaredRange: number;
  10447. /**
  10448. * Defines how far from the source the light is impacting in scene units.
  10449. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10450. */
  10451. /**
  10452. * Defines how far from the source the light is impacting in scene units.
  10453. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10454. */
  10455. range: number;
  10456. /**
  10457. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10458. * of light.
  10459. */
  10460. private _photometricScale;
  10461. private _intensityMode;
  10462. /**
  10463. * Gets the photometric scale used to interpret the intensity.
  10464. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10465. */
  10466. /**
  10467. * Sets the photometric scale used to interpret the intensity.
  10468. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10469. */
  10470. intensityMode: number;
  10471. private _radius;
  10472. /**
  10473. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10474. */
  10475. /**
  10476. * sets the light radius used by PBR Materials to simulate soft area lights.
  10477. */
  10478. radius: number;
  10479. private _renderPriority;
  10480. /**
  10481. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10482. * exceeding the number allowed of the materials.
  10483. */
  10484. renderPriority: number;
  10485. private _shadowEnabled;
  10486. /**
  10487. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10488. * the current shadow generator.
  10489. */
  10490. /**
  10491. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10492. * the current shadow generator.
  10493. */
  10494. shadowEnabled: boolean;
  10495. private _includedOnlyMeshes;
  10496. /**
  10497. * Gets the only meshes impacted by this light.
  10498. */
  10499. /**
  10500. * Sets the only meshes impacted by this light.
  10501. */
  10502. includedOnlyMeshes: AbstractMesh[];
  10503. private _excludedMeshes;
  10504. /**
  10505. * Gets the meshes not impacted by this light.
  10506. */
  10507. /**
  10508. * Sets the meshes not impacted by this light.
  10509. */
  10510. excludedMeshes: AbstractMesh[];
  10511. private _excludeWithLayerMask;
  10512. /**
  10513. * Gets the layer id use to find what meshes are not impacted by the light.
  10514. * Inactive if 0
  10515. */
  10516. /**
  10517. * Sets the layer id use to find what meshes are not impacted by the light.
  10518. * Inactive if 0
  10519. */
  10520. excludeWithLayerMask: number;
  10521. private _includeOnlyWithLayerMask;
  10522. /**
  10523. * Gets the layer id use to find what meshes are impacted by the light.
  10524. * Inactive if 0
  10525. */
  10526. /**
  10527. * Sets the layer id use to find what meshes are impacted by the light.
  10528. * Inactive if 0
  10529. */
  10530. includeOnlyWithLayerMask: number;
  10531. private _lightmapMode;
  10532. /**
  10533. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10534. */
  10535. /**
  10536. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10537. */
  10538. lightmapMode: number;
  10539. /**
  10540. * Shadow generator associted to the light.
  10541. * @hidden Internal use only.
  10542. */
  10543. _shadowGenerator: Nullable<IShadowGenerator>;
  10544. /**
  10545. * @hidden Internal use only.
  10546. */
  10547. _excludedMeshesIds: string[];
  10548. /**
  10549. * @hidden Internal use only.
  10550. */
  10551. _includedOnlyMeshesIds: string[];
  10552. /**
  10553. * The current light unifom buffer.
  10554. * @hidden Internal use only.
  10555. */
  10556. _uniformBuffer: UniformBuffer;
  10557. /**
  10558. * Creates a Light object in the scene.
  10559. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10560. * @param name The firendly name of the light
  10561. * @param scene The scene the light belongs too
  10562. */
  10563. constructor(name: string, scene: Scene);
  10564. protected abstract _buildUniformLayout(): void;
  10565. /**
  10566. * Sets the passed Effect "effect" with the Light information.
  10567. * @param effect The effect to update
  10568. * @param lightIndex The index of the light in the effect to update
  10569. * @returns The light
  10570. */
  10571. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10572. /**
  10573. * Returns the string "Light".
  10574. * @returns the class name
  10575. */
  10576. getClassName(): string;
  10577. /** @hidden */
  10578. readonly _isLight: boolean;
  10579. /**
  10580. * Converts the light information to a readable string for debug purpose.
  10581. * @param fullDetails Supports for multiple levels of logging within scene loading
  10582. * @returns the human readable light info
  10583. */
  10584. toString(fullDetails?: boolean): string;
  10585. /** @hidden */
  10586. protected _syncParentEnabledState(): void;
  10587. /**
  10588. * Set the enabled state of this node.
  10589. * @param value - the new enabled state
  10590. */
  10591. setEnabled(value: boolean): void;
  10592. /**
  10593. * Returns the Light associated shadow generator if any.
  10594. * @return the associated shadow generator.
  10595. */
  10596. getShadowGenerator(): Nullable<IShadowGenerator>;
  10597. /**
  10598. * Returns a Vector3, the absolute light position in the World.
  10599. * @returns the world space position of the light
  10600. */
  10601. getAbsolutePosition(): Vector3;
  10602. /**
  10603. * Specifies if the light will affect the passed mesh.
  10604. * @param mesh The mesh to test against the light
  10605. * @return true the mesh is affected otherwise, false.
  10606. */
  10607. canAffectMesh(mesh: AbstractMesh): boolean;
  10608. /**
  10609. * Sort function to order lights for rendering.
  10610. * @param a First Light object to compare to second.
  10611. * @param b Second Light object to compare first.
  10612. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10613. */
  10614. static CompareLightsPriority(a: Light, b: Light): number;
  10615. /**
  10616. * Releases resources associated with this node.
  10617. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10618. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10619. */
  10620. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10621. /**
  10622. * Returns the light type ID (integer).
  10623. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10624. */
  10625. getTypeID(): number;
  10626. /**
  10627. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10628. * @returns the scaled intensity in intensity mode unit
  10629. */
  10630. getScaledIntensity(): number;
  10631. /**
  10632. * Returns a new Light object, named "name", from the current one.
  10633. * @param name The name of the cloned light
  10634. * @returns the new created light
  10635. */
  10636. clone(name: string): Nullable<Light>;
  10637. /**
  10638. * Serializes the current light into a Serialization object.
  10639. * @returns the serialized object.
  10640. */
  10641. serialize(): any;
  10642. /**
  10643. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10644. * This new light is named "name" and added to the passed scene.
  10645. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10646. * @param name The friendly name of the light
  10647. * @param scene The scene the new light will belong to
  10648. * @returns the constructor function
  10649. */
  10650. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10651. /**
  10652. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10653. * @param parsedLight The JSON representation of the light
  10654. * @param scene The scene to create the parsed light in
  10655. * @returns the created light after parsing
  10656. */
  10657. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10658. private _hookArrayForExcluded;
  10659. private _hookArrayForIncludedOnly;
  10660. private _resyncMeshes;
  10661. /**
  10662. * Forces the meshes to update their light related information in their rendering used effects
  10663. * @hidden Internal Use Only
  10664. */
  10665. _markMeshesAsLightDirty(): void;
  10666. /**
  10667. * Recomputes the cached photometric scale if needed.
  10668. */
  10669. private _computePhotometricScale;
  10670. /**
  10671. * Returns the Photometric Scale according to the light type and intensity mode.
  10672. */
  10673. private _getPhotometricScale;
  10674. /**
  10675. * Reorder the light in the scene according to their defined priority.
  10676. * @hidden Internal Use Only
  10677. */
  10678. _reorderLightsInScene(): void;
  10679. /**
  10680. * Prepares the list of defines specific to the light type.
  10681. * @param defines the list of defines
  10682. * @param lightIndex defines the index of the light for the effect
  10683. */
  10684. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10685. }
  10686. }
  10687. declare module "babylonjs/Actions/action" {
  10688. import { Observable } from "babylonjs/Misc/observable";
  10689. import { Condition } from "babylonjs/Actions/condition";
  10690. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10691. import { ActionManager } from "babylonjs/Actions/actionManager";
  10692. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10693. /**
  10694. * Interface used to define Action
  10695. */
  10696. export interface IAction {
  10697. /**
  10698. * Trigger for the action
  10699. */
  10700. trigger: number;
  10701. /** Options of the trigger */
  10702. triggerOptions: any;
  10703. /**
  10704. * Gets the trigger parameters
  10705. * @returns the trigger parameters
  10706. */
  10707. getTriggerParameter(): any;
  10708. /**
  10709. * Internal only - executes current action event
  10710. * @hidden
  10711. */
  10712. _executeCurrent(evt?: ActionEvent): void;
  10713. /**
  10714. * Serialize placeholder for child classes
  10715. * @param parent of child
  10716. * @returns the serialized object
  10717. */
  10718. serialize(parent: any): any;
  10719. /**
  10720. * Internal only
  10721. * @hidden
  10722. */
  10723. _prepare(): void;
  10724. /**
  10725. * Internal only - manager for action
  10726. * @hidden
  10727. */
  10728. _actionManager: AbstractActionManager;
  10729. }
  10730. /**
  10731. * The action to be carried out following a trigger
  10732. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10733. */
  10734. export class Action implements IAction {
  10735. /** the trigger, with or without parameters, for the action */
  10736. triggerOptions: any;
  10737. /**
  10738. * Trigger for the action
  10739. */
  10740. trigger: number;
  10741. /**
  10742. * Internal only - manager for action
  10743. * @hidden
  10744. */
  10745. _actionManager: ActionManager;
  10746. private _nextActiveAction;
  10747. private _child;
  10748. private _condition?;
  10749. private _triggerParameter;
  10750. /**
  10751. * An event triggered prior to action being executed.
  10752. */
  10753. onBeforeExecuteObservable: Observable<Action>;
  10754. /**
  10755. * Creates a new Action
  10756. * @param triggerOptions the trigger, with or without parameters, for the action
  10757. * @param condition an optional determinant of action
  10758. */
  10759. constructor(
  10760. /** the trigger, with or without parameters, for the action */
  10761. triggerOptions: any, condition?: Condition);
  10762. /**
  10763. * Internal only
  10764. * @hidden
  10765. */
  10766. _prepare(): void;
  10767. /**
  10768. * Gets the trigger parameters
  10769. * @returns the trigger parameters
  10770. */
  10771. getTriggerParameter(): any;
  10772. /**
  10773. * Internal only - executes current action event
  10774. * @hidden
  10775. */
  10776. _executeCurrent(evt?: ActionEvent): void;
  10777. /**
  10778. * Execute placeholder for child classes
  10779. * @param evt optional action event
  10780. */
  10781. execute(evt?: ActionEvent): void;
  10782. /**
  10783. * Skips to next active action
  10784. */
  10785. skipToNextActiveAction(): void;
  10786. /**
  10787. * Adds action to chain of actions, may be a DoNothingAction
  10788. * @param action defines the next action to execute
  10789. * @returns The action passed in
  10790. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10791. */
  10792. then(action: Action): Action;
  10793. /**
  10794. * Internal only
  10795. * @hidden
  10796. */
  10797. _getProperty(propertyPath: string): string;
  10798. /**
  10799. * Internal only
  10800. * @hidden
  10801. */
  10802. _getEffectiveTarget(target: any, propertyPath: string): any;
  10803. /**
  10804. * Serialize placeholder for child classes
  10805. * @param parent of child
  10806. * @returns the serialized object
  10807. */
  10808. serialize(parent: any): any;
  10809. /**
  10810. * Internal only called by serialize
  10811. * @hidden
  10812. */
  10813. protected _serialize(serializedAction: any, parent?: any): any;
  10814. /**
  10815. * Internal only
  10816. * @hidden
  10817. */
  10818. static _SerializeValueAsString: (value: any) => string;
  10819. /**
  10820. * Internal only
  10821. * @hidden
  10822. */
  10823. static _GetTargetProperty: (target: import("babylonjs/scene").Scene | import("babylonjs/node").Node) => {
  10824. name: string;
  10825. targetType: string;
  10826. value: string;
  10827. };
  10828. }
  10829. }
  10830. declare module "babylonjs/Actions/condition" {
  10831. import { ActionManager } from "babylonjs/Actions/actionManager";
  10832. /**
  10833. * A Condition applied to an Action
  10834. */
  10835. export class Condition {
  10836. /**
  10837. * Internal only - manager for action
  10838. * @hidden
  10839. */
  10840. _actionManager: ActionManager;
  10841. /**
  10842. * Internal only
  10843. * @hidden
  10844. */
  10845. _evaluationId: number;
  10846. /**
  10847. * Internal only
  10848. * @hidden
  10849. */
  10850. _currentResult: boolean;
  10851. /**
  10852. * Creates a new Condition
  10853. * @param actionManager the manager of the action the condition is applied to
  10854. */
  10855. constructor(actionManager: ActionManager);
  10856. /**
  10857. * Check if the current condition is valid
  10858. * @returns a boolean
  10859. */
  10860. isValid(): boolean;
  10861. /**
  10862. * Internal only
  10863. * @hidden
  10864. */
  10865. _getProperty(propertyPath: string): string;
  10866. /**
  10867. * Internal only
  10868. * @hidden
  10869. */
  10870. _getEffectiveTarget(target: any, propertyPath: string): any;
  10871. /**
  10872. * Serialize placeholder for child classes
  10873. * @returns the serialized object
  10874. */
  10875. serialize(): any;
  10876. /**
  10877. * Internal only
  10878. * @hidden
  10879. */
  10880. protected _serialize(serializedCondition: any): any;
  10881. }
  10882. /**
  10883. * Defines specific conditional operators as extensions of Condition
  10884. */
  10885. export class ValueCondition extends Condition {
  10886. /** path to specify the property of the target the conditional operator uses */
  10887. propertyPath: string;
  10888. /** the value compared by the conditional operator against the current value of the property */
  10889. value: any;
  10890. /** the conditional operator, default ValueCondition.IsEqual */
  10891. operator: number;
  10892. /**
  10893. * Internal only
  10894. * @hidden
  10895. */
  10896. private static _IsEqual;
  10897. /**
  10898. * Internal only
  10899. * @hidden
  10900. */
  10901. private static _IsDifferent;
  10902. /**
  10903. * Internal only
  10904. * @hidden
  10905. */
  10906. private static _IsGreater;
  10907. /**
  10908. * Internal only
  10909. * @hidden
  10910. */
  10911. private static _IsLesser;
  10912. /**
  10913. * returns the number for IsEqual
  10914. */
  10915. static readonly IsEqual: number;
  10916. /**
  10917. * Returns the number for IsDifferent
  10918. */
  10919. static readonly IsDifferent: number;
  10920. /**
  10921. * Returns the number for IsGreater
  10922. */
  10923. static readonly IsGreater: number;
  10924. /**
  10925. * Returns the number for IsLesser
  10926. */
  10927. static readonly IsLesser: number;
  10928. /**
  10929. * Internal only The action manager for the condition
  10930. * @hidden
  10931. */
  10932. _actionManager: ActionManager;
  10933. /**
  10934. * Internal only
  10935. * @hidden
  10936. */
  10937. private _target;
  10938. /**
  10939. * Internal only
  10940. * @hidden
  10941. */
  10942. private _effectiveTarget;
  10943. /**
  10944. * Internal only
  10945. * @hidden
  10946. */
  10947. private _property;
  10948. /**
  10949. * Creates a new ValueCondition
  10950. * @param actionManager manager for the action the condition applies to
  10951. * @param target for the action
  10952. * @param propertyPath path to specify the property of the target the conditional operator uses
  10953. * @param value the value compared by the conditional operator against the current value of the property
  10954. * @param operator the conditional operator, default ValueCondition.IsEqual
  10955. */
  10956. constructor(actionManager: ActionManager, target: any,
  10957. /** path to specify the property of the target the conditional operator uses */
  10958. propertyPath: string,
  10959. /** the value compared by the conditional operator against the current value of the property */
  10960. value: any,
  10961. /** the conditional operator, default ValueCondition.IsEqual */
  10962. operator?: number);
  10963. /**
  10964. * Compares the given value with the property value for the specified conditional operator
  10965. * @returns the result of the comparison
  10966. */
  10967. isValid(): boolean;
  10968. /**
  10969. * Serialize the ValueCondition into a JSON compatible object
  10970. * @returns serialization object
  10971. */
  10972. serialize(): any;
  10973. /**
  10974. * Gets the name of the conditional operator for the ValueCondition
  10975. * @param operator the conditional operator
  10976. * @returns the name
  10977. */
  10978. static GetOperatorName(operator: number): string;
  10979. }
  10980. /**
  10981. * Defines a predicate condition as an extension of Condition
  10982. */
  10983. export class PredicateCondition extends Condition {
  10984. /** defines the predicate function used to validate the condition */
  10985. predicate: () => boolean;
  10986. /**
  10987. * Internal only - manager for action
  10988. * @hidden
  10989. */
  10990. _actionManager: ActionManager;
  10991. /**
  10992. * Creates a new PredicateCondition
  10993. * @param actionManager manager for the action the condition applies to
  10994. * @param predicate defines the predicate function used to validate the condition
  10995. */
  10996. constructor(actionManager: ActionManager,
  10997. /** defines the predicate function used to validate the condition */
  10998. predicate: () => boolean);
  10999. /**
  11000. * @returns the validity of the predicate condition
  11001. */
  11002. isValid(): boolean;
  11003. }
  11004. /**
  11005. * Defines a state condition as an extension of Condition
  11006. */
  11007. export class StateCondition extends Condition {
  11008. /** Value to compare with target state */
  11009. value: string;
  11010. /**
  11011. * Internal only - manager for action
  11012. * @hidden
  11013. */
  11014. _actionManager: ActionManager;
  11015. /**
  11016. * Internal only
  11017. * @hidden
  11018. */
  11019. private _target;
  11020. /**
  11021. * Creates a new StateCondition
  11022. * @param actionManager manager for the action the condition applies to
  11023. * @param target of the condition
  11024. * @param value to compare with target state
  11025. */
  11026. constructor(actionManager: ActionManager, target: any,
  11027. /** Value to compare with target state */
  11028. value: string);
  11029. /**
  11030. * Gets a boolean indicating if the current condition is met
  11031. * @returns the validity of the state
  11032. */
  11033. isValid(): boolean;
  11034. /**
  11035. * Serialize the StateCondition into a JSON compatible object
  11036. * @returns serialization object
  11037. */
  11038. serialize(): any;
  11039. }
  11040. }
  11041. declare module "babylonjs/Actions/directActions" {
  11042. import { Action } from "babylonjs/Actions/action";
  11043. import { Condition } from "babylonjs/Actions/condition";
  11044. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  11045. /**
  11046. * This defines an action responsible to toggle a boolean once triggered.
  11047. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11048. */
  11049. export class SwitchBooleanAction extends Action {
  11050. /**
  11051. * The path to the boolean property in the target object
  11052. */
  11053. propertyPath: string;
  11054. private _target;
  11055. private _effectiveTarget;
  11056. private _property;
  11057. /**
  11058. * Instantiate the action
  11059. * @param triggerOptions defines the trigger options
  11060. * @param target defines the object containing the boolean
  11061. * @param propertyPath defines the path to the boolean property in the target object
  11062. * @param condition defines the trigger related conditions
  11063. */
  11064. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  11065. /** @hidden */
  11066. _prepare(): void;
  11067. /**
  11068. * Execute the action toggle the boolean value.
  11069. */
  11070. execute(): void;
  11071. /**
  11072. * Serializes the actions and its related information.
  11073. * @param parent defines the object to serialize in
  11074. * @returns the serialized object
  11075. */
  11076. serialize(parent: any): any;
  11077. }
  11078. /**
  11079. * This defines an action responsible to set a the state field of the target
  11080. * to a desired value once triggered.
  11081. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11082. */
  11083. export class SetStateAction extends Action {
  11084. /**
  11085. * The value to store in the state field.
  11086. */
  11087. value: string;
  11088. private _target;
  11089. /**
  11090. * Instantiate the action
  11091. * @param triggerOptions defines the trigger options
  11092. * @param target defines the object containing the state property
  11093. * @param value defines the value to store in the state field
  11094. * @param condition defines the trigger related conditions
  11095. */
  11096. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  11097. /**
  11098. * Execute the action and store the value on the target state property.
  11099. */
  11100. execute(): void;
  11101. /**
  11102. * Serializes the actions and its related information.
  11103. * @param parent defines the object to serialize in
  11104. * @returns the serialized object
  11105. */
  11106. serialize(parent: any): any;
  11107. }
  11108. /**
  11109. * This defines an action responsible to set a property of the target
  11110. * to a desired value once triggered.
  11111. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11112. */
  11113. export class SetValueAction extends Action {
  11114. /**
  11115. * The path of the property to set in the target.
  11116. */
  11117. propertyPath: string;
  11118. /**
  11119. * The value to set in the property
  11120. */
  11121. value: any;
  11122. private _target;
  11123. private _effectiveTarget;
  11124. private _property;
  11125. /**
  11126. * Instantiate the action
  11127. * @param triggerOptions defines the trigger options
  11128. * @param target defines the object containing the property
  11129. * @param propertyPath defines the path of the property to set in the target
  11130. * @param value defines the value to set in the property
  11131. * @param condition defines the trigger related conditions
  11132. */
  11133. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  11134. /** @hidden */
  11135. _prepare(): void;
  11136. /**
  11137. * Execute the action and set the targetted property to the desired value.
  11138. */
  11139. execute(): void;
  11140. /**
  11141. * Serializes the actions and its related information.
  11142. * @param parent defines the object to serialize in
  11143. * @returns the serialized object
  11144. */
  11145. serialize(parent: any): any;
  11146. }
  11147. /**
  11148. * This defines an action responsible to increment the target value
  11149. * to a desired value once triggered.
  11150. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11151. */
  11152. export class IncrementValueAction extends Action {
  11153. /**
  11154. * The path of the property to increment in the target.
  11155. */
  11156. propertyPath: string;
  11157. /**
  11158. * The value we should increment the property by.
  11159. */
  11160. value: any;
  11161. private _target;
  11162. private _effectiveTarget;
  11163. private _property;
  11164. /**
  11165. * Instantiate the action
  11166. * @param triggerOptions defines the trigger options
  11167. * @param target defines the object containing the property
  11168. * @param propertyPath defines the path of the property to increment in the target
  11169. * @param value defines the value value we should increment the property by
  11170. * @param condition defines the trigger related conditions
  11171. */
  11172. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  11173. /** @hidden */
  11174. _prepare(): void;
  11175. /**
  11176. * Execute the action and increment the target of the value amount.
  11177. */
  11178. execute(): void;
  11179. /**
  11180. * Serializes the actions and its related information.
  11181. * @param parent defines the object to serialize in
  11182. * @returns the serialized object
  11183. */
  11184. serialize(parent: any): any;
  11185. }
  11186. /**
  11187. * This defines an action responsible to start an animation once triggered.
  11188. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11189. */
  11190. export class PlayAnimationAction extends Action {
  11191. /**
  11192. * Where the animation should start (animation frame)
  11193. */
  11194. from: number;
  11195. /**
  11196. * Where the animation should stop (animation frame)
  11197. */
  11198. to: number;
  11199. /**
  11200. * Define if the animation should loop or stop after the first play.
  11201. */
  11202. loop?: boolean;
  11203. private _target;
  11204. /**
  11205. * Instantiate the action
  11206. * @param triggerOptions defines the trigger options
  11207. * @param target defines the target animation or animation name
  11208. * @param from defines from where the animation should start (animation frame)
  11209. * @param end defines where the animation should stop (animation frame)
  11210. * @param loop defines if the animation should loop or stop after the first play
  11211. * @param condition defines the trigger related conditions
  11212. */
  11213. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  11214. /** @hidden */
  11215. _prepare(): void;
  11216. /**
  11217. * Execute the action and play the animation.
  11218. */
  11219. execute(): void;
  11220. /**
  11221. * Serializes the actions and its related information.
  11222. * @param parent defines the object to serialize in
  11223. * @returns the serialized object
  11224. */
  11225. serialize(parent: any): any;
  11226. }
  11227. /**
  11228. * This defines an action responsible to stop an animation once triggered.
  11229. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11230. */
  11231. export class StopAnimationAction extends Action {
  11232. private _target;
  11233. /**
  11234. * Instantiate the action
  11235. * @param triggerOptions defines the trigger options
  11236. * @param target defines the target animation or animation name
  11237. * @param condition defines the trigger related conditions
  11238. */
  11239. constructor(triggerOptions: any, target: any, condition?: Condition);
  11240. /** @hidden */
  11241. _prepare(): void;
  11242. /**
  11243. * Execute the action and stop the animation.
  11244. */
  11245. execute(): void;
  11246. /**
  11247. * Serializes the actions and its related information.
  11248. * @param parent defines the object to serialize in
  11249. * @returns the serialized object
  11250. */
  11251. serialize(parent: any): any;
  11252. }
  11253. /**
  11254. * This defines an action responsible that does nothing once triggered.
  11255. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11256. */
  11257. export class DoNothingAction extends Action {
  11258. /**
  11259. * Instantiate the action
  11260. * @param triggerOptions defines the trigger options
  11261. * @param condition defines the trigger related conditions
  11262. */
  11263. constructor(triggerOptions?: any, condition?: Condition);
  11264. /**
  11265. * Execute the action and do nothing.
  11266. */
  11267. execute(): void;
  11268. /**
  11269. * Serializes the actions and its related information.
  11270. * @param parent defines the object to serialize in
  11271. * @returns the serialized object
  11272. */
  11273. serialize(parent: any): any;
  11274. }
  11275. /**
  11276. * This defines an action responsible to trigger several actions once triggered.
  11277. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11278. */
  11279. export class CombineAction extends Action {
  11280. /**
  11281. * The list of aggregated animations to run.
  11282. */
  11283. children: Action[];
  11284. /**
  11285. * Instantiate the action
  11286. * @param triggerOptions defines the trigger options
  11287. * @param children defines the list of aggregated animations to run
  11288. * @param condition defines the trigger related conditions
  11289. */
  11290. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  11291. /** @hidden */
  11292. _prepare(): void;
  11293. /**
  11294. * Execute the action and executes all the aggregated actions.
  11295. */
  11296. execute(evt: ActionEvent): void;
  11297. /**
  11298. * Serializes the actions and its related information.
  11299. * @param parent defines the object to serialize in
  11300. * @returns the serialized object
  11301. */
  11302. serialize(parent: any): any;
  11303. }
  11304. /**
  11305. * This defines an action responsible to run code (external event) once triggered.
  11306. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11307. */
  11308. export class ExecuteCodeAction extends Action {
  11309. /**
  11310. * The callback function to run.
  11311. */
  11312. func: (evt: ActionEvent) => void;
  11313. /**
  11314. * Instantiate the action
  11315. * @param triggerOptions defines the trigger options
  11316. * @param func defines the callback function to run
  11317. * @param condition defines the trigger related conditions
  11318. */
  11319. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  11320. /**
  11321. * Execute the action and run the attached code.
  11322. */
  11323. execute(evt: ActionEvent): void;
  11324. }
  11325. /**
  11326. * This defines an action responsible to set the parent property of the target once triggered.
  11327. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11328. */
  11329. export class SetParentAction extends Action {
  11330. private _parent;
  11331. private _target;
  11332. /**
  11333. * Instantiate the action
  11334. * @param triggerOptions defines the trigger options
  11335. * @param target defines the target containing the parent property
  11336. * @param parent defines from where the animation should start (animation frame)
  11337. * @param condition defines the trigger related conditions
  11338. */
  11339. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  11340. /** @hidden */
  11341. _prepare(): void;
  11342. /**
  11343. * Execute the action and set the parent property.
  11344. */
  11345. execute(): void;
  11346. /**
  11347. * Serializes the actions and its related information.
  11348. * @param parent defines the object to serialize in
  11349. * @returns the serialized object
  11350. */
  11351. serialize(parent: any): any;
  11352. }
  11353. }
  11354. declare module "babylonjs/Actions/actionManager" {
  11355. import { Nullable } from "babylonjs/types";
  11356. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11357. import { Scene } from "babylonjs/scene";
  11358. import { IAction } from "babylonjs/Actions/action";
  11359. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  11360. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  11361. /**
  11362. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  11363. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  11364. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11365. */
  11366. export class ActionManager extends AbstractActionManager {
  11367. /**
  11368. * Nothing
  11369. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11370. */
  11371. static readonly NothingTrigger: number;
  11372. /**
  11373. * On pick
  11374. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11375. */
  11376. static readonly OnPickTrigger: number;
  11377. /**
  11378. * On left pick
  11379. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11380. */
  11381. static readonly OnLeftPickTrigger: number;
  11382. /**
  11383. * On right pick
  11384. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11385. */
  11386. static readonly OnRightPickTrigger: number;
  11387. /**
  11388. * On center pick
  11389. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11390. */
  11391. static readonly OnCenterPickTrigger: number;
  11392. /**
  11393. * On pick down
  11394. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11395. */
  11396. static readonly OnPickDownTrigger: number;
  11397. /**
  11398. * On double pick
  11399. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11400. */
  11401. static readonly OnDoublePickTrigger: number;
  11402. /**
  11403. * On pick up
  11404. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11405. */
  11406. static readonly OnPickUpTrigger: number;
  11407. /**
  11408. * On pick out.
  11409. * This trigger will only be raised if you also declared a OnPickDown
  11410. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11411. */
  11412. static readonly OnPickOutTrigger: number;
  11413. /**
  11414. * On long press
  11415. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11416. */
  11417. static readonly OnLongPressTrigger: number;
  11418. /**
  11419. * On pointer over
  11420. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11421. */
  11422. static readonly OnPointerOverTrigger: number;
  11423. /**
  11424. * On pointer out
  11425. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11426. */
  11427. static readonly OnPointerOutTrigger: number;
  11428. /**
  11429. * On every frame
  11430. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11431. */
  11432. static readonly OnEveryFrameTrigger: number;
  11433. /**
  11434. * On intersection enter
  11435. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11436. */
  11437. static readonly OnIntersectionEnterTrigger: number;
  11438. /**
  11439. * On intersection exit
  11440. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11441. */
  11442. static readonly OnIntersectionExitTrigger: number;
  11443. /**
  11444. * On key down
  11445. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11446. */
  11447. static readonly OnKeyDownTrigger: number;
  11448. /**
  11449. * On key up
  11450. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11451. */
  11452. static readonly OnKeyUpTrigger: number;
  11453. private _scene;
  11454. /**
  11455. * Creates a new action manager
  11456. * @param scene defines the hosting scene
  11457. */
  11458. constructor(scene: Scene);
  11459. /**
  11460. * Releases all associated resources
  11461. */
  11462. dispose(): void;
  11463. /**
  11464. * Gets hosting scene
  11465. * @returns the hosting scene
  11466. */
  11467. getScene(): Scene;
  11468. /**
  11469. * Does this action manager handles actions of any of the given triggers
  11470. * @param triggers defines the triggers to be tested
  11471. * @return a boolean indicating whether one (or more) of the triggers is handled
  11472. */
  11473. hasSpecificTriggers(triggers: number[]): boolean;
  11474. /**
  11475. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11476. * speed.
  11477. * @param triggerA defines the trigger to be tested
  11478. * @param triggerB defines the trigger to be tested
  11479. * @return a boolean indicating whether one (or more) of the triggers is handled
  11480. */
  11481. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11482. /**
  11483. * Does this action manager handles actions of a given trigger
  11484. * @param trigger defines the trigger to be tested
  11485. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11486. * @return whether the trigger is handled
  11487. */
  11488. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11489. /**
  11490. * Does this action manager has pointer triggers
  11491. */
  11492. readonly hasPointerTriggers: boolean;
  11493. /**
  11494. * Does this action manager has pick triggers
  11495. */
  11496. readonly hasPickTriggers: boolean;
  11497. /**
  11498. * Registers an action to this action manager
  11499. * @param action defines the action to be registered
  11500. * @return the action amended (prepared) after registration
  11501. */
  11502. registerAction(action: IAction): Nullable<IAction>;
  11503. /**
  11504. * Unregisters an action to this action manager
  11505. * @param action defines the action to be unregistered
  11506. * @return a boolean indicating whether the action has been unregistered
  11507. */
  11508. unregisterAction(action: IAction): Boolean;
  11509. /**
  11510. * Process a specific trigger
  11511. * @param trigger defines the trigger to process
  11512. * @param evt defines the event details to be processed
  11513. */
  11514. processTrigger(trigger: number, evt?: IActionEvent): void;
  11515. /** @hidden */
  11516. _getEffectiveTarget(target: any, propertyPath: string): any;
  11517. /** @hidden */
  11518. _getProperty(propertyPath: string): string;
  11519. /**
  11520. * Serialize this manager to a JSON object
  11521. * @param name defines the property name to store this manager
  11522. * @returns a JSON representation of this manager
  11523. */
  11524. serialize(name: string): any;
  11525. /**
  11526. * Creates a new ActionManager from a JSON data
  11527. * @param parsedActions defines the JSON data to read from
  11528. * @param object defines the hosting mesh
  11529. * @param scene defines the hosting scene
  11530. */
  11531. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11532. /**
  11533. * Get a trigger name by index
  11534. * @param trigger defines the trigger index
  11535. * @returns a trigger name
  11536. */
  11537. static GetTriggerName(trigger: number): string;
  11538. }
  11539. }
  11540. declare module "babylonjs/Culling/ray" {
  11541. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  11542. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  11543. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11544. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11545. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  11546. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  11547. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  11548. /**
  11549. * Class representing a ray with position and direction
  11550. */
  11551. export class Ray {
  11552. /** origin point */
  11553. origin: Vector3;
  11554. /** direction */
  11555. direction: Vector3;
  11556. /** length of the ray */
  11557. length: number;
  11558. private static readonly TmpVector3;
  11559. private _tmpRay;
  11560. /**
  11561. * Creates a new ray
  11562. * @param origin origin point
  11563. * @param direction direction
  11564. * @param length length of the ray
  11565. */
  11566. constructor(
  11567. /** origin point */
  11568. origin: Vector3,
  11569. /** direction */
  11570. direction: Vector3,
  11571. /** length of the ray */
  11572. length?: number);
  11573. /**
  11574. * Checks if the ray intersects a box
  11575. * @param minimum bound of the box
  11576. * @param maximum bound of the box
  11577. * @param intersectionTreshold extra extend to be added to the box in all direction
  11578. * @returns if the box was hit
  11579. */
  11580. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11581. /**
  11582. * Checks if the ray intersects a box
  11583. * @param box the bounding box to check
  11584. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11585. * @returns if the box was hit
  11586. */
  11587. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11588. /**
  11589. * If the ray hits a sphere
  11590. * @param sphere the bounding sphere to check
  11591. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11592. * @returns true if it hits the sphere
  11593. */
  11594. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11595. /**
  11596. * If the ray hits a triange
  11597. * @param vertex0 triangle vertex
  11598. * @param vertex1 triangle vertex
  11599. * @param vertex2 triangle vertex
  11600. * @returns intersection information if hit
  11601. */
  11602. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11603. /**
  11604. * Checks if ray intersects a plane
  11605. * @param plane the plane to check
  11606. * @returns the distance away it was hit
  11607. */
  11608. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11609. /**
  11610. * Checks if ray intersects a mesh
  11611. * @param mesh the mesh to check
  11612. * @param fastCheck if only the bounding box should checked
  11613. * @returns picking info of the intersecton
  11614. */
  11615. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11616. /**
  11617. * Checks if ray intersects a mesh
  11618. * @param meshes the meshes to check
  11619. * @param fastCheck if only the bounding box should checked
  11620. * @param results array to store result in
  11621. * @returns Array of picking infos
  11622. */
  11623. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11624. private _comparePickingInfo;
  11625. private static smallnum;
  11626. private static rayl;
  11627. /**
  11628. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11629. * @param sega the first point of the segment to test the intersection against
  11630. * @param segb the second point of the segment to test the intersection against
  11631. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11632. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11633. */
  11634. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11635. /**
  11636. * Update the ray from viewport position
  11637. * @param x position
  11638. * @param y y position
  11639. * @param viewportWidth viewport width
  11640. * @param viewportHeight viewport height
  11641. * @param world world matrix
  11642. * @param view view matrix
  11643. * @param projection projection matrix
  11644. * @returns this ray updated
  11645. */
  11646. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11647. /**
  11648. * Creates a ray with origin and direction of 0,0,0
  11649. * @returns the new ray
  11650. */
  11651. static Zero(): Ray;
  11652. /**
  11653. * Creates a new ray from screen space and viewport
  11654. * @param x position
  11655. * @param y y position
  11656. * @param viewportWidth viewport width
  11657. * @param viewportHeight viewport height
  11658. * @param world world matrix
  11659. * @param view view matrix
  11660. * @param projection projection matrix
  11661. * @returns new ray
  11662. */
  11663. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11664. /**
  11665. * 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
  11666. * transformed to the given world matrix.
  11667. * @param origin The origin point
  11668. * @param end The end point
  11669. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11670. * @returns the new ray
  11671. */
  11672. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11673. /**
  11674. * Transforms a ray by a matrix
  11675. * @param ray ray to transform
  11676. * @param matrix matrix to apply
  11677. * @returns the resulting new ray
  11678. */
  11679. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11680. /**
  11681. * Transforms a ray by a matrix
  11682. * @param ray ray to transform
  11683. * @param matrix matrix to apply
  11684. * @param result ray to store result in
  11685. */
  11686. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11687. /**
  11688. * Unproject a ray from screen space to object space
  11689. * @param sourceX defines the screen space x coordinate to use
  11690. * @param sourceY defines the screen space y coordinate to use
  11691. * @param viewportWidth defines the current width of the viewport
  11692. * @param viewportHeight defines the current height of the viewport
  11693. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11694. * @param view defines the view matrix to use
  11695. * @param projection defines the projection matrix to use
  11696. */
  11697. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11698. }
  11699. /**
  11700. * Type used to define predicate used to select faces when a mesh intersection is detected
  11701. */
  11702. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11703. module "babylonjs/scene" {
  11704. interface Scene {
  11705. /** @hidden */
  11706. _tempPickingRay: Nullable<Ray>;
  11707. /** @hidden */
  11708. _cachedRayForTransform: Ray;
  11709. /** @hidden */
  11710. _pickWithRayInverseMatrix: Matrix;
  11711. /** @hidden */
  11712. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11713. /** @hidden */
  11714. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11715. }
  11716. }
  11717. }
  11718. declare module "babylonjs/sceneComponent" {
  11719. import { Scene } from "babylonjs/scene";
  11720. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11721. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11722. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11723. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11724. import { Nullable } from "babylonjs/types";
  11725. import { Camera } from "babylonjs/Cameras/camera";
  11726. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11727. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11728. import { AbstractScene } from "babylonjs/abstractScene";
  11729. /**
  11730. * Groups all the scene component constants in one place to ease maintenance.
  11731. * @hidden
  11732. */
  11733. export class SceneComponentConstants {
  11734. static readonly NAME_EFFECTLAYER: string;
  11735. static readonly NAME_LAYER: string;
  11736. static readonly NAME_LENSFLARESYSTEM: string;
  11737. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11738. static readonly NAME_PARTICLESYSTEM: string;
  11739. static readonly NAME_GAMEPAD: string;
  11740. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11741. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11742. static readonly NAME_DEPTHRENDERER: string;
  11743. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11744. static readonly NAME_SPRITE: string;
  11745. static readonly NAME_OUTLINERENDERER: string;
  11746. static readonly NAME_PROCEDURALTEXTURE: string;
  11747. static readonly NAME_SHADOWGENERATOR: string;
  11748. static readonly NAME_OCTREE: string;
  11749. static readonly NAME_PHYSICSENGINE: string;
  11750. static readonly NAME_AUDIO: string;
  11751. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11752. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11753. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11754. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11755. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11756. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11757. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11758. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11759. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11760. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11761. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11762. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11763. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11764. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11765. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11766. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11767. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11768. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11769. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11770. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11771. static readonly STEP_AFTERRENDER_AUDIO: number;
  11772. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11773. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11774. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11775. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11776. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11777. static readonly STEP_POINTERMOVE_SPRITE: number;
  11778. static readonly STEP_POINTERDOWN_SPRITE: number;
  11779. static readonly STEP_POINTERUP_SPRITE: number;
  11780. }
  11781. /**
  11782. * This represents a scene component.
  11783. *
  11784. * This is used to decouple the dependency the scene is having on the different workloads like
  11785. * layers, post processes...
  11786. */
  11787. export interface ISceneComponent {
  11788. /**
  11789. * The name of the component. Each component must have a unique name.
  11790. */
  11791. name: string;
  11792. /**
  11793. * The scene the component belongs to.
  11794. */
  11795. scene: Scene;
  11796. /**
  11797. * Register the component to one instance of a scene.
  11798. */
  11799. register(): void;
  11800. /**
  11801. * Rebuilds the elements related to this component in case of
  11802. * context lost for instance.
  11803. */
  11804. rebuild(): void;
  11805. /**
  11806. * Disposes the component and the associated ressources.
  11807. */
  11808. dispose(): void;
  11809. }
  11810. /**
  11811. * This represents a SERIALIZABLE scene component.
  11812. *
  11813. * This extends Scene Component to add Serialization methods on top.
  11814. */
  11815. export interface ISceneSerializableComponent extends ISceneComponent {
  11816. /**
  11817. * Adds all the element from the container to the scene
  11818. * @param container the container holding the elements
  11819. */
  11820. addFromContainer(container: AbstractScene): void;
  11821. /**
  11822. * Removes all the elements in the container from the scene
  11823. * @param container contains the elements to remove
  11824. * @param dispose if the removed element should be disposed (default: false)
  11825. */
  11826. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11827. /**
  11828. * Serializes the component data to the specified json object
  11829. * @param serializationObject The object to serialize to
  11830. */
  11831. serialize(serializationObject: any): void;
  11832. }
  11833. /**
  11834. * Strong typing of a Mesh related stage step action
  11835. */
  11836. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11837. /**
  11838. * Strong typing of a Evaluate Sub Mesh related stage step action
  11839. */
  11840. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11841. /**
  11842. * Strong typing of a Active Mesh related stage step action
  11843. */
  11844. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11845. /**
  11846. * Strong typing of a Camera related stage step action
  11847. */
  11848. export type CameraStageAction = (camera: Camera) => void;
  11849. /**
  11850. * Strong typing of a Camera Frame buffer related stage step action
  11851. */
  11852. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11853. /**
  11854. * Strong typing of a Render Target related stage step action
  11855. */
  11856. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11857. /**
  11858. * Strong typing of a RenderingGroup related stage step action
  11859. */
  11860. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11861. /**
  11862. * Strong typing of a Mesh Render related stage step action
  11863. */
  11864. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11865. /**
  11866. * Strong typing of a simple stage step action
  11867. */
  11868. export type SimpleStageAction = () => void;
  11869. /**
  11870. * Strong typing of a render target action.
  11871. */
  11872. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11873. /**
  11874. * Strong typing of a pointer move action.
  11875. */
  11876. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11877. /**
  11878. * Strong typing of a pointer up/down action.
  11879. */
  11880. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11881. /**
  11882. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11883. * @hidden
  11884. */
  11885. export class Stage<T extends Function> extends Array<{
  11886. index: number;
  11887. component: ISceneComponent;
  11888. action: T;
  11889. }> {
  11890. /**
  11891. * Hide ctor from the rest of the world.
  11892. * @param items The items to add.
  11893. */
  11894. private constructor();
  11895. /**
  11896. * Creates a new Stage.
  11897. * @returns A new instance of a Stage
  11898. */
  11899. static Create<T extends Function>(): Stage<T>;
  11900. /**
  11901. * Registers a step in an ordered way in the targeted stage.
  11902. * @param index Defines the position to register the step in
  11903. * @param component Defines the component attached to the step
  11904. * @param action Defines the action to launch during the step
  11905. */
  11906. registerStep(index: number, component: ISceneComponent, action: T): void;
  11907. /**
  11908. * Clears all the steps from the stage.
  11909. */
  11910. clear(): void;
  11911. }
  11912. }
  11913. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11914. import { Nullable } from "babylonjs/types";
  11915. import { Observable } from "babylonjs/Misc/observable";
  11916. import { Scene } from "babylonjs/scene";
  11917. import { Sprite } from "babylonjs/Sprites/sprite";
  11918. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11919. import { Ray } from "babylonjs/Culling/ray";
  11920. import { Camera } from "babylonjs/Cameras/camera";
  11921. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11922. import { ISceneComponent } from "babylonjs/sceneComponent";
  11923. module "babylonjs/scene" {
  11924. interface Scene {
  11925. /** @hidden */
  11926. _pointerOverSprite: Nullable<Sprite>;
  11927. /** @hidden */
  11928. _pickedDownSprite: Nullable<Sprite>;
  11929. /** @hidden */
  11930. _tempSpritePickingRay: Nullable<Ray>;
  11931. /**
  11932. * All of the sprite managers added to this scene
  11933. * @see http://doc.babylonjs.com/babylon101/sprites
  11934. */
  11935. spriteManagers: Array<ISpriteManager>;
  11936. /**
  11937. * An event triggered when sprites rendering is about to start
  11938. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11939. */
  11940. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11941. /**
  11942. * An event triggered when sprites rendering is done
  11943. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11944. */
  11945. onAfterSpritesRenderingObservable: Observable<Scene>;
  11946. /** @hidden */
  11947. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11948. /** Launch a ray to try to pick a sprite in the scene
  11949. * @param x position on screen
  11950. * @param y position on screen
  11951. * @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
  11952. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11953. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11954. * @returns a PickingInfo
  11955. */
  11956. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11957. /** Use the given ray to pick a sprite in the scene
  11958. * @param ray The ray (in world space) to use to pick meshes
  11959. * @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
  11960. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11961. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11962. * @returns a PickingInfo
  11963. */
  11964. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11965. /**
  11966. * Force the sprite under the pointer
  11967. * @param sprite defines the sprite to use
  11968. */
  11969. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11970. /**
  11971. * Gets the sprite under the pointer
  11972. * @returns a Sprite or null if no sprite is under the pointer
  11973. */
  11974. getPointerOverSprite(): Nullable<Sprite>;
  11975. }
  11976. }
  11977. /**
  11978. * Defines the sprite scene component responsible to manage sprites
  11979. * in a given scene.
  11980. */
  11981. export class SpriteSceneComponent implements ISceneComponent {
  11982. /**
  11983. * The component name helpfull to identify the component in the list of scene components.
  11984. */
  11985. readonly name: string;
  11986. /**
  11987. * The scene the component belongs to.
  11988. */
  11989. scene: Scene;
  11990. /** @hidden */
  11991. private _spritePredicate;
  11992. /**
  11993. * Creates a new instance of the component for the given scene
  11994. * @param scene Defines the scene to register the component in
  11995. */
  11996. constructor(scene: Scene);
  11997. /**
  11998. * Registers the component in a given scene
  11999. */
  12000. register(): void;
  12001. /**
  12002. * Rebuilds the elements related to this component in case of
  12003. * context lost for instance.
  12004. */
  12005. rebuild(): void;
  12006. /**
  12007. * Disposes the component and the associated ressources.
  12008. */
  12009. dispose(): void;
  12010. private _pickSpriteButKeepRay;
  12011. private _pointerMove;
  12012. private _pointerDown;
  12013. private _pointerUp;
  12014. }
  12015. }
  12016. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  12017. /** @hidden */
  12018. export var fogFragmentDeclaration: {
  12019. name: string;
  12020. shader: string;
  12021. };
  12022. }
  12023. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  12024. /** @hidden */
  12025. export var fogFragment: {
  12026. name: string;
  12027. shader: string;
  12028. };
  12029. }
  12030. declare module "babylonjs/Shaders/sprites.fragment" {
  12031. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  12032. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  12033. /** @hidden */
  12034. export var spritesPixelShader: {
  12035. name: string;
  12036. shader: string;
  12037. };
  12038. }
  12039. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  12040. /** @hidden */
  12041. export var fogVertexDeclaration: {
  12042. name: string;
  12043. shader: string;
  12044. };
  12045. }
  12046. declare module "babylonjs/Shaders/sprites.vertex" {
  12047. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  12048. /** @hidden */
  12049. export var spritesVertexShader: {
  12050. name: string;
  12051. shader: string;
  12052. };
  12053. }
  12054. declare module "babylonjs/Sprites/spriteManager" {
  12055. import { IDisposable, Scene } from "babylonjs/scene";
  12056. import { Nullable } from "babylonjs/types";
  12057. import { Observable } from "babylonjs/Misc/observable";
  12058. import { Sprite } from "babylonjs/Sprites/sprite";
  12059. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  12060. import { Camera } from "babylonjs/Cameras/camera";
  12061. import { Texture } from "babylonjs/Materials/Textures/texture";
  12062. import "babylonjs/Shaders/sprites.fragment";
  12063. import "babylonjs/Shaders/sprites.vertex";
  12064. import { Ray } from "babylonjs/Culling/ray";
  12065. /**
  12066. * Defines the minimum interface to fullfil in order to be a sprite manager.
  12067. */
  12068. export interface ISpriteManager extends IDisposable {
  12069. /**
  12070. * Restricts the camera to viewing objects with the same layerMask.
  12071. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  12072. */
  12073. layerMask: number;
  12074. /**
  12075. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  12076. */
  12077. isPickable: boolean;
  12078. /**
  12079. * Specifies the rendering group id for this mesh (0 by default)
  12080. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  12081. */
  12082. renderingGroupId: number;
  12083. /**
  12084. * Defines the list of sprites managed by the manager.
  12085. */
  12086. sprites: Array<Sprite>;
  12087. /**
  12088. * Tests the intersection of a sprite with a specific ray.
  12089. * @param ray The ray we are sending to test the collision
  12090. * @param camera The camera space we are sending rays in
  12091. * @param predicate A predicate allowing excluding sprites from the list of object to test
  12092. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  12093. * @returns picking info or null.
  12094. */
  12095. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  12096. /**
  12097. * Renders the list of sprites on screen.
  12098. */
  12099. render(): void;
  12100. }
  12101. /**
  12102. * Class used to manage multiple sprites on the same spritesheet
  12103. * @see http://doc.babylonjs.com/babylon101/sprites
  12104. */
  12105. export class SpriteManager implements ISpriteManager {
  12106. /** defines the manager's name */
  12107. name: string;
  12108. /** Gets the list of sprites */
  12109. sprites: Sprite[];
  12110. /** Gets or sets the rendering group id (0 by default) */
  12111. renderingGroupId: number;
  12112. /** Gets or sets camera layer mask */
  12113. layerMask: number;
  12114. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  12115. fogEnabled: boolean;
  12116. /** Gets or sets a boolean indicating if the sprites are pickable */
  12117. isPickable: boolean;
  12118. /** Defines the default width of a cell in the spritesheet */
  12119. cellWidth: number;
  12120. /** Defines the default height of a cell in the spritesheet */
  12121. cellHeight: number;
  12122. /**
  12123. * An event triggered when the manager is disposed.
  12124. */
  12125. onDisposeObservable: Observable<SpriteManager>;
  12126. private _onDisposeObserver;
  12127. /**
  12128. * Callback called when the manager is disposed
  12129. */
  12130. onDispose: () => void;
  12131. private _capacity;
  12132. private _spriteTexture;
  12133. private _epsilon;
  12134. private _scene;
  12135. private _vertexData;
  12136. private _buffer;
  12137. private _vertexBuffers;
  12138. private _indexBuffer;
  12139. private _effectBase;
  12140. private _effectFog;
  12141. /**
  12142. * Gets or sets the spritesheet texture
  12143. */
  12144. texture: Texture;
  12145. /**
  12146. * Creates a new sprite manager
  12147. * @param name defines the manager's name
  12148. * @param imgUrl defines the sprite sheet url
  12149. * @param capacity defines the maximum allowed number of sprites
  12150. * @param cellSize defines the size of a sprite cell
  12151. * @param scene defines the hosting scene
  12152. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  12153. * @param samplingMode defines the smapling mode to use with spritesheet
  12154. */
  12155. constructor(
  12156. /** defines the manager's name */
  12157. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  12158. private _appendSpriteVertex;
  12159. /**
  12160. * Intersects the sprites with a ray
  12161. * @param ray defines the ray to intersect with
  12162. * @param camera defines the current active camera
  12163. * @param predicate defines a predicate used to select candidate sprites
  12164. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  12165. * @returns null if no hit or a PickingInfo
  12166. */
  12167. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  12168. /**
  12169. * Render all child sprites
  12170. */
  12171. render(): void;
  12172. /**
  12173. * Release associated resources
  12174. */
  12175. dispose(): void;
  12176. }
  12177. }
  12178. declare module "babylonjs/Sprites/sprite" {
  12179. import { Vector3, Color4 } from "babylonjs/Maths/math";
  12180. import { Nullable } from "babylonjs/types";
  12181. import { ActionManager } from "babylonjs/Actions/actionManager";
  12182. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  12183. /**
  12184. * Class used to represent a sprite
  12185. * @see http://doc.babylonjs.com/babylon101/sprites
  12186. */
  12187. export class Sprite {
  12188. /** defines the name */
  12189. name: string;
  12190. /** Gets or sets the current world position */
  12191. position: Vector3;
  12192. /** Gets or sets the main color */
  12193. color: Color4;
  12194. /** Gets or sets the width */
  12195. width: number;
  12196. /** Gets or sets the height */
  12197. height: number;
  12198. /** Gets or sets rotation angle */
  12199. angle: number;
  12200. /** Gets or sets the cell index in the sprite sheet */
  12201. cellIndex: number;
  12202. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  12203. invertU: number;
  12204. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  12205. invertV: number;
  12206. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  12207. disposeWhenFinishedAnimating: boolean;
  12208. /** Gets the list of attached animations */
  12209. animations: Animation[];
  12210. /** Gets or sets a boolean indicating if the sprite can be picked */
  12211. isPickable: boolean;
  12212. /**
  12213. * Gets or sets the associated action manager
  12214. */
  12215. actionManager: Nullable<ActionManager>;
  12216. private _animationStarted;
  12217. private _loopAnimation;
  12218. private _fromIndex;
  12219. private _toIndex;
  12220. private _delay;
  12221. private _direction;
  12222. private _manager;
  12223. private _time;
  12224. private _onAnimationEnd;
  12225. /**
  12226. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  12227. */
  12228. isVisible: boolean;
  12229. /**
  12230. * Gets or sets the sprite size
  12231. */
  12232. size: number;
  12233. /**
  12234. * Creates a new Sprite
  12235. * @param name defines the name
  12236. * @param manager defines the manager
  12237. */
  12238. constructor(
  12239. /** defines the name */
  12240. name: string, manager: ISpriteManager);
  12241. /**
  12242. * Starts an animation
  12243. * @param from defines the initial key
  12244. * @param to defines the end key
  12245. * @param loop defines if the animation must loop
  12246. * @param delay defines the start delay (in ms)
  12247. * @param onAnimationEnd defines a callback to call when animation ends
  12248. */
  12249. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  12250. /** Stops current animation (if any) */
  12251. stopAnimation(): void;
  12252. /** @hidden */
  12253. _animate(deltaTime: number): void;
  12254. /** Release associated resources */
  12255. dispose(): void;
  12256. }
  12257. }
  12258. declare module "babylonjs/Collisions/pickingInfo" {
  12259. import { Nullable } from "babylonjs/types";
  12260. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  12261. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12262. import { Sprite } from "babylonjs/Sprites/sprite";
  12263. import { Ray } from "babylonjs/Culling/ray";
  12264. /**
  12265. * Information about the result of picking within a scene
  12266. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  12267. */
  12268. export class PickingInfo {
  12269. /** @hidden */
  12270. _pickingUnavailable: boolean;
  12271. /**
  12272. * If the pick collided with an object
  12273. */
  12274. hit: boolean;
  12275. /**
  12276. * Distance away where the pick collided
  12277. */
  12278. distance: number;
  12279. /**
  12280. * The location of pick collision
  12281. */
  12282. pickedPoint: Nullable<Vector3>;
  12283. /**
  12284. * The mesh corresponding the the pick collision
  12285. */
  12286. pickedMesh: Nullable<AbstractMesh>;
  12287. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  12288. bu: number;
  12289. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  12290. bv: number;
  12291. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  12292. faceId: number;
  12293. /** Id of the the submesh that was picked */
  12294. subMeshId: number;
  12295. /** If a sprite was picked, this will be the sprite the pick collided with */
  12296. pickedSprite: Nullable<Sprite>;
  12297. /**
  12298. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  12299. */
  12300. originMesh: Nullable<AbstractMesh>;
  12301. /**
  12302. * The ray that was used to perform the picking.
  12303. */
  12304. ray: Nullable<Ray>;
  12305. /**
  12306. * Gets the normal correspodning to the face the pick collided with
  12307. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  12308. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  12309. * @returns The normal correspodning to the face the pick collided with
  12310. */
  12311. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  12312. /**
  12313. * Gets the texture coordinates of where the pick occured
  12314. * @returns the vector containing the coordnates of the texture
  12315. */
  12316. getTextureCoordinates(): Nullable<Vector2>;
  12317. }
  12318. }
  12319. declare module "babylonjs/Events/pointerEvents" {
  12320. import { Nullable } from "babylonjs/types";
  12321. import { Vector2 } from "babylonjs/Maths/math";
  12322. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  12323. import { Ray } from "babylonjs/Culling/ray";
  12324. /**
  12325. * Gather the list of pointer event types as constants.
  12326. */
  12327. export class PointerEventTypes {
  12328. /**
  12329. * 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.
  12330. */
  12331. static readonly POINTERDOWN: number;
  12332. /**
  12333. * The pointerup event is fired when a pointer is no longer active.
  12334. */
  12335. static readonly POINTERUP: number;
  12336. /**
  12337. * The pointermove event is fired when a pointer changes coordinates.
  12338. */
  12339. static readonly POINTERMOVE: number;
  12340. /**
  12341. * The pointerwheel event is fired when a mouse wheel has been rotated.
  12342. */
  12343. static readonly POINTERWHEEL: number;
  12344. /**
  12345. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  12346. */
  12347. static readonly POINTERPICK: number;
  12348. /**
  12349. * The pointertap event is fired when a the object has been touched and released without drag.
  12350. */
  12351. static readonly POINTERTAP: number;
  12352. /**
  12353. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12354. */
  12355. static readonly POINTERDOUBLETAP: number;
  12356. }
  12357. /**
  12358. * Base class of pointer info types.
  12359. */
  12360. export class PointerInfoBase {
  12361. /**
  12362. * Defines the type of event (PointerEventTypes)
  12363. */
  12364. type: number;
  12365. /**
  12366. * Defines the related dom event
  12367. */
  12368. event: PointerEvent | MouseWheelEvent;
  12369. /**
  12370. * Instantiates the base class of pointers info.
  12371. * @param type Defines the type of event (PointerEventTypes)
  12372. * @param event Defines the related dom event
  12373. */
  12374. constructor(
  12375. /**
  12376. * Defines the type of event (PointerEventTypes)
  12377. */
  12378. type: number,
  12379. /**
  12380. * Defines the related dom event
  12381. */
  12382. event: PointerEvent | MouseWheelEvent);
  12383. }
  12384. /**
  12385. * This class is used to store pointer related info for the onPrePointerObservable event.
  12386. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12387. */
  12388. export class PointerInfoPre extends PointerInfoBase {
  12389. /**
  12390. * Ray from a pointer if availible (eg. 6dof controller)
  12391. */
  12392. ray: Nullable<Ray>;
  12393. /**
  12394. * Defines the local position of the pointer on the canvas.
  12395. */
  12396. localPosition: Vector2;
  12397. /**
  12398. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12399. */
  12400. skipOnPointerObservable: boolean;
  12401. /**
  12402. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12403. * @param type Defines the type of event (PointerEventTypes)
  12404. * @param event Defines the related dom event
  12405. * @param localX Defines the local x coordinates of the pointer when the event occured
  12406. * @param localY Defines the local y coordinates of the pointer when the event occured
  12407. */
  12408. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12409. }
  12410. /**
  12411. * This type contains all the data related to a pointer event in Babylon.js.
  12412. * 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.
  12413. */
  12414. export class PointerInfo extends PointerInfoBase {
  12415. /**
  12416. * Defines the picking info associated to the info (if any)\
  12417. */
  12418. pickInfo: Nullable<PickingInfo>;
  12419. /**
  12420. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12421. * @param type Defines the type of event (PointerEventTypes)
  12422. * @param event Defines the related dom event
  12423. * @param pickInfo Defines the picking info associated to the info (if any)\
  12424. */
  12425. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12426. /**
  12427. * Defines the picking info associated to the info (if any)\
  12428. */
  12429. pickInfo: Nullable<PickingInfo>);
  12430. }
  12431. /**
  12432. * Data relating to a touch event on the screen.
  12433. */
  12434. export interface PointerTouch {
  12435. /**
  12436. * X coordinate of touch.
  12437. */
  12438. x: number;
  12439. /**
  12440. * Y coordinate of touch.
  12441. */
  12442. y: number;
  12443. /**
  12444. * Id of touch. Unique for each finger.
  12445. */
  12446. pointerId: number;
  12447. /**
  12448. * Event type passed from DOM.
  12449. */
  12450. type: any;
  12451. }
  12452. }
  12453. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  12454. import { Observable } from "babylonjs/Misc/observable";
  12455. import { Nullable } from "babylonjs/types";
  12456. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12457. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12458. /**
  12459. * Manage the mouse inputs to control the movement of a free camera.
  12460. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12461. */
  12462. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12463. /**
  12464. * Define if touch is enabled in the mouse input
  12465. */
  12466. touchEnabled: boolean;
  12467. /**
  12468. * Defines the camera the input is attached to.
  12469. */
  12470. camera: FreeCamera;
  12471. /**
  12472. * Defines the buttons associated with the input to handle camera move.
  12473. */
  12474. buttons: number[];
  12475. /**
  12476. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12477. */
  12478. angularSensibility: number;
  12479. private _pointerInput;
  12480. private _onMouseMove;
  12481. private _observer;
  12482. private previousPosition;
  12483. /**
  12484. * Observable for when a pointer move event occurs containing the move offset
  12485. */
  12486. onPointerMovedObservable: Observable<{
  12487. offsetX: number;
  12488. offsetY: number;
  12489. }>;
  12490. /**
  12491. * @hidden
  12492. * If the camera should be rotated automatically based on pointer movement
  12493. */
  12494. _allowCameraRotation: boolean;
  12495. /**
  12496. * Manage the mouse inputs to control the movement of a free camera.
  12497. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12498. * @param touchEnabled Defines if touch is enabled or not
  12499. */
  12500. constructor(
  12501. /**
  12502. * Define if touch is enabled in the mouse input
  12503. */
  12504. touchEnabled?: boolean);
  12505. /**
  12506. * Attach the input controls to a specific dom element to get the input from.
  12507. * @param element Defines the element the controls should be listened from
  12508. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12509. */
  12510. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12511. /**
  12512. * Called on JS contextmenu event.
  12513. * Override this method to provide functionality.
  12514. */
  12515. protected onContextMenu(evt: PointerEvent): void;
  12516. /**
  12517. * Detach the current controls from the specified dom element.
  12518. * @param element Defines the element to stop listening the inputs from
  12519. */
  12520. detachControl(element: Nullable<HTMLElement>): void;
  12521. /**
  12522. * Gets the class name of the current intput.
  12523. * @returns the class name
  12524. */
  12525. getClassName(): string;
  12526. /**
  12527. * Get the friendly name associated with the input class.
  12528. * @returns the input friendly name
  12529. */
  12530. getSimpleName(): string;
  12531. }
  12532. }
  12533. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12534. import { Nullable } from "babylonjs/types";
  12535. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12536. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12537. /**
  12538. * Manage the touch inputs to control the movement of a free camera.
  12539. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12540. */
  12541. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12542. /**
  12543. * Defines the camera the input is attached to.
  12544. */
  12545. camera: FreeCamera;
  12546. /**
  12547. * Defines the touch sensibility for rotation.
  12548. * The higher the faster.
  12549. */
  12550. touchAngularSensibility: number;
  12551. /**
  12552. * Defines the touch sensibility for move.
  12553. * The higher the faster.
  12554. */
  12555. touchMoveSensibility: number;
  12556. private _offsetX;
  12557. private _offsetY;
  12558. private _pointerPressed;
  12559. private _pointerInput;
  12560. private _observer;
  12561. private _onLostFocus;
  12562. /**
  12563. * Attach the input controls to a specific dom element to get the input from.
  12564. * @param element Defines the element the controls should be listened from
  12565. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12566. */
  12567. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12568. /**
  12569. * Detach the current controls from the specified dom element.
  12570. * @param element Defines the element to stop listening the inputs from
  12571. */
  12572. detachControl(element: Nullable<HTMLElement>): void;
  12573. /**
  12574. * Update the current camera state depending on the inputs that have been used this frame.
  12575. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12576. */
  12577. checkInputs(): void;
  12578. /**
  12579. * Gets the class name of the current intput.
  12580. * @returns the class name
  12581. */
  12582. getClassName(): string;
  12583. /**
  12584. * Get the friendly name associated with the input class.
  12585. * @returns the input friendly name
  12586. */
  12587. getSimpleName(): string;
  12588. }
  12589. }
  12590. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12591. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12592. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12593. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  12594. import { Nullable } from "babylonjs/types";
  12595. /**
  12596. * Default Inputs manager for the FreeCamera.
  12597. * It groups all the default supported inputs for ease of use.
  12598. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12599. */
  12600. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12601. /**
  12602. * @hidden
  12603. */
  12604. _mouseInput: Nullable<FreeCameraMouseInput>;
  12605. /**
  12606. * Instantiates a new FreeCameraInputsManager.
  12607. * @param camera Defines the camera the inputs belong to
  12608. */
  12609. constructor(camera: FreeCamera);
  12610. /**
  12611. * Add keyboard input support to the input manager.
  12612. * @returns the current input manager
  12613. */
  12614. addKeyboard(): FreeCameraInputsManager;
  12615. /**
  12616. * Add mouse input support to the input manager.
  12617. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12618. * @returns the current input manager
  12619. */
  12620. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12621. /**
  12622. * Removes the mouse input support from the manager
  12623. * @returns the current input manager
  12624. */
  12625. removeMouse(): FreeCameraInputsManager;
  12626. /**
  12627. * Add touch input support to the input manager.
  12628. * @returns the current input manager
  12629. */
  12630. addTouch(): FreeCameraInputsManager;
  12631. /**
  12632. * Remove all attached input methods from a camera
  12633. */
  12634. clear(): void;
  12635. }
  12636. }
  12637. declare module "babylonjs/Cameras/freeCamera" {
  12638. import { Vector3 } from "babylonjs/Maths/math";
  12639. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12640. import { Scene } from "babylonjs/scene";
  12641. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12642. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12643. /**
  12644. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12645. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12646. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12647. */
  12648. export class FreeCamera extends TargetCamera {
  12649. /**
  12650. * Define the collision ellipsoid of the camera.
  12651. * This is helpful to simulate a camera body like the player body around the camera
  12652. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12653. */
  12654. ellipsoid: Vector3;
  12655. /**
  12656. * Define an offset for the position of the ellipsoid around the camera.
  12657. * This can be helpful to determine the center of the body near the gravity center of the body
  12658. * instead of its head.
  12659. */
  12660. ellipsoidOffset: Vector3;
  12661. /**
  12662. * Enable or disable collisions of the camera with the rest of the scene objects.
  12663. */
  12664. checkCollisions: boolean;
  12665. /**
  12666. * Enable or disable gravity on the camera.
  12667. */
  12668. applyGravity: boolean;
  12669. /**
  12670. * Define the input manager associated to the camera.
  12671. */
  12672. inputs: FreeCameraInputsManager;
  12673. /**
  12674. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12675. * Higher values reduce sensitivity.
  12676. */
  12677. /**
  12678. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12679. * Higher values reduce sensitivity.
  12680. */
  12681. angularSensibility: number;
  12682. /**
  12683. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12684. */
  12685. keysUp: number[];
  12686. /**
  12687. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12688. */
  12689. keysDown: number[];
  12690. /**
  12691. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12692. */
  12693. keysLeft: number[];
  12694. /**
  12695. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12696. */
  12697. keysRight: number[];
  12698. /**
  12699. * Event raised when the camera collide with a mesh in the scene.
  12700. */
  12701. onCollide: (collidedMesh: AbstractMesh) => void;
  12702. private _collider;
  12703. private _needMoveForGravity;
  12704. private _oldPosition;
  12705. private _diffPosition;
  12706. private _newPosition;
  12707. /** @hidden */
  12708. _localDirection: Vector3;
  12709. /** @hidden */
  12710. _transformedDirection: Vector3;
  12711. /**
  12712. * Instantiates a Free Camera.
  12713. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12714. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12715. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12716. * @param name Define the name of the camera in the scene
  12717. * @param position Define the start position of the camera in the scene
  12718. * @param scene Define the scene the camera belongs to
  12719. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12720. */
  12721. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12722. /**
  12723. * Attached controls to the current camera.
  12724. * @param element Defines the element the controls should be listened from
  12725. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12726. */
  12727. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12728. /**
  12729. * Detach the current controls from the camera.
  12730. * The camera will stop reacting to inputs.
  12731. * @param element Defines the element to stop listening the inputs from
  12732. */
  12733. detachControl(element: HTMLElement): void;
  12734. private _collisionMask;
  12735. /**
  12736. * Define a collision mask to limit the list of object the camera can collide with
  12737. */
  12738. collisionMask: number;
  12739. /** @hidden */
  12740. _collideWithWorld(displacement: Vector3): void;
  12741. private _onCollisionPositionChange;
  12742. /** @hidden */
  12743. _checkInputs(): void;
  12744. /** @hidden */
  12745. _decideIfNeedsToMove(): boolean;
  12746. /** @hidden */
  12747. _updatePosition(): void;
  12748. /**
  12749. * Destroy the camera and release the current resources hold by it.
  12750. */
  12751. dispose(): void;
  12752. /**
  12753. * Gets the current object class name.
  12754. * @return the class name
  12755. */
  12756. getClassName(): string;
  12757. }
  12758. }
  12759. declare module "babylonjs/Gamepads/gamepad" {
  12760. import { Observable } from "babylonjs/Misc/observable";
  12761. /**
  12762. * Represents a gamepad control stick position
  12763. */
  12764. export class StickValues {
  12765. /**
  12766. * The x component of the control stick
  12767. */
  12768. x: number;
  12769. /**
  12770. * The y component of the control stick
  12771. */
  12772. y: number;
  12773. /**
  12774. * Initializes the gamepad x and y control stick values
  12775. * @param x The x component of the gamepad control stick value
  12776. * @param y The y component of the gamepad control stick value
  12777. */
  12778. constructor(
  12779. /**
  12780. * The x component of the control stick
  12781. */
  12782. x: number,
  12783. /**
  12784. * The y component of the control stick
  12785. */
  12786. y: number);
  12787. }
  12788. /**
  12789. * An interface which manages callbacks for gamepad button changes
  12790. */
  12791. export interface GamepadButtonChanges {
  12792. /**
  12793. * Called when a gamepad has been changed
  12794. */
  12795. changed: boolean;
  12796. /**
  12797. * Called when a gamepad press event has been triggered
  12798. */
  12799. pressChanged: boolean;
  12800. /**
  12801. * Called when a touch event has been triggered
  12802. */
  12803. touchChanged: boolean;
  12804. /**
  12805. * Called when a value has changed
  12806. */
  12807. valueChanged: boolean;
  12808. }
  12809. /**
  12810. * Represents a gamepad
  12811. */
  12812. export class Gamepad {
  12813. /**
  12814. * The id of the gamepad
  12815. */
  12816. id: string;
  12817. /**
  12818. * The index of the gamepad
  12819. */
  12820. index: number;
  12821. /**
  12822. * The browser gamepad
  12823. */
  12824. browserGamepad: any;
  12825. /**
  12826. * Specifies what type of gamepad this represents
  12827. */
  12828. type: number;
  12829. private _leftStick;
  12830. private _rightStick;
  12831. /** @hidden */
  12832. _isConnected: boolean;
  12833. private _leftStickAxisX;
  12834. private _leftStickAxisY;
  12835. private _rightStickAxisX;
  12836. private _rightStickAxisY;
  12837. /**
  12838. * Triggered when the left control stick has been changed
  12839. */
  12840. private _onleftstickchanged;
  12841. /**
  12842. * Triggered when the right control stick has been changed
  12843. */
  12844. private _onrightstickchanged;
  12845. /**
  12846. * Represents a gamepad controller
  12847. */
  12848. static GAMEPAD: number;
  12849. /**
  12850. * Represents a generic controller
  12851. */
  12852. static GENERIC: number;
  12853. /**
  12854. * Represents an XBox controller
  12855. */
  12856. static XBOX: number;
  12857. /**
  12858. * Represents a pose-enabled controller
  12859. */
  12860. static POSE_ENABLED: number;
  12861. /**
  12862. * Specifies whether the left control stick should be Y-inverted
  12863. */
  12864. protected _invertLeftStickY: boolean;
  12865. /**
  12866. * Specifies if the gamepad has been connected
  12867. */
  12868. readonly isConnected: boolean;
  12869. /**
  12870. * Initializes the gamepad
  12871. * @param id The id of the gamepad
  12872. * @param index The index of the gamepad
  12873. * @param browserGamepad The browser gamepad
  12874. * @param leftStickX The x component of the left joystick
  12875. * @param leftStickY The y component of the left joystick
  12876. * @param rightStickX The x component of the right joystick
  12877. * @param rightStickY The y component of the right joystick
  12878. */
  12879. constructor(
  12880. /**
  12881. * The id of the gamepad
  12882. */
  12883. id: string,
  12884. /**
  12885. * The index of the gamepad
  12886. */
  12887. index: number,
  12888. /**
  12889. * The browser gamepad
  12890. */
  12891. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12892. /**
  12893. * Callback triggered when the left joystick has changed
  12894. * @param callback
  12895. */
  12896. onleftstickchanged(callback: (values: StickValues) => void): void;
  12897. /**
  12898. * Callback triggered when the right joystick has changed
  12899. * @param callback
  12900. */
  12901. onrightstickchanged(callback: (values: StickValues) => void): void;
  12902. /**
  12903. * Gets the left joystick
  12904. */
  12905. /**
  12906. * Sets the left joystick values
  12907. */
  12908. leftStick: StickValues;
  12909. /**
  12910. * Gets the right joystick
  12911. */
  12912. /**
  12913. * Sets the right joystick value
  12914. */
  12915. rightStick: StickValues;
  12916. /**
  12917. * Updates the gamepad joystick positions
  12918. */
  12919. update(): void;
  12920. /**
  12921. * Disposes the gamepad
  12922. */
  12923. dispose(): void;
  12924. }
  12925. /**
  12926. * Represents a generic gamepad
  12927. */
  12928. export class GenericPad extends Gamepad {
  12929. private _buttons;
  12930. private _onbuttondown;
  12931. private _onbuttonup;
  12932. /**
  12933. * Observable triggered when a button has been pressed
  12934. */
  12935. onButtonDownObservable: Observable<number>;
  12936. /**
  12937. * Observable triggered when a button has been released
  12938. */
  12939. onButtonUpObservable: Observable<number>;
  12940. /**
  12941. * Callback triggered when a button has been pressed
  12942. * @param callback Called when a button has been pressed
  12943. */
  12944. onbuttondown(callback: (buttonPressed: number) => void): void;
  12945. /**
  12946. * Callback triggered when a button has been released
  12947. * @param callback Called when a button has been released
  12948. */
  12949. onbuttonup(callback: (buttonReleased: number) => void): void;
  12950. /**
  12951. * Initializes the generic gamepad
  12952. * @param id The id of the generic gamepad
  12953. * @param index The index of the generic gamepad
  12954. * @param browserGamepad The browser gamepad
  12955. */
  12956. constructor(id: string, index: number, browserGamepad: any);
  12957. private _setButtonValue;
  12958. /**
  12959. * Updates the generic gamepad
  12960. */
  12961. update(): void;
  12962. /**
  12963. * Disposes the generic gamepad
  12964. */
  12965. dispose(): void;
  12966. }
  12967. }
  12968. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  12969. import { Observable } from "babylonjs/Misc/observable";
  12970. import { Nullable } from "babylonjs/types";
  12971. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  12972. import { TransformNode } from "babylonjs/Meshes/transformNode";
  12973. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12974. import { Ray } from "babylonjs/Culling/ray";
  12975. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  12976. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  12977. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12978. /**
  12979. * Defines the types of pose enabled controllers that are supported
  12980. */
  12981. export enum PoseEnabledControllerType {
  12982. /**
  12983. * HTC Vive
  12984. */
  12985. VIVE = 0,
  12986. /**
  12987. * Oculus Rift
  12988. */
  12989. OCULUS = 1,
  12990. /**
  12991. * Windows mixed reality
  12992. */
  12993. WINDOWS = 2,
  12994. /**
  12995. * Samsung gear VR
  12996. */
  12997. GEAR_VR = 3,
  12998. /**
  12999. * Google Daydream
  13000. */
  13001. DAYDREAM = 4,
  13002. /**
  13003. * Generic
  13004. */
  13005. GENERIC = 5
  13006. }
  13007. /**
  13008. * Defines the MutableGamepadButton interface for the state of a gamepad button
  13009. */
  13010. export interface MutableGamepadButton {
  13011. /**
  13012. * Value of the button/trigger
  13013. */
  13014. value: number;
  13015. /**
  13016. * If the button/trigger is currently touched
  13017. */
  13018. touched: boolean;
  13019. /**
  13020. * If the button/trigger is currently pressed
  13021. */
  13022. pressed: boolean;
  13023. }
  13024. /**
  13025. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  13026. * @hidden
  13027. */
  13028. export interface ExtendedGamepadButton extends GamepadButton {
  13029. /**
  13030. * If the button/trigger is currently pressed
  13031. */
  13032. readonly pressed: boolean;
  13033. /**
  13034. * If the button/trigger is currently touched
  13035. */
  13036. readonly touched: boolean;
  13037. /**
  13038. * Value of the button/trigger
  13039. */
  13040. readonly value: number;
  13041. }
  13042. /** @hidden */
  13043. export interface _GamePadFactory {
  13044. /**
  13045. * Returns wether or not the current gamepad can be created for this type of controller.
  13046. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  13047. * @returns true if it can be created, otherwise false
  13048. */
  13049. canCreate(gamepadInfo: any): boolean;
  13050. /**
  13051. * Creates a new instance of the Gamepad.
  13052. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  13053. * @returns the new gamepad instance
  13054. */
  13055. create(gamepadInfo: any): Gamepad;
  13056. }
  13057. /**
  13058. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  13059. */
  13060. export class PoseEnabledControllerHelper {
  13061. /** @hidden */
  13062. static _ControllerFactories: _GamePadFactory[];
  13063. /** @hidden */
  13064. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  13065. /**
  13066. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  13067. * @param vrGamepad the gamepad to initialized
  13068. * @returns a vr controller of the type the gamepad identified as
  13069. */
  13070. static InitiateController(vrGamepad: any): Gamepad;
  13071. }
  13072. /**
  13073. * Defines the PoseEnabledController object that contains state of a vr capable controller
  13074. */
  13075. export class PoseEnabledController extends Gamepad implements PoseControlled {
  13076. private _deviceRoomPosition;
  13077. private _deviceRoomRotationQuaternion;
  13078. /**
  13079. * The device position in babylon space
  13080. */
  13081. devicePosition: Vector3;
  13082. /**
  13083. * The device rotation in babylon space
  13084. */
  13085. deviceRotationQuaternion: Quaternion;
  13086. /**
  13087. * The scale factor of the device in babylon space
  13088. */
  13089. deviceScaleFactor: number;
  13090. /**
  13091. * (Likely devicePosition should be used instead) The device position in its room space
  13092. */
  13093. position: Vector3;
  13094. /**
  13095. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  13096. */
  13097. rotationQuaternion: Quaternion;
  13098. /**
  13099. * The type of controller (Eg. Windows mixed reality)
  13100. */
  13101. controllerType: PoseEnabledControllerType;
  13102. protected _calculatedPosition: Vector3;
  13103. private _calculatedRotation;
  13104. /**
  13105. * The raw pose from the device
  13106. */
  13107. rawPose: DevicePose;
  13108. private _trackPosition;
  13109. private _maxRotationDistFromHeadset;
  13110. private _draggedRoomRotation;
  13111. /**
  13112. * @hidden
  13113. */
  13114. _disableTrackPosition(fixedPosition: Vector3): void;
  13115. /**
  13116. * Internal, the mesh attached to the controller
  13117. * @hidden
  13118. */
  13119. _mesh: Nullable<AbstractMesh>;
  13120. private _poseControlledCamera;
  13121. private _leftHandSystemQuaternion;
  13122. /**
  13123. * Internal, matrix used to convert room space to babylon space
  13124. * @hidden
  13125. */
  13126. _deviceToWorld: Matrix;
  13127. /**
  13128. * Node to be used when casting a ray from the controller
  13129. * @hidden
  13130. */
  13131. _pointingPoseNode: Nullable<TransformNode>;
  13132. /**
  13133. * Name of the child mesh that can be used to cast a ray from the controller
  13134. */
  13135. static readonly POINTING_POSE: string;
  13136. /**
  13137. * Creates a new PoseEnabledController from a gamepad
  13138. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  13139. */
  13140. constructor(browserGamepad: any);
  13141. private _workingMatrix;
  13142. /**
  13143. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  13144. */
  13145. update(): void;
  13146. /**
  13147. * Updates only the pose device and mesh without doing any button event checking
  13148. */
  13149. protected _updatePoseAndMesh(): void;
  13150. /**
  13151. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  13152. * @param poseData raw pose fromthe device
  13153. */
  13154. updateFromDevice(poseData: DevicePose): void;
  13155. /**
  13156. * @hidden
  13157. */
  13158. _meshAttachedObservable: Observable<AbstractMesh>;
  13159. /**
  13160. * Attaches a mesh to the controller
  13161. * @param mesh the mesh to be attached
  13162. */
  13163. attachToMesh(mesh: AbstractMesh): void;
  13164. /**
  13165. * Attaches the controllers mesh to a camera
  13166. * @param camera the camera the mesh should be attached to
  13167. */
  13168. attachToPoseControlledCamera(camera: TargetCamera): void;
  13169. /**
  13170. * Disposes of the controller
  13171. */
  13172. dispose(): void;
  13173. /**
  13174. * The mesh that is attached to the controller
  13175. */
  13176. readonly mesh: Nullable<AbstractMesh>;
  13177. /**
  13178. * Gets the ray of the controller in the direction the controller is pointing
  13179. * @param length the length the resulting ray should be
  13180. * @returns a ray in the direction the controller is pointing
  13181. */
  13182. getForwardRay(length?: number): Ray;
  13183. }
  13184. }
  13185. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  13186. import { Observable } from "babylonjs/Misc/observable";
  13187. import { Scene } from "babylonjs/scene";
  13188. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13189. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  13190. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  13191. /**
  13192. * Defines the WebVRController object that represents controllers tracked in 3D space
  13193. */
  13194. export abstract class WebVRController extends PoseEnabledController {
  13195. /**
  13196. * Internal, the default controller model for the controller
  13197. */
  13198. protected _defaultModel: AbstractMesh;
  13199. /**
  13200. * Fired when the trigger state has changed
  13201. */
  13202. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  13203. /**
  13204. * Fired when the main button state has changed
  13205. */
  13206. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  13207. /**
  13208. * Fired when the secondary button state has changed
  13209. */
  13210. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  13211. /**
  13212. * Fired when the pad state has changed
  13213. */
  13214. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  13215. /**
  13216. * Fired when controllers stick values have changed
  13217. */
  13218. onPadValuesChangedObservable: Observable<StickValues>;
  13219. /**
  13220. * Array of button availible on the controller
  13221. */
  13222. protected _buttons: Array<MutableGamepadButton>;
  13223. private _onButtonStateChange;
  13224. /**
  13225. * Fired when a controller button's state has changed
  13226. * @param callback the callback containing the button that was modified
  13227. */
  13228. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  13229. /**
  13230. * X and Y axis corrisponding to the controllers joystick
  13231. */
  13232. pad: StickValues;
  13233. /**
  13234. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  13235. */
  13236. hand: string;
  13237. /**
  13238. * The default controller model for the controller
  13239. */
  13240. readonly defaultModel: AbstractMesh;
  13241. /**
  13242. * Creates a new WebVRController from a gamepad
  13243. * @param vrGamepad the gamepad that the WebVRController should be created from
  13244. */
  13245. constructor(vrGamepad: any);
  13246. /**
  13247. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  13248. */
  13249. update(): void;
  13250. /**
  13251. * Function to be called when a button is modified
  13252. */
  13253. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  13254. /**
  13255. * Loads a mesh and attaches it to the controller
  13256. * @param scene the scene the mesh should be added to
  13257. * @param meshLoaded callback for when the mesh has been loaded
  13258. */
  13259. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  13260. private _setButtonValue;
  13261. private _changes;
  13262. private _checkChanges;
  13263. /**
  13264. * Disposes of th webVRCOntroller
  13265. */
  13266. dispose(): void;
  13267. }
  13268. }
  13269. declare module "babylonjs/Lights/hemisphericLight" {
  13270. import { Nullable } from "babylonjs/types";
  13271. import { Scene } from "babylonjs/scene";
  13272. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  13273. import { Effect } from "babylonjs/Materials/effect";
  13274. import { Light } from "babylonjs/Lights/light";
  13275. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  13276. /**
  13277. * The HemisphericLight simulates the ambient environment light,
  13278. * so the passed direction is the light reflection direction, not the incoming direction.
  13279. */
  13280. export class HemisphericLight extends Light {
  13281. /**
  13282. * The groundColor is the light in the opposite direction to the one specified during creation.
  13283. * 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.
  13284. */
  13285. groundColor: Color3;
  13286. /**
  13287. * The light reflection direction, not the incoming direction.
  13288. */
  13289. direction: Vector3;
  13290. /**
  13291. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  13292. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  13293. * The HemisphericLight can't cast shadows.
  13294. * Documentation : https://doc.babylonjs.com/babylon101/lights
  13295. * @param name The friendly name of the light
  13296. * @param direction The direction of the light reflection
  13297. * @param scene The scene the light belongs to
  13298. */
  13299. constructor(name: string, direction: Vector3, scene: Scene);
  13300. protected _buildUniformLayout(): void;
  13301. /**
  13302. * Returns the string "HemisphericLight".
  13303. * @return The class name
  13304. */
  13305. getClassName(): string;
  13306. /**
  13307. * Sets the HemisphericLight direction towards the passed target (Vector3).
  13308. * Returns the updated direction.
  13309. * @param target The target the direction should point to
  13310. * @return The computed direction
  13311. */
  13312. setDirectionToTarget(target: Vector3): Vector3;
  13313. /**
  13314. * Returns the shadow generator associated to the light.
  13315. * @returns Always null for hemispheric lights because it does not support shadows.
  13316. */
  13317. getShadowGenerator(): Nullable<IShadowGenerator>;
  13318. /**
  13319. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  13320. * @param effect The effect to update
  13321. * @param lightIndex The index of the light in the effect to update
  13322. * @returns The hemispheric light
  13323. */
  13324. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  13325. /**
  13326. * Computes the world matrix of the node
  13327. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  13328. * @param useWasUpdatedFlag defines a reserved property
  13329. * @returns the world matrix
  13330. */
  13331. computeWorldMatrix(): Matrix;
  13332. /**
  13333. * Returns the integer 3.
  13334. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  13335. */
  13336. getTypeID(): number;
  13337. /**
  13338. * Prepares the list of defines specific to the light type.
  13339. * @param defines the list of defines
  13340. * @param lightIndex defines the index of the light for the effect
  13341. */
  13342. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  13343. }
  13344. }
  13345. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  13346. /** @hidden */
  13347. export var vrMultiviewToSingleviewPixelShader: {
  13348. name: string;
  13349. shader: string;
  13350. };
  13351. }
  13352. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  13353. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  13354. import { Scene } from "babylonjs/scene";
  13355. /**
  13356. * Renders to multiple views with a single draw call
  13357. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  13358. */
  13359. export class MultiviewRenderTarget extends RenderTargetTexture {
  13360. /**
  13361. * Creates a multiview render target
  13362. * @param scene scene used with the render target
  13363. * @param size the size of the render target (used for each view)
  13364. */
  13365. constructor(scene: Scene, size?: number | {
  13366. width: number;
  13367. height: number;
  13368. } | {
  13369. ratio: number;
  13370. });
  13371. /**
  13372. * @hidden
  13373. * @param faceIndex the face index, if its a cube texture
  13374. */
  13375. _bindFrameBuffer(faceIndex?: number): void;
  13376. /**
  13377. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  13378. * @returns the view count
  13379. */
  13380. getViewCount(): number;
  13381. }
  13382. }
  13383. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  13384. import { Camera } from "babylonjs/Cameras/camera";
  13385. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  13386. import { Nullable } from "babylonjs/types";
  13387. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  13388. import { Matrix } from "babylonjs/Maths/math";
  13389. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  13390. module "babylonjs/Engines/engine" {
  13391. interface Engine {
  13392. /**
  13393. * Creates a new multiview render target
  13394. * @param width defines the width of the texture
  13395. * @param height defines the height of the texture
  13396. * @returns the created multiview texture
  13397. */
  13398. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  13399. /**
  13400. * Binds a multiview framebuffer to be drawn to
  13401. * @param multiviewTexture texture to bind
  13402. */
  13403. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  13404. }
  13405. }
  13406. module "babylonjs/Cameras/camera" {
  13407. interface Camera {
  13408. /**
  13409. * @hidden
  13410. * 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)
  13411. */
  13412. _useMultiviewToSingleView: boolean;
  13413. /**
  13414. * @hidden
  13415. * 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)
  13416. */
  13417. _multiviewTexture: Nullable<RenderTargetTexture>;
  13418. /**
  13419. * @hidden
  13420. * ensures the multiview texture of the camera exists and has the specified width/height
  13421. * @param width height to set on the multiview texture
  13422. * @param height width to set on the multiview texture
  13423. */
  13424. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  13425. }
  13426. }
  13427. module "babylonjs/scene" {
  13428. interface Scene {
  13429. /** @hidden */
  13430. _transformMatrixR: Matrix;
  13431. /** @hidden */
  13432. _multiviewSceneUbo: Nullable<UniformBuffer>;
  13433. /** @hidden */
  13434. _createMultiviewUbo(): void;
  13435. /** @hidden */
  13436. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  13437. /** @hidden */
  13438. _renderMultiviewToSingleView(camera: Camera): void;
  13439. }
  13440. }
  13441. }
  13442. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  13443. import { Camera } from "babylonjs/Cameras/camera";
  13444. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  13445. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  13446. import "babylonjs/Engines/Extensions/engine.multiview";
  13447. /**
  13448. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  13449. * This will not be used for webXR as it supports displaying texture arrays directly
  13450. */
  13451. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  13452. /**
  13453. * Initializes a VRMultiviewToSingleview
  13454. * @param name name of the post process
  13455. * @param camera camera to be applied to
  13456. * @param scaleFactor scaling factor to the size of the output texture
  13457. */
  13458. constructor(name: string, camera: Camera, scaleFactor: number);
  13459. }
  13460. }
  13461. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  13462. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  13463. import { Nullable } from "babylonjs/types";
  13464. import { Size } from "babylonjs/Maths/math";
  13465. import { Observable } from "babylonjs/Misc/observable";
  13466. module "babylonjs/Engines/engine" {
  13467. /**
  13468. * Defines the interface used by display changed events
  13469. */
  13470. interface IDisplayChangedEventArgs {
  13471. /** Gets the vrDisplay object (if any) */
  13472. vrDisplay: Nullable<any>;
  13473. /** Gets a boolean indicating if webVR is supported */
  13474. vrSupported: boolean;
  13475. }
  13476. interface Engine {
  13477. /** @hidden */
  13478. _vrDisplay: any;
  13479. /** @hidden */
  13480. _vrSupported: boolean;
  13481. /** @hidden */
  13482. _oldSize: Size;
  13483. /** @hidden */
  13484. _oldHardwareScaleFactor: number;
  13485. /** @hidden */
  13486. _vrExclusivePointerMode: boolean;
  13487. /** @hidden */
  13488. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  13489. /** @hidden */
  13490. _onVRDisplayPointerRestricted: () => void;
  13491. /** @hidden */
  13492. _onVRDisplayPointerUnrestricted: () => void;
  13493. /** @hidden */
  13494. _onVrDisplayConnect: Nullable<(display: any) => void>;
  13495. /** @hidden */
  13496. _onVrDisplayDisconnect: Nullable<() => void>;
  13497. /** @hidden */
  13498. _onVrDisplayPresentChange: Nullable<() => void>;
  13499. /**
  13500. * Observable signaled when VR display mode changes
  13501. */
  13502. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  13503. /**
  13504. * Observable signaled when VR request present is complete
  13505. */
  13506. onVRRequestPresentComplete: Observable<boolean>;
  13507. /**
  13508. * Observable signaled when VR request present starts
  13509. */
  13510. onVRRequestPresentStart: Observable<Engine>;
  13511. /**
  13512. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  13513. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  13514. */
  13515. isInVRExclusivePointerMode: boolean;
  13516. /**
  13517. * Gets a boolean indicating if a webVR device was detected
  13518. * @returns true if a webVR device was detected
  13519. */
  13520. isVRDevicePresent(): boolean;
  13521. /**
  13522. * Gets the current webVR device
  13523. * @returns the current webVR device (or null)
  13524. */
  13525. getVRDevice(): any;
  13526. /**
  13527. * Initializes a webVR display and starts listening to display change events
  13528. * The onVRDisplayChangedObservable will be notified upon these changes
  13529. * @returns A promise containing a VRDisplay and if vr is supported
  13530. */
  13531. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  13532. /** @hidden */
  13533. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  13534. /**
  13535. * Call this function to switch to webVR mode
  13536. * Will do nothing if webVR is not supported or if there is no webVR device
  13537. * @see http://doc.babylonjs.com/how_to/webvr_camera
  13538. */
  13539. enableVR(): void;
  13540. /** @hidden */
  13541. _onVRFullScreenTriggered(): void;
  13542. }
  13543. }
  13544. }
  13545. declare module "babylonjs/Cameras/VR/webVRCamera" {
  13546. import { Nullable } from "babylonjs/types";
  13547. import { Observable } from "babylonjs/Misc/observable";
  13548. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  13549. import { Scene } from "babylonjs/scene";
  13550. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  13551. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  13552. import { Node } from "babylonjs/node";
  13553. import { Ray } from "babylonjs/Culling/ray";
  13554. import "babylonjs/Cameras/RigModes/webVRRigMode";
  13555. import "babylonjs/Engines/Extensions/engine.webVR";
  13556. /**
  13557. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  13558. * IMPORTANT!! The data is right-hand data.
  13559. * @export
  13560. * @interface DevicePose
  13561. */
  13562. export interface DevicePose {
  13563. /**
  13564. * The position of the device, values in array are [x,y,z].
  13565. */
  13566. readonly position: Nullable<Float32Array>;
  13567. /**
  13568. * The linearVelocity of the device, values in array are [x,y,z].
  13569. */
  13570. readonly linearVelocity: Nullable<Float32Array>;
  13571. /**
  13572. * The linearAcceleration of the device, values in array are [x,y,z].
  13573. */
  13574. readonly linearAcceleration: Nullable<Float32Array>;
  13575. /**
  13576. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  13577. */
  13578. readonly orientation: Nullable<Float32Array>;
  13579. /**
  13580. * The angularVelocity of the device, values in array are [x,y,z].
  13581. */
  13582. readonly angularVelocity: Nullable<Float32Array>;
  13583. /**
  13584. * The angularAcceleration of the device, values in array are [x,y,z].
  13585. */
  13586. readonly angularAcceleration: Nullable<Float32Array>;
  13587. }
  13588. /**
  13589. * Interface representing a pose controlled object in Babylon.
  13590. * A pose controlled object has both regular pose values as well as pose values
  13591. * from an external device such as a VR head mounted display
  13592. */
  13593. export interface PoseControlled {
  13594. /**
  13595. * The position of the object in babylon space.
  13596. */
  13597. position: Vector3;
  13598. /**
  13599. * The rotation quaternion of the object in babylon space.
  13600. */
  13601. rotationQuaternion: Quaternion;
  13602. /**
  13603. * The position of the device in babylon space.
  13604. */
  13605. devicePosition?: Vector3;
  13606. /**
  13607. * The rotation quaternion of the device in babylon space.
  13608. */
  13609. deviceRotationQuaternion: Quaternion;
  13610. /**
  13611. * The raw pose coming from the device.
  13612. */
  13613. rawPose: Nullable<DevicePose>;
  13614. /**
  13615. * The scale of the device to be used when translating from device space to babylon space.
  13616. */
  13617. deviceScaleFactor: number;
  13618. /**
  13619. * Updates the poseControlled values based on the input device pose.
  13620. * @param poseData the pose data to update the object with
  13621. */
  13622. updateFromDevice(poseData: DevicePose): void;
  13623. }
  13624. /**
  13625. * Set of options to customize the webVRCamera
  13626. */
  13627. export interface WebVROptions {
  13628. /**
  13629. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  13630. */
  13631. trackPosition?: boolean;
  13632. /**
  13633. * Sets the scale of the vrDevice in babylon space. (default: 1)
  13634. */
  13635. positionScale?: number;
  13636. /**
  13637. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  13638. */
  13639. displayName?: string;
  13640. /**
  13641. * Should the native controller meshes be initialized. (default: true)
  13642. */
  13643. controllerMeshes?: boolean;
  13644. /**
  13645. * Creating a default HemiLight only on controllers. (default: true)
  13646. */
  13647. defaultLightingOnControllers?: boolean;
  13648. /**
  13649. * If you don't want to use the default VR button of the helper. (default: false)
  13650. */
  13651. useCustomVRButton?: boolean;
  13652. /**
  13653. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  13654. */
  13655. customVRButton?: HTMLButtonElement;
  13656. /**
  13657. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  13658. */
  13659. rayLength?: number;
  13660. /**
  13661. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  13662. */
  13663. defaultHeight?: number;
  13664. /**
  13665. * If multiview should be used if availible (default: false)
  13666. */
  13667. useMultiview?: boolean;
  13668. }
  13669. /**
  13670. * This represents a WebVR camera.
  13671. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  13672. * @example http://doc.babylonjs.com/how_to/webvr_camera
  13673. */
  13674. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  13675. private webVROptions;
  13676. /**
  13677. * @hidden
  13678. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  13679. */
  13680. _vrDevice: any;
  13681. /**
  13682. * The rawPose of the vrDevice.
  13683. */
  13684. rawPose: Nullable<DevicePose>;
  13685. private _onVREnabled;
  13686. private _specsVersion;
  13687. private _attached;
  13688. private _frameData;
  13689. protected _descendants: Array<Node>;
  13690. private _deviceRoomPosition;
  13691. /** @hidden */
  13692. _deviceRoomRotationQuaternion: Quaternion;
  13693. private _standingMatrix;
  13694. /**
  13695. * Represents device position in babylon space.
  13696. */
  13697. devicePosition: Vector3;
  13698. /**
  13699. * Represents device rotation in babylon space.
  13700. */
  13701. deviceRotationQuaternion: Quaternion;
  13702. /**
  13703. * The scale of the device to be used when translating from device space to babylon space.
  13704. */
  13705. deviceScaleFactor: number;
  13706. private _deviceToWorld;
  13707. private _worldToDevice;
  13708. /**
  13709. * References to the webVR controllers for the vrDevice.
  13710. */
  13711. controllers: Array<WebVRController>;
  13712. /**
  13713. * Emits an event when a controller is attached.
  13714. */
  13715. onControllersAttachedObservable: Observable<WebVRController[]>;
  13716. /**
  13717. * Emits an event when a controller's mesh has been loaded;
  13718. */
  13719. onControllerMeshLoadedObservable: Observable<WebVRController>;
  13720. /**
  13721. * Emits an event when the HMD's pose has been updated.
  13722. */
  13723. onPoseUpdatedFromDeviceObservable: Observable<any>;
  13724. private _poseSet;
  13725. /**
  13726. * If the rig cameras be used as parent instead of this camera.
  13727. */
  13728. rigParenting: boolean;
  13729. private _lightOnControllers;
  13730. private _defaultHeight?;
  13731. /**
  13732. * Instantiates a WebVRFreeCamera.
  13733. * @param name The name of the WebVRFreeCamera
  13734. * @param position The starting anchor position for the camera
  13735. * @param scene The scene the camera belongs to
  13736. * @param webVROptions a set of customizable options for the webVRCamera
  13737. */
  13738. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  13739. /**
  13740. * Gets the device distance from the ground in meters.
  13741. * @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.
  13742. */
  13743. deviceDistanceToRoomGround(): number;
  13744. /**
  13745. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13746. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  13747. */
  13748. useStandingMatrix(callback?: (bool: boolean) => void): void;
  13749. /**
  13750. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13751. * @returns A promise with a boolean set to if the standing matrix is supported.
  13752. */
  13753. useStandingMatrixAsync(): Promise<boolean>;
  13754. /**
  13755. * Disposes the camera
  13756. */
  13757. dispose(): void;
  13758. /**
  13759. * Gets a vrController by name.
  13760. * @param name The name of the controller to retreive
  13761. * @returns the controller matching the name specified or null if not found
  13762. */
  13763. getControllerByName(name: string): Nullable<WebVRController>;
  13764. private _leftController;
  13765. /**
  13766. * The controller corrisponding to the users left hand.
  13767. */
  13768. readonly leftController: Nullable<WebVRController>;
  13769. private _rightController;
  13770. /**
  13771. * The controller corrisponding to the users right hand.
  13772. */
  13773. readonly rightController: Nullable<WebVRController>;
  13774. /**
  13775. * Casts a ray forward from the vrCamera's gaze.
  13776. * @param length Length of the ray (default: 100)
  13777. * @returns the ray corrisponding to the gaze
  13778. */
  13779. getForwardRay(length?: number): Ray;
  13780. /**
  13781. * @hidden
  13782. * Updates the camera based on device's frame data
  13783. */
  13784. _checkInputs(): void;
  13785. /**
  13786. * Updates the poseControlled values based on the input device pose.
  13787. * @param poseData Pose coming from the device
  13788. */
  13789. updateFromDevice(poseData: DevicePose): void;
  13790. private _htmlElementAttached;
  13791. private _detachIfAttached;
  13792. /**
  13793. * WebVR's attach control will start broadcasting frames to the device.
  13794. * Note that in certain browsers (chrome for example) this function must be called
  13795. * within a user-interaction callback. Example:
  13796. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  13797. *
  13798. * @param element html element to attach the vrDevice to
  13799. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  13800. */
  13801. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  13802. /**
  13803. * Detaches the camera from the html element and disables VR
  13804. *
  13805. * @param element html element to detach from
  13806. */
  13807. detachControl(element: HTMLElement): void;
  13808. /**
  13809. * @returns the name of this class
  13810. */
  13811. getClassName(): string;
  13812. /**
  13813. * Calls resetPose on the vrDisplay
  13814. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  13815. */
  13816. resetToCurrentRotation(): void;
  13817. /**
  13818. * @hidden
  13819. * Updates the rig cameras (left and right eye)
  13820. */
  13821. _updateRigCameras(): void;
  13822. private _workingVector;
  13823. private _oneVector;
  13824. private _workingMatrix;
  13825. private updateCacheCalled;
  13826. private _correctPositionIfNotTrackPosition;
  13827. /**
  13828. * @hidden
  13829. * Updates the cached values of the camera
  13830. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  13831. */
  13832. _updateCache(ignoreParentClass?: boolean): void;
  13833. /**
  13834. * @hidden
  13835. * Get current device position in babylon world
  13836. */
  13837. _computeDevicePosition(): void;
  13838. /**
  13839. * Updates the current device position and rotation in the babylon world
  13840. */
  13841. update(): void;
  13842. /**
  13843. * @hidden
  13844. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  13845. * @returns an identity matrix
  13846. */
  13847. _getViewMatrix(): Matrix;
  13848. private _tmpMatrix;
  13849. /**
  13850. * This function is called by the two RIG cameras.
  13851. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  13852. * @hidden
  13853. */
  13854. _getWebVRViewMatrix(): Matrix;
  13855. /** @hidden */
  13856. _getWebVRProjectionMatrix(): Matrix;
  13857. private _onGamepadConnectedObserver;
  13858. private _onGamepadDisconnectedObserver;
  13859. private _updateCacheWhenTrackingDisabledObserver;
  13860. /**
  13861. * Initializes the controllers and their meshes
  13862. */
  13863. initControllers(): void;
  13864. }
  13865. }
  13866. declare module "babylonjs/PostProcesses/postProcess" {
  13867. import { Nullable } from "babylonjs/types";
  13868. import { SmartArray } from "babylonjs/Misc/smartArray";
  13869. import { Observable } from "babylonjs/Misc/observable";
  13870. import { Color4, Vector2 } from "babylonjs/Maths/math";
  13871. import { Camera } from "babylonjs/Cameras/camera";
  13872. import { Effect } from "babylonjs/Materials/effect";
  13873. import "babylonjs/Shaders/postprocess.vertex";
  13874. import { IInspectable } from "babylonjs/Misc/iInspectable";
  13875. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  13876. import { Engine } from "babylonjs/Engines/engine";
  13877. /**
  13878. * Size options for a post process
  13879. */
  13880. export type PostProcessOptions = {
  13881. width: number;
  13882. height: number;
  13883. };
  13884. /**
  13885. * PostProcess can be used to apply a shader to a texture after it has been rendered
  13886. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13887. */
  13888. export class PostProcess {
  13889. /** Name of the PostProcess. */
  13890. name: string;
  13891. /**
  13892. * Gets or sets the unique id of the post process
  13893. */
  13894. uniqueId: number;
  13895. /**
  13896. * Width of the texture to apply the post process on
  13897. */
  13898. width: number;
  13899. /**
  13900. * Height of the texture to apply the post process on
  13901. */
  13902. height: number;
  13903. /**
  13904. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  13905. * @hidden
  13906. */
  13907. _outputTexture: Nullable<InternalTexture>;
  13908. /**
  13909. * Sampling mode used by the shader
  13910. * See https://doc.babylonjs.com/classes/3.1/texture
  13911. */
  13912. renderTargetSamplingMode: number;
  13913. /**
  13914. * Clear color to use when screen clearing
  13915. */
  13916. clearColor: Color4;
  13917. /**
  13918. * If the buffer needs to be cleared before applying the post process. (default: true)
  13919. * Should be set to false if shader will overwrite all previous pixels.
  13920. */
  13921. autoClear: boolean;
  13922. /**
  13923. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  13924. */
  13925. alphaMode: number;
  13926. /**
  13927. * Sets the setAlphaBlendConstants of the babylon engine
  13928. */
  13929. alphaConstants: Color4;
  13930. /**
  13931. * Animations to be used for the post processing
  13932. */
  13933. animations: import("babylonjs/Animations/animation").Animation[];
  13934. /**
  13935. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  13936. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  13937. */
  13938. enablePixelPerfectMode: boolean;
  13939. /**
  13940. * Force the postprocess to be applied without taking in account viewport
  13941. */
  13942. forceFullscreenViewport: boolean;
  13943. /**
  13944. * List of inspectable custom properties (used by the Inspector)
  13945. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13946. */
  13947. inspectableCustomProperties: IInspectable[];
  13948. /**
  13949. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  13950. *
  13951. * | Value | Type | Description |
  13952. * | ----- | ----------------------------------- | ----------- |
  13953. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  13954. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  13955. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  13956. *
  13957. */
  13958. scaleMode: number;
  13959. /**
  13960. * Force textures to be a power of two (default: false)
  13961. */
  13962. alwaysForcePOT: boolean;
  13963. private _samples;
  13964. /**
  13965. * Number of sample textures (default: 1)
  13966. */
  13967. samples: number;
  13968. /**
  13969. * Modify the scale of the post process to be the same as the viewport (default: false)
  13970. */
  13971. adaptScaleToCurrentViewport: boolean;
  13972. private _camera;
  13973. private _scene;
  13974. private _engine;
  13975. private _options;
  13976. private _reusable;
  13977. private _textureType;
  13978. /**
  13979. * Smart array of input and output textures for the post process.
  13980. * @hidden
  13981. */
  13982. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  13983. /**
  13984. * The index in _textures that corresponds to the output texture.
  13985. * @hidden
  13986. */
  13987. _currentRenderTextureInd: number;
  13988. private _effect;
  13989. private _samplers;
  13990. private _fragmentUrl;
  13991. private _vertexUrl;
  13992. private _parameters;
  13993. private _scaleRatio;
  13994. protected _indexParameters: any;
  13995. private _shareOutputWithPostProcess;
  13996. private _texelSize;
  13997. private _forcedOutputTexture;
  13998. /**
  13999. * Returns the fragment url or shader name used in the post process.
  14000. * @returns the fragment url or name in the shader store.
  14001. */
  14002. getEffectName(): string;
  14003. /**
  14004. * An event triggered when the postprocess is activated.
  14005. */
  14006. onActivateObservable: Observable<Camera>;
  14007. private _onActivateObserver;
  14008. /**
  14009. * A function that is added to the onActivateObservable
  14010. */
  14011. onActivate: Nullable<(camera: Camera) => void>;
  14012. /**
  14013. * An event triggered when the postprocess changes its size.
  14014. */
  14015. onSizeChangedObservable: Observable<PostProcess>;
  14016. private _onSizeChangedObserver;
  14017. /**
  14018. * A function that is added to the onSizeChangedObservable
  14019. */
  14020. onSizeChanged: (postProcess: PostProcess) => void;
  14021. /**
  14022. * An event triggered when the postprocess applies its effect.
  14023. */
  14024. onApplyObservable: Observable<Effect>;
  14025. private _onApplyObserver;
  14026. /**
  14027. * A function that is added to the onApplyObservable
  14028. */
  14029. onApply: (effect: Effect) => void;
  14030. /**
  14031. * An event triggered before rendering the postprocess
  14032. */
  14033. onBeforeRenderObservable: Observable<Effect>;
  14034. private _onBeforeRenderObserver;
  14035. /**
  14036. * A function that is added to the onBeforeRenderObservable
  14037. */
  14038. onBeforeRender: (effect: Effect) => void;
  14039. /**
  14040. * An event triggered after rendering the postprocess
  14041. */
  14042. onAfterRenderObservable: Observable<Effect>;
  14043. private _onAfterRenderObserver;
  14044. /**
  14045. * A function that is added to the onAfterRenderObservable
  14046. */
  14047. onAfterRender: (efect: Effect) => void;
  14048. /**
  14049. * 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
  14050. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  14051. */
  14052. inputTexture: InternalTexture;
  14053. /**
  14054. * Gets the camera which post process is applied to.
  14055. * @returns The camera the post process is applied to.
  14056. */
  14057. getCamera(): Camera;
  14058. /**
  14059. * Gets the texel size of the postprocess.
  14060. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  14061. */
  14062. readonly texelSize: Vector2;
  14063. /**
  14064. * Creates a new instance PostProcess
  14065. * @param name The name of the PostProcess.
  14066. * @param fragmentUrl The url of the fragment shader to be used.
  14067. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  14068. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  14069. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  14070. * @param camera The camera to apply the render pass to.
  14071. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  14072. * @param engine The engine which the post process will be applied. (default: current engine)
  14073. * @param reusable If the post process can be reused on the same frame. (default: false)
  14074. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  14075. * @param textureType Type of textures used when performing the post process. (default: 0)
  14076. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  14077. * @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
  14078. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  14079. */
  14080. constructor(
  14081. /** Name of the PostProcess. */
  14082. 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);
  14083. /**
  14084. * Gets a string idenfifying the name of the class
  14085. * @returns "PostProcess" string
  14086. */
  14087. getClassName(): string;
  14088. /**
  14089. * Gets the engine which this post process belongs to.
  14090. * @returns The engine the post process was enabled with.
  14091. */
  14092. getEngine(): Engine;
  14093. /**
  14094. * The effect that is created when initializing the post process.
  14095. * @returns The created effect corrisponding the the postprocess.
  14096. */
  14097. getEffect(): Effect;
  14098. /**
  14099. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  14100. * @param postProcess The post process to share the output with.
  14101. * @returns This post process.
  14102. */
  14103. shareOutputWith(postProcess: PostProcess): PostProcess;
  14104. /**
  14105. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  14106. * This should be called if the post process that shares output with this post process is disabled/disposed.
  14107. */
  14108. useOwnOutput(): void;
  14109. /**
  14110. * Updates the effect with the current post process compile time values and recompiles the shader.
  14111. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  14112. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  14113. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  14114. * @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
  14115. * @param onCompiled Called when the shader has been compiled.
  14116. * @param onError Called if there is an error when compiling a shader.
  14117. */
  14118. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  14119. /**
  14120. * The post process is reusable if it can be used multiple times within one frame.
  14121. * @returns If the post process is reusable
  14122. */
  14123. isReusable(): boolean;
  14124. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  14125. markTextureDirty(): void;
  14126. /**
  14127. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  14128. * 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.
  14129. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  14130. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  14131. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  14132. * @returns The target texture that was bound to be written to.
  14133. */
  14134. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  14135. /**
  14136. * If the post process is supported.
  14137. */
  14138. readonly isSupported: boolean;
  14139. /**
  14140. * The aspect ratio of the output texture.
  14141. */
  14142. readonly aspectRatio: number;
  14143. /**
  14144. * Get a value indicating if the post-process is ready to be used
  14145. * @returns true if the post-process is ready (shader is compiled)
  14146. */
  14147. isReady(): boolean;
  14148. /**
  14149. * Binds all textures and uniforms to the shader, this will be run on every pass.
  14150. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  14151. */
  14152. apply(): Nullable<Effect>;
  14153. private _disposeTextures;
  14154. /**
  14155. * Disposes the post process.
  14156. * @param camera The camera to dispose the post process on.
  14157. */
  14158. dispose(camera?: Camera): void;
  14159. }
  14160. }
  14161. declare module "babylonjs/PostProcesses/postProcessManager" {
  14162. import { Nullable } from "babylonjs/types";
  14163. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  14164. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  14165. import { Scene } from "babylonjs/scene";
  14166. /**
  14167. * PostProcessManager is used to manage one or more post processes or post process pipelines
  14168. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  14169. */
  14170. export class PostProcessManager {
  14171. private _scene;
  14172. private _indexBuffer;
  14173. private _vertexBuffers;
  14174. /**
  14175. * Creates a new instance PostProcess
  14176. * @param scene The scene that the post process is associated with.
  14177. */
  14178. constructor(scene: Scene);
  14179. private _prepareBuffers;
  14180. private _buildIndexBuffer;
  14181. /**
  14182. * Rebuilds the vertex buffers of the manager.
  14183. * @hidden
  14184. */
  14185. _rebuild(): void;
  14186. /**
  14187. * Prepares a frame to be run through a post process.
  14188. * @param sourceTexture The input texture to the post procesess. (default: null)
  14189. * @param postProcesses An array of post processes to be run. (default: null)
  14190. * @returns True if the post processes were able to be run.
  14191. * @hidden
  14192. */
  14193. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  14194. /**
  14195. * Manually render a set of post processes to a texture.
  14196. * @param postProcesses An array of post processes to be run.
  14197. * @param targetTexture The target texture to render to.
  14198. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  14199. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  14200. * @param lodLevel defines which lod of the texture to render to
  14201. */
  14202. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  14203. /**
  14204. * Finalize the result of the output of the postprocesses.
  14205. * @param doNotPresent If true the result will not be displayed to the screen.
  14206. * @param targetTexture The target texture to render to.
  14207. * @param faceIndex The index of the face to bind the target texture to.
  14208. * @param postProcesses The array of post processes to render.
  14209. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  14210. * @hidden
  14211. */
  14212. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  14213. /**
  14214. * Disposes of the post process manager.
  14215. */
  14216. dispose(): void;
  14217. }
  14218. }
  14219. declare module "babylonjs/Layers/layerSceneComponent" {
  14220. import { Scene } from "babylonjs/scene";
  14221. import { ISceneComponent } from "babylonjs/sceneComponent";
  14222. import { Layer } from "babylonjs/Layers/layer";
  14223. module "babylonjs/abstractScene" {
  14224. interface AbstractScene {
  14225. /**
  14226. * The list of layers (background and foreground) of the scene
  14227. */
  14228. layers: Array<Layer>;
  14229. }
  14230. }
  14231. /**
  14232. * Defines the layer scene component responsible to manage any layers
  14233. * in a given scene.
  14234. */
  14235. export class LayerSceneComponent implements ISceneComponent {
  14236. /**
  14237. * The component name helpfull to identify the component in the list of scene components.
  14238. */
  14239. readonly name: string;
  14240. /**
  14241. * The scene the component belongs to.
  14242. */
  14243. scene: Scene;
  14244. private _engine;
  14245. /**
  14246. * Creates a new instance of the component for the given scene
  14247. * @param scene Defines the scene to register the component in
  14248. */
  14249. constructor(scene: Scene);
  14250. /**
  14251. * Registers the component in a given scene
  14252. */
  14253. register(): void;
  14254. /**
  14255. * Rebuilds the elements related to this component in case of
  14256. * context lost for instance.
  14257. */
  14258. rebuild(): void;
  14259. /**
  14260. * Disposes the component and the associated ressources.
  14261. */
  14262. dispose(): void;
  14263. private _draw;
  14264. private _drawCameraPredicate;
  14265. private _drawCameraBackground;
  14266. private _drawCameraForeground;
  14267. private _drawRenderTargetPredicate;
  14268. private _drawRenderTargetBackground;
  14269. private _drawRenderTargetForeground;
  14270. }
  14271. }
  14272. declare module "babylonjs/Shaders/layer.fragment" {
  14273. /** @hidden */
  14274. export var layerPixelShader: {
  14275. name: string;
  14276. shader: string;
  14277. };
  14278. }
  14279. declare module "babylonjs/Shaders/layer.vertex" {
  14280. /** @hidden */
  14281. export var layerVertexShader: {
  14282. name: string;
  14283. shader: string;
  14284. };
  14285. }
  14286. declare module "babylonjs/Layers/layer" {
  14287. import { Observable } from "babylonjs/Misc/observable";
  14288. import { Nullable } from "babylonjs/types";
  14289. import { Scene } from "babylonjs/scene";
  14290. import { Vector2, Color4 } from "babylonjs/Maths/math";
  14291. import { Texture } from "babylonjs/Materials/Textures/texture";
  14292. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  14293. import "babylonjs/Shaders/layer.fragment";
  14294. import "babylonjs/Shaders/layer.vertex";
  14295. /**
  14296. * This represents a full screen 2d layer.
  14297. * This can be useful to display a picture in the background of your scene for instance.
  14298. * @see https://www.babylonjs-playground.com/#08A2BS#1
  14299. */
  14300. export class Layer {
  14301. /**
  14302. * Define the name of the layer.
  14303. */
  14304. name: string;
  14305. /**
  14306. * Define the texture the layer should display.
  14307. */
  14308. texture: Nullable<Texture>;
  14309. /**
  14310. * Is the layer in background or foreground.
  14311. */
  14312. isBackground: boolean;
  14313. /**
  14314. * Define the color of the layer (instead of texture).
  14315. */
  14316. color: Color4;
  14317. /**
  14318. * Define the scale of the layer in order to zoom in out of the texture.
  14319. */
  14320. scale: Vector2;
  14321. /**
  14322. * Define an offset for the layer in order to shift the texture.
  14323. */
  14324. offset: Vector2;
  14325. /**
  14326. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  14327. */
  14328. alphaBlendingMode: number;
  14329. /**
  14330. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  14331. * Alpha test will not mix with the background color in case of transparency.
  14332. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  14333. */
  14334. alphaTest: boolean;
  14335. /**
  14336. * Define a mask to restrict the layer to only some of the scene cameras.
  14337. */
  14338. layerMask: number;
  14339. /**
  14340. * Define the list of render target the layer is visible into.
  14341. */
  14342. renderTargetTextures: RenderTargetTexture[];
  14343. /**
  14344. * Define if the layer is only used in renderTarget or if it also
  14345. * renders in the main frame buffer of the canvas.
  14346. */
  14347. renderOnlyInRenderTargetTextures: boolean;
  14348. private _scene;
  14349. private _vertexBuffers;
  14350. private _indexBuffer;
  14351. private _effect;
  14352. private _alphaTestEffect;
  14353. /**
  14354. * An event triggered when the layer is disposed.
  14355. */
  14356. onDisposeObservable: Observable<Layer>;
  14357. private _onDisposeObserver;
  14358. /**
  14359. * Back compatibility with callback before the onDisposeObservable existed.
  14360. * The set callback will be triggered when the layer has been disposed.
  14361. */
  14362. onDispose: () => void;
  14363. /**
  14364. * An event triggered before rendering the scene
  14365. */
  14366. onBeforeRenderObservable: Observable<Layer>;
  14367. private _onBeforeRenderObserver;
  14368. /**
  14369. * Back compatibility with callback before the onBeforeRenderObservable existed.
  14370. * The set callback will be triggered just before rendering the layer.
  14371. */
  14372. onBeforeRender: () => void;
  14373. /**
  14374. * An event triggered after rendering the scene
  14375. */
  14376. onAfterRenderObservable: Observable<Layer>;
  14377. private _onAfterRenderObserver;
  14378. /**
  14379. * Back compatibility with callback before the onAfterRenderObservable existed.
  14380. * The set callback will be triggered just after rendering the layer.
  14381. */
  14382. onAfterRender: () => void;
  14383. /**
  14384. * Instantiates a new layer.
  14385. * This represents a full screen 2d layer.
  14386. * This can be useful to display a picture in the background of your scene for instance.
  14387. * @see https://www.babylonjs-playground.com/#08A2BS#1
  14388. * @param name Define the name of the layer in the scene
  14389. * @param imgUrl Define the url of the texture to display in the layer
  14390. * @param scene Define the scene the layer belongs to
  14391. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  14392. * @param color Defines a color for the layer
  14393. */
  14394. constructor(
  14395. /**
  14396. * Define the name of the layer.
  14397. */
  14398. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  14399. private _createIndexBuffer;
  14400. /** @hidden */
  14401. _rebuild(): void;
  14402. /**
  14403. * Renders the layer in the scene.
  14404. */
  14405. render(): void;
  14406. /**
  14407. * Disposes and releases the associated ressources.
  14408. */
  14409. dispose(): void;
  14410. }
  14411. }
  14412. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  14413. import { Scene } from "babylonjs/scene";
  14414. import { ISceneComponent } from "babylonjs/sceneComponent";
  14415. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  14416. module "babylonjs/abstractScene" {
  14417. interface AbstractScene {
  14418. /**
  14419. * The list of procedural textures added to the scene
  14420. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14421. */
  14422. proceduralTextures: Array<ProceduralTexture>;
  14423. }
  14424. }
  14425. /**
  14426. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  14427. * in a given scene.
  14428. */
  14429. export class ProceduralTextureSceneComponent implements ISceneComponent {
  14430. /**
  14431. * The component name helpfull to identify the component in the list of scene components.
  14432. */
  14433. readonly name: string;
  14434. /**
  14435. * The scene the component belongs to.
  14436. */
  14437. scene: Scene;
  14438. /**
  14439. * Creates a new instance of the component for the given scene
  14440. * @param scene Defines the scene to register the component in
  14441. */
  14442. constructor(scene: Scene);
  14443. /**
  14444. * Registers the component in a given scene
  14445. */
  14446. register(): void;
  14447. /**
  14448. * Rebuilds the elements related to this component in case of
  14449. * context lost for instance.
  14450. */
  14451. rebuild(): void;
  14452. /**
  14453. * Disposes the component and the associated ressources.
  14454. */
  14455. dispose(): void;
  14456. private _beforeClear;
  14457. }
  14458. }
  14459. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  14460. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  14461. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  14462. module "babylonjs/Engines/engine" {
  14463. interface Engine {
  14464. /**
  14465. * Creates a new render target cube texture
  14466. * @param size defines the size of the texture
  14467. * @param options defines the options used to create the texture
  14468. * @returns a new render target cube texture stored in an InternalTexture
  14469. */
  14470. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  14471. }
  14472. }
  14473. }
  14474. declare module "babylonjs/Shaders/procedural.vertex" {
  14475. /** @hidden */
  14476. export var proceduralVertexShader: {
  14477. name: string;
  14478. shader: string;
  14479. };
  14480. }
  14481. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  14482. import { Observable } from "babylonjs/Misc/observable";
  14483. import { Nullable } from "babylonjs/types";
  14484. import { Scene } from "babylonjs/scene";
  14485. import { Matrix, Vector3, Vector2, Color3, Color4 } from "babylonjs/Maths/math";
  14486. import { Effect } from "babylonjs/Materials/effect";
  14487. import { Texture } from "babylonjs/Materials/Textures/texture";
  14488. import "babylonjs/Engines/Extensions/engine.renderTarget";
  14489. import "babylonjs/Shaders/procedural.vertex";
  14490. /**
  14491. * 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.
  14492. * This is the base class of any Procedural texture and contains most of the shareable code.
  14493. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14494. */
  14495. export class ProceduralTexture extends Texture {
  14496. isCube: boolean;
  14497. /**
  14498. * Define if the texture is enabled or not (disabled texture will not render)
  14499. */
  14500. isEnabled: boolean;
  14501. /**
  14502. * Define if the texture must be cleared before rendering (default is true)
  14503. */
  14504. autoClear: boolean;
  14505. /**
  14506. * Callback called when the texture is generated
  14507. */
  14508. onGenerated: () => void;
  14509. /**
  14510. * Event raised when the texture is generated
  14511. */
  14512. onGeneratedObservable: Observable<ProceduralTexture>;
  14513. /** @hidden */
  14514. _generateMipMaps: boolean;
  14515. /** @hidden **/
  14516. _effect: Effect;
  14517. /** @hidden */
  14518. _textures: {
  14519. [key: string]: Texture;
  14520. };
  14521. private _size;
  14522. private _currentRefreshId;
  14523. private _refreshRate;
  14524. private _vertexBuffers;
  14525. private _indexBuffer;
  14526. private _uniforms;
  14527. private _samplers;
  14528. private _fragment;
  14529. private _floats;
  14530. private _ints;
  14531. private _floatsArrays;
  14532. private _colors3;
  14533. private _colors4;
  14534. private _vectors2;
  14535. private _vectors3;
  14536. private _matrices;
  14537. private _fallbackTexture;
  14538. private _fallbackTextureUsed;
  14539. private _engine;
  14540. private _cachedDefines;
  14541. private _contentUpdateId;
  14542. private _contentData;
  14543. /**
  14544. * Instantiates a new procedural texture.
  14545. * 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.
  14546. * This is the base class of any Procedural texture and contains most of the shareable code.
  14547. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14548. * @param name Define the name of the texture
  14549. * @param size Define the size of the texture to create
  14550. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  14551. * @param scene Define the scene the texture belongs to
  14552. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  14553. * @param generateMipMaps Define if the texture should creates mip maps or not
  14554. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  14555. */
  14556. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  14557. /**
  14558. * The effect that is created when initializing the post process.
  14559. * @returns The created effect corrisponding the the postprocess.
  14560. */
  14561. getEffect(): Effect;
  14562. /**
  14563. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  14564. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  14565. */
  14566. getContent(): Nullable<ArrayBufferView>;
  14567. private _createIndexBuffer;
  14568. /** @hidden */
  14569. _rebuild(): void;
  14570. /**
  14571. * Resets the texture in order to recreate its associated resources.
  14572. * This can be called in case of context loss
  14573. */
  14574. reset(): void;
  14575. protected _getDefines(): string;
  14576. /**
  14577. * Is the texture ready to be used ? (rendered at least once)
  14578. * @returns true if ready, otherwise, false.
  14579. */
  14580. isReady(): boolean;
  14581. /**
  14582. * Resets the refresh counter of the texture and start bak from scratch.
  14583. * Could be useful to regenerate the texture if it is setup to render only once.
  14584. */
  14585. resetRefreshCounter(): void;
  14586. /**
  14587. * Set the fragment shader to use in order to render the texture.
  14588. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  14589. */
  14590. setFragment(fragment: any): void;
  14591. /**
  14592. * Define the refresh rate of the texture or the rendering frequency.
  14593. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  14594. */
  14595. refreshRate: number;
  14596. /** @hidden */
  14597. _shouldRender(): boolean;
  14598. /**
  14599. * Get the size the texture is rendering at.
  14600. * @returns the size (texture is always squared)
  14601. */
  14602. getRenderSize(): number;
  14603. /**
  14604. * Resize the texture to new value.
  14605. * @param size Define the new size the texture should have
  14606. * @param generateMipMaps Define whether the new texture should create mip maps
  14607. */
  14608. resize(size: number, generateMipMaps: boolean): void;
  14609. private _checkUniform;
  14610. /**
  14611. * Set a texture in the shader program used to render.
  14612. * @param name Define the name of the uniform samplers as defined in the shader
  14613. * @param texture Define the texture to bind to this sampler
  14614. * @return the texture itself allowing "fluent" like uniform updates
  14615. */
  14616. setTexture(name: string, texture: Texture): ProceduralTexture;
  14617. /**
  14618. * Set a float in the shader.
  14619. * @param name Define the name of the uniform as defined in the shader
  14620. * @param value Define the value to give to the uniform
  14621. * @return the texture itself allowing "fluent" like uniform updates
  14622. */
  14623. setFloat(name: string, value: number): ProceduralTexture;
  14624. /**
  14625. * Set a int in the shader.
  14626. * @param name Define the name of the uniform as defined in the shader
  14627. * @param value Define the value to give to the uniform
  14628. * @return the texture itself allowing "fluent" like uniform updates
  14629. */
  14630. setInt(name: string, value: number): ProceduralTexture;
  14631. /**
  14632. * Set an array of floats in the shader.
  14633. * @param name Define the name of the uniform as defined in the shader
  14634. * @param value Define the value to give to the uniform
  14635. * @return the texture itself allowing "fluent" like uniform updates
  14636. */
  14637. setFloats(name: string, value: number[]): ProceduralTexture;
  14638. /**
  14639. * Set a vec3 in the shader from a Color3.
  14640. * @param name Define the name of the uniform as defined in the shader
  14641. * @param value Define the value to give to the uniform
  14642. * @return the texture itself allowing "fluent" like uniform updates
  14643. */
  14644. setColor3(name: string, value: Color3): ProceduralTexture;
  14645. /**
  14646. * Set a vec4 in the shader from a Color4.
  14647. * @param name Define the name of the uniform as defined in the shader
  14648. * @param value Define the value to give to the uniform
  14649. * @return the texture itself allowing "fluent" like uniform updates
  14650. */
  14651. setColor4(name: string, value: Color4): ProceduralTexture;
  14652. /**
  14653. * Set a vec2 in the shader from a Vector2.
  14654. * @param name Define the name of the uniform as defined in the shader
  14655. * @param value Define the value to give to the uniform
  14656. * @return the texture itself allowing "fluent" like uniform updates
  14657. */
  14658. setVector2(name: string, value: Vector2): ProceduralTexture;
  14659. /**
  14660. * Set a vec3 in the shader from a Vector3.
  14661. * @param name Define the name of the uniform as defined in the shader
  14662. * @param value Define the value to give to the uniform
  14663. * @return the texture itself allowing "fluent" like uniform updates
  14664. */
  14665. setVector3(name: string, value: Vector3): ProceduralTexture;
  14666. /**
  14667. * Set a mat4 in the shader from a MAtrix.
  14668. * @param name Define the name of the uniform as defined in the shader
  14669. * @param value Define the value to give to the uniform
  14670. * @return the texture itself allowing "fluent" like uniform updates
  14671. */
  14672. setMatrix(name: string, value: Matrix): ProceduralTexture;
  14673. /**
  14674. * Render the texture to its associated render target.
  14675. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  14676. */
  14677. render(useCameraPostProcess?: boolean): void;
  14678. /**
  14679. * Clone the texture.
  14680. * @returns the cloned texture
  14681. */
  14682. clone(): ProceduralTexture;
  14683. /**
  14684. * Dispose the texture and release its asoociated resources.
  14685. */
  14686. dispose(): void;
  14687. }
  14688. }
  14689. declare module "babylonjs/Particles/baseParticleSystem" {
  14690. import { Nullable } from "babylonjs/types";
  14691. import { Color4, Vector2, Vector3 } from "babylonjs/Maths/math";
  14692. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14693. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  14694. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  14695. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  14696. import { Scene } from "babylonjs/scene";
  14697. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/tools";
  14698. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  14699. import { Texture } from "babylonjs/Materials/Textures/texture";
  14700. import { Animation } from "babylonjs/Animations/animation";
  14701. /**
  14702. * This represents the base class for particle system in Babylon.
  14703. * 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.
  14704. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14705. * @example https://doc.babylonjs.com/babylon101/particles
  14706. */
  14707. export class BaseParticleSystem {
  14708. /**
  14709. * Source color is added to the destination color without alpha affecting the result
  14710. */
  14711. static BLENDMODE_ONEONE: number;
  14712. /**
  14713. * Blend current color and particle color using particle’s alpha
  14714. */
  14715. static BLENDMODE_STANDARD: number;
  14716. /**
  14717. * Add current color and particle color multiplied by particle’s alpha
  14718. */
  14719. static BLENDMODE_ADD: number;
  14720. /**
  14721. * Multiply current color with particle color
  14722. */
  14723. static BLENDMODE_MULTIPLY: number;
  14724. /**
  14725. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  14726. */
  14727. static BLENDMODE_MULTIPLYADD: number;
  14728. /**
  14729. * List of animations used by the particle system.
  14730. */
  14731. animations: Animation[];
  14732. /**
  14733. * The id of the Particle system.
  14734. */
  14735. id: string;
  14736. /**
  14737. * The friendly name of the Particle system.
  14738. */
  14739. name: string;
  14740. /**
  14741. * The rendering group used by the Particle system to chose when to render.
  14742. */
  14743. renderingGroupId: number;
  14744. /**
  14745. * The emitter represents the Mesh or position we are attaching the particle system to.
  14746. */
  14747. emitter: Nullable<AbstractMesh | Vector3>;
  14748. /**
  14749. * The maximum number of particles to emit per frame
  14750. */
  14751. emitRate: number;
  14752. /**
  14753. * If you want to launch only a few particles at once, that can be done, as well.
  14754. */
  14755. manualEmitCount: number;
  14756. /**
  14757. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14758. */
  14759. updateSpeed: number;
  14760. /**
  14761. * The amount of time the particle system is running (depends of the overall update speed).
  14762. */
  14763. targetStopDuration: number;
  14764. /**
  14765. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14766. */
  14767. disposeOnStop: boolean;
  14768. /**
  14769. * Minimum power of emitting particles.
  14770. */
  14771. minEmitPower: number;
  14772. /**
  14773. * Maximum power of emitting particles.
  14774. */
  14775. maxEmitPower: number;
  14776. /**
  14777. * Minimum life time of emitting particles.
  14778. */
  14779. minLifeTime: number;
  14780. /**
  14781. * Maximum life time of emitting particles.
  14782. */
  14783. maxLifeTime: number;
  14784. /**
  14785. * Minimum Size of emitting particles.
  14786. */
  14787. minSize: number;
  14788. /**
  14789. * Maximum Size of emitting particles.
  14790. */
  14791. maxSize: number;
  14792. /**
  14793. * Minimum scale of emitting particles on X axis.
  14794. */
  14795. minScaleX: number;
  14796. /**
  14797. * Maximum scale of emitting particles on X axis.
  14798. */
  14799. maxScaleX: number;
  14800. /**
  14801. * Minimum scale of emitting particles on Y axis.
  14802. */
  14803. minScaleY: number;
  14804. /**
  14805. * Maximum scale of emitting particles on Y axis.
  14806. */
  14807. maxScaleY: number;
  14808. /**
  14809. * Gets or sets the minimal initial rotation in radians.
  14810. */
  14811. minInitialRotation: number;
  14812. /**
  14813. * Gets or sets the maximal initial rotation in radians.
  14814. */
  14815. maxInitialRotation: number;
  14816. /**
  14817. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14818. */
  14819. minAngularSpeed: number;
  14820. /**
  14821. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14822. */
  14823. maxAngularSpeed: number;
  14824. /**
  14825. * The texture used to render each particle. (this can be a spritesheet)
  14826. */
  14827. particleTexture: Nullable<Texture>;
  14828. /**
  14829. * The layer mask we are rendering the particles through.
  14830. */
  14831. layerMask: number;
  14832. /**
  14833. * This can help using your own shader to render the particle system.
  14834. * The according effect will be created
  14835. */
  14836. customShader: any;
  14837. /**
  14838. * By default particle system starts as soon as they are created. This prevents the
  14839. * automatic start to happen and let you decide when to start emitting particles.
  14840. */
  14841. preventAutoStart: boolean;
  14842. private _noiseTexture;
  14843. /**
  14844. * Gets or sets a texture used to add random noise to particle positions
  14845. */
  14846. noiseTexture: Nullable<ProceduralTexture>;
  14847. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14848. noiseStrength: Vector3;
  14849. /**
  14850. * Callback triggered when the particle animation is ending.
  14851. */
  14852. onAnimationEnd: Nullable<() => void>;
  14853. /**
  14854. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  14855. */
  14856. blendMode: number;
  14857. /**
  14858. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  14859. * to override the particles.
  14860. */
  14861. forceDepthWrite: boolean;
  14862. /** 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 */
  14863. preWarmCycles: number;
  14864. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  14865. preWarmStepOffset: number;
  14866. /**
  14867. * 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)
  14868. */
  14869. spriteCellChangeSpeed: number;
  14870. /**
  14871. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14872. */
  14873. startSpriteCellID: number;
  14874. /**
  14875. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14876. */
  14877. endSpriteCellID: number;
  14878. /**
  14879. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14880. */
  14881. spriteCellWidth: number;
  14882. /**
  14883. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14884. */
  14885. spriteCellHeight: number;
  14886. /**
  14887. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14888. */
  14889. spriteRandomStartCell: boolean;
  14890. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14891. translationPivot: Vector2;
  14892. /** @hidden */
  14893. protected _isAnimationSheetEnabled: boolean;
  14894. /**
  14895. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14896. */
  14897. beginAnimationOnStart: boolean;
  14898. /**
  14899. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14900. */
  14901. beginAnimationFrom: number;
  14902. /**
  14903. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14904. */
  14905. beginAnimationTo: number;
  14906. /**
  14907. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14908. */
  14909. beginAnimationLoop: boolean;
  14910. /**
  14911. * Gets or sets a world offset applied to all particles
  14912. */
  14913. worldOffset: Vector3;
  14914. /**
  14915. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  14916. */
  14917. isAnimationSheetEnabled: boolean;
  14918. /**
  14919. * Get hosting scene
  14920. * @returns the scene
  14921. */
  14922. getScene(): Scene;
  14923. /**
  14924. * You can use gravity if you want to give an orientation to your particles.
  14925. */
  14926. gravity: Vector3;
  14927. protected _colorGradients: Nullable<Array<ColorGradient>>;
  14928. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  14929. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  14930. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  14931. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  14932. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  14933. protected _dragGradients: Nullable<Array<FactorGradient>>;
  14934. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  14935. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  14936. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  14937. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  14938. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  14939. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  14940. /**
  14941. * Defines the delay in milliseconds before starting the system (0 by default)
  14942. */
  14943. startDelay: number;
  14944. /**
  14945. * Gets the current list of drag gradients.
  14946. * You must use addDragGradient and removeDragGradient to udpate this list
  14947. * @returns the list of drag gradients
  14948. */
  14949. getDragGradients(): Nullable<Array<FactorGradient>>;
  14950. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14951. limitVelocityDamping: number;
  14952. /**
  14953. * Gets the current list of limit velocity gradients.
  14954. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14955. * @returns the list of limit velocity gradients
  14956. */
  14957. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14958. /**
  14959. * Gets the current list of color gradients.
  14960. * You must use addColorGradient and removeColorGradient to udpate this list
  14961. * @returns the list of color gradients
  14962. */
  14963. getColorGradients(): Nullable<Array<ColorGradient>>;
  14964. /**
  14965. * Gets the current list of size gradients.
  14966. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14967. * @returns the list of size gradients
  14968. */
  14969. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14970. /**
  14971. * Gets the current list of color remap gradients.
  14972. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14973. * @returns the list of color remap gradients
  14974. */
  14975. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14976. /**
  14977. * Gets the current list of alpha remap gradients.
  14978. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14979. * @returns the list of alpha remap gradients
  14980. */
  14981. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14982. /**
  14983. * Gets the current list of life time gradients.
  14984. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14985. * @returns the list of life time gradients
  14986. */
  14987. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14988. /**
  14989. * Gets the current list of angular speed gradients.
  14990. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14991. * @returns the list of angular speed gradients
  14992. */
  14993. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14994. /**
  14995. * Gets the current list of velocity gradients.
  14996. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14997. * @returns the list of velocity gradients
  14998. */
  14999. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  15000. /**
  15001. * Gets the current list of start size gradients.
  15002. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  15003. * @returns the list of start size gradients
  15004. */
  15005. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  15006. /**
  15007. * Gets the current list of emit rate gradients.
  15008. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  15009. * @returns the list of emit rate gradients
  15010. */
  15011. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  15012. /**
  15013. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15014. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15015. */
  15016. direction1: Vector3;
  15017. /**
  15018. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15019. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15020. */
  15021. direction2: Vector3;
  15022. /**
  15023. * 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.
  15024. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15025. */
  15026. minEmitBox: Vector3;
  15027. /**
  15028. * 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.
  15029. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15030. */
  15031. maxEmitBox: Vector3;
  15032. /**
  15033. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  15034. */
  15035. color1: Color4;
  15036. /**
  15037. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  15038. */
  15039. color2: Color4;
  15040. /**
  15041. * Color the particle will have at the end of its lifetime
  15042. */
  15043. colorDead: Color4;
  15044. /**
  15045. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  15046. */
  15047. textureMask: Color4;
  15048. /**
  15049. * The particle emitter type defines the emitter used by the particle system.
  15050. * It can be for example box, sphere, or cone...
  15051. */
  15052. particleEmitterType: IParticleEmitterType;
  15053. /** @hidden */
  15054. _isSubEmitter: boolean;
  15055. /**
  15056. * Gets or sets the billboard mode to use when isBillboardBased = true.
  15057. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  15058. */
  15059. billboardMode: number;
  15060. protected _isBillboardBased: boolean;
  15061. /**
  15062. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  15063. */
  15064. isBillboardBased: boolean;
  15065. /**
  15066. * The scene the particle system belongs to.
  15067. */
  15068. protected _scene: Scene;
  15069. /**
  15070. * Local cache of defines for image processing.
  15071. */
  15072. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  15073. /**
  15074. * Default configuration related to image processing available in the standard Material.
  15075. */
  15076. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  15077. /**
  15078. * Gets the image processing configuration used either in this material.
  15079. */
  15080. /**
  15081. * Sets the Default image processing configuration used either in the this material.
  15082. *
  15083. * If sets to null, the scene one is in use.
  15084. */
  15085. imageProcessingConfiguration: ImageProcessingConfiguration;
  15086. /**
  15087. * Attaches a new image processing configuration to the Standard Material.
  15088. * @param configuration
  15089. */
  15090. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  15091. /** @hidden */
  15092. protected _reset(): void;
  15093. /** @hidden */
  15094. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  15095. /**
  15096. * Instantiates a particle system.
  15097. * 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.
  15098. * @param name The name of the particle system
  15099. */
  15100. constructor(name: string);
  15101. /**
  15102. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  15103. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15104. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15105. * @returns the emitter
  15106. */
  15107. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  15108. /**
  15109. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  15110. * @param radius The radius of the hemisphere to emit from
  15111. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15112. * @returns the emitter
  15113. */
  15114. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  15115. /**
  15116. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  15117. * @param radius The radius of the sphere to emit from
  15118. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15119. * @returns the emitter
  15120. */
  15121. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  15122. /**
  15123. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  15124. * @param radius The radius of the sphere to emit from
  15125. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  15126. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  15127. * @returns the emitter
  15128. */
  15129. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  15130. /**
  15131. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  15132. * @param radius The radius of the emission cylinder
  15133. * @param height The height of the emission cylinder
  15134. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  15135. * @param directionRandomizer How much to randomize the particle direction [0-1]
  15136. * @returns the emitter
  15137. */
  15138. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  15139. /**
  15140. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  15141. * @param radius The radius of the cylinder to emit from
  15142. * @param height The height of the emission cylinder
  15143. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15144. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  15145. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  15146. * @returns the emitter
  15147. */
  15148. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  15149. /**
  15150. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  15151. * @param radius The radius of the cone to emit from
  15152. * @param angle The base angle of the cone
  15153. * @returns the emitter
  15154. */
  15155. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  15156. /**
  15157. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  15158. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15159. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15160. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15161. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15162. * @returns the emitter
  15163. */
  15164. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  15165. }
  15166. }
  15167. declare module "babylonjs/Particles/subEmitter" {
  15168. import { Scene } from "babylonjs/scene";
  15169. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  15170. /**
  15171. * Type of sub emitter
  15172. */
  15173. export enum SubEmitterType {
  15174. /**
  15175. * Attached to the particle over it's lifetime
  15176. */
  15177. ATTACHED = 0,
  15178. /**
  15179. * Created when the particle dies
  15180. */
  15181. END = 1
  15182. }
  15183. /**
  15184. * Sub emitter class used to emit particles from an existing particle
  15185. */
  15186. export class SubEmitter {
  15187. /**
  15188. * the particle system to be used by the sub emitter
  15189. */
  15190. particleSystem: ParticleSystem;
  15191. /**
  15192. * Type of the submitter (Default: END)
  15193. */
  15194. type: SubEmitterType;
  15195. /**
  15196. * 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)
  15197. * Note: This only is supported when using an emitter of type Mesh
  15198. */
  15199. inheritDirection: boolean;
  15200. /**
  15201. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  15202. */
  15203. inheritedVelocityAmount: number;
  15204. /**
  15205. * Creates a sub emitter
  15206. * @param particleSystem the particle system to be used by the sub emitter
  15207. */
  15208. constructor(
  15209. /**
  15210. * the particle system to be used by the sub emitter
  15211. */
  15212. particleSystem: ParticleSystem);
  15213. /**
  15214. * Clones the sub emitter
  15215. * @returns the cloned sub emitter
  15216. */
  15217. clone(): SubEmitter;
  15218. /**
  15219. * Serialize current object to a JSON object
  15220. * @returns the serialized object
  15221. */
  15222. serialize(): any;
  15223. /** @hidden */
  15224. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  15225. /**
  15226. * Creates a new SubEmitter from a serialized JSON version
  15227. * @param serializationObject defines the JSON object to read from
  15228. * @param scene defines the hosting scene
  15229. * @param rootUrl defines the rootUrl for data loading
  15230. * @returns a new SubEmitter
  15231. */
  15232. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  15233. /** Release associated resources */
  15234. dispose(): void;
  15235. }
  15236. }
  15237. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  15238. /** @hidden */
  15239. export var clipPlaneFragmentDeclaration: {
  15240. name: string;
  15241. shader: string;
  15242. };
  15243. }
  15244. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  15245. /** @hidden */
  15246. export var imageProcessingDeclaration: {
  15247. name: string;
  15248. shader: string;
  15249. };
  15250. }
  15251. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  15252. /** @hidden */
  15253. export var imageProcessingFunctions: {
  15254. name: string;
  15255. shader: string;
  15256. };
  15257. }
  15258. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  15259. /** @hidden */
  15260. export var clipPlaneFragment: {
  15261. name: string;
  15262. shader: string;
  15263. };
  15264. }
  15265. declare module "babylonjs/Shaders/particles.fragment" {
  15266. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  15267. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  15268. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  15269. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  15270. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  15271. /** @hidden */
  15272. export var particlesPixelShader: {
  15273. name: string;
  15274. shader: string;
  15275. };
  15276. }
  15277. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  15278. /** @hidden */
  15279. export var clipPlaneVertexDeclaration: {
  15280. name: string;
  15281. shader: string;
  15282. };
  15283. }
  15284. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  15285. /** @hidden */
  15286. export var clipPlaneVertex: {
  15287. name: string;
  15288. shader: string;
  15289. };
  15290. }
  15291. declare module "babylonjs/Shaders/particles.vertex" {
  15292. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  15293. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  15294. /** @hidden */
  15295. export var particlesVertexShader: {
  15296. name: string;
  15297. shader: string;
  15298. };
  15299. }
  15300. declare module "babylonjs/Particles/particleSystem" {
  15301. import { Nullable } from "babylonjs/types";
  15302. import { IAnimatable, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  15303. import { Observable } from "babylonjs/Misc/observable";
  15304. import { Color4, Color3, Vector3, Matrix } from "babylonjs/Maths/math";
  15305. import { Effect } from "babylonjs/Materials/effect";
  15306. import { Scene, IDisposable } from "babylonjs/scene";
  15307. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  15308. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  15309. import { Particle } from "babylonjs/Particles/particle";
  15310. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  15311. import "babylonjs/Shaders/particles.fragment";
  15312. import "babylonjs/Shaders/particles.vertex";
  15313. /**
  15314. * This represents a particle system in Babylon.
  15315. * 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.
  15316. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  15317. * @example https://doc.babylonjs.com/babylon101/particles
  15318. */
  15319. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  15320. /**
  15321. * Billboard mode will only apply to Y axis
  15322. */
  15323. static readonly BILLBOARDMODE_Y: number;
  15324. /**
  15325. * Billboard mode will apply to all axes
  15326. */
  15327. static readonly BILLBOARDMODE_ALL: number;
  15328. /**
  15329. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  15330. */
  15331. static readonly BILLBOARDMODE_STRETCHED: number;
  15332. /**
  15333. * This function can be defined to provide custom update for active particles.
  15334. * This function will be called instead of regular update (age, position, color, etc.).
  15335. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  15336. */
  15337. updateFunction: (particles: Particle[]) => void;
  15338. private _emitterWorldMatrix;
  15339. /**
  15340. * This function can be defined to specify initial direction for every new particle.
  15341. * It by default use the emitterType defined function
  15342. */
  15343. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  15344. /**
  15345. * This function can be defined to specify initial position for every new particle.
  15346. * It by default use the emitterType defined function
  15347. */
  15348. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  15349. /**
  15350. * @hidden
  15351. */
  15352. _inheritedVelocityOffset: Vector3;
  15353. /**
  15354. * An event triggered when the system is disposed
  15355. */
  15356. onDisposeObservable: Observable<ParticleSystem>;
  15357. private _onDisposeObserver;
  15358. /**
  15359. * Sets a callback that will be triggered when the system is disposed
  15360. */
  15361. onDispose: () => void;
  15362. private _particles;
  15363. private _epsilon;
  15364. private _capacity;
  15365. private _stockParticles;
  15366. private _newPartsExcess;
  15367. private _vertexData;
  15368. private _vertexBuffer;
  15369. private _vertexBuffers;
  15370. private _spriteBuffer;
  15371. private _indexBuffer;
  15372. private _effect;
  15373. private _customEffect;
  15374. private _cachedDefines;
  15375. private _scaledColorStep;
  15376. private _colorDiff;
  15377. private _scaledDirection;
  15378. private _scaledGravity;
  15379. private _currentRenderId;
  15380. private _alive;
  15381. private _useInstancing;
  15382. private _started;
  15383. private _stopped;
  15384. private _actualFrame;
  15385. private _scaledUpdateSpeed;
  15386. private _vertexBufferSize;
  15387. /** @hidden */
  15388. _currentEmitRateGradient: Nullable<FactorGradient>;
  15389. /** @hidden */
  15390. _currentEmitRate1: number;
  15391. /** @hidden */
  15392. _currentEmitRate2: number;
  15393. /** @hidden */
  15394. _currentStartSizeGradient: Nullable<FactorGradient>;
  15395. /** @hidden */
  15396. _currentStartSize1: number;
  15397. /** @hidden */
  15398. _currentStartSize2: number;
  15399. private readonly _rawTextureWidth;
  15400. private _rampGradientsTexture;
  15401. private _useRampGradients;
  15402. /** Gets or sets a boolean indicating that ramp gradients must be used
  15403. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  15404. */
  15405. useRampGradients: boolean;
  15406. /**
  15407. * 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.
  15408. * 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: [])
  15409. */
  15410. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  15411. private _subEmitters;
  15412. /**
  15413. * @hidden
  15414. * If the particle systems emitter should be disposed when the particle system is disposed
  15415. */
  15416. _disposeEmitterOnDispose: boolean;
  15417. /**
  15418. * The current active Sub-systems, this property is used by the root particle system only.
  15419. */
  15420. activeSubSystems: Array<ParticleSystem>;
  15421. private _rootParticleSystem;
  15422. /**
  15423. * Gets the current list of active particles
  15424. */
  15425. readonly particles: Particle[];
  15426. /**
  15427. * Returns the string "ParticleSystem"
  15428. * @returns a string containing the class name
  15429. */
  15430. getClassName(): string;
  15431. /**
  15432. * Instantiates a particle system.
  15433. * 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.
  15434. * @param name The name of the particle system
  15435. * @param capacity The max number of particles alive at the same time
  15436. * @param scene The scene the particle system belongs to
  15437. * @param customEffect a custom effect used to change the way particles are rendered by default
  15438. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  15439. * @param epsilon Offset used to render the particles
  15440. */
  15441. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  15442. private _addFactorGradient;
  15443. private _removeFactorGradient;
  15444. /**
  15445. * Adds a new life time gradient
  15446. * @param gradient defines the gradient to use (between 0 and 1)
  15447. * @param factor defines the life time factor to affect to the specified gradient
  15448. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15449. * @returns the current particle system
  15450. */
  15451. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15452. /**
  15453. * Remove a specific life time gradient
  15454. * @param gradient defines the gradient to remove
  15455. * @returns the current particle system
  15456. */
  15457. removeLifeTimeGradient(gradient: number): IParticleSystem;
  15458. /**
  15459. * Adds a new size gradient
  15460. * @param gradient defines the gradient to use (between 0 and 1)
  15461. * @param factor defines the size factor to affect to the specified gradient
  15462. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15463. * @returns the current particle system
  15464. */
  15465. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15466. /**
  15467. * Remove a specific size gradient
  15468. * @param gradient defines the gradient to remove
  15469. * @returns the current particle system
  15470. */
  15471. removeSizeGradient(gradient: number): IParticleSystem;
  15472. /**
  15473. * Adds a new color remap gradient
  15474. * @param gradient defines the gradient to use (between 0 and 1)
  15475. * @param min defines the color remap minimal range
  15476. * @param max defines the color remap maximal range
  15477. * @returns the current particle system
  15478. */
  15479. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15480. /**
  15481. * Remove a specific color remap gradient
  15482. * @param gradient defines the gradient to remove
  15483. * @returns the current particle system
  15484. */
  15485. removeColorRemapGradient(gradient: number): IParticleSystem;
  15486. /**
  15487. * Adds a new alpha remap gradient
  15488. * @param gradient defines the gradient to use (between 0 and 1)
  15489. * @param min defines the alpha remap minimal range
  15490. * @param max defines the alpha remap maximal range
  15491. * @returns the current particle system
  15492. */
  15493. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15494. /**
  15495. * Remove a specific alpha remap gradient
  15496. * @param gradient defines the gradient to remove
  15497. * @returns the current particle system
  15498. */
  15499. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  15500. /**
  15501. * Adds a new angular speed gradient
  15502. * @param gradient defines the gradient to use (between 0 and 1)
  15503. * @param factor defines the angular speed to affect to the specified gradient
  15504. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15505. * @returns the current particle system
  15506. */
  15507. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15508. /**
  15509. * Remove a specific angular speed gradient
  15510. * @param gradient defines the gradient to remove
  15511. * @returns the current particle system
  15512. */
  15513. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  15514. /**
  15515. * Adds a new velocity gradient
  15516. * @param gradient defines the gradient to use (between 0 and 1)
  15517. * @param factor defines the velocity to affect to the specified gradient
  15518. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15519. * @returns the current particle system
  15520. */
  15521. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15522. /**
  15523. * Remove a specific velocity gradient
  15524. * @param gradient defines the gradient to remove
  15525. * @returns the current particle system
  15526. */
  15527. removeVelocityGradient(gradient: number): IParticleSystem;
  15528. /**
  15529. * Adds a new limit velocity gradient
  15530. * @param gradient defines the gradient to use (between 0 and 1)
  15531. * @param factor defines the limit velocity value to affect to the specified gradient
  15532. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15533. * @returns the current particle system
  15534. */
  15535. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15536. /**
  15537. * Remove a specific limit velocity gradient
  15538. * @param gradient defines the gradient to remove
  15539. * @returns the current particle system
  15540. */
  15541. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  15542. /**
  15543. * Adds a new drag gradient
  15544. * @param gradient defines the gradient to use (between 0 and 1)
  15545. * @param factor defines the drag value to affect to the specified gradient
  15546. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15547. * @returns the current particle system
  15548. */
  15549. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15550. /**
  15551. * Remove a specific drag gradient
  15552. * @param gradient defines the gradient to remove
  15553. * @returns the current particle system
  15554. */
  15555. removeDragGradient(gradient: number): IParticleSystem;
  15556. /**
  15557. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  15558. * @param gradient defines the gradient to use (between 0 and 1)
  15559. * @param factor defines the emit rate value to affect to the specified gradient
  15560. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15561. * @returns the current particle system
  15562. */
  15563. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15564. /**
  15565. * Remove a specific emit rate gradient
  15566. * @param gradient defines the gradient to remove
  15567. * @returns the current particle system
  15568. */
  15569. removeEmitRateGradient(gradient: number): IParticleSystem;
  15570. /**
  15571. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  15572. * @param gradient defines the gradient to use (between 0 and 1)
  15573. * @param factor defines the start size value to affect to the specified gradient
  15574. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15575. * @returns the current particle system
  15576. */
  15577. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15578. /**
  15579. * Remove a specific start size gradient
  15580. * @param gradient defines the gradient to remove
  15581. * @returns the current particle system
  15582. */
  15583. removeStartSizeGradient(gradient: number): IParticleSystem;
  15584. private _createRampGradientTexture;
  15585. /**
  15586. * Gets the current list of ramp gradients.
  15587. * You must use addRampGradient and removeRampGradient to udpate this list
  15588. * @returns the list of ramp gradients
  15589. */
  15590. getRampGradients(): Nullable<Array<Color3Gradient>>;
  15591. /**
  15592. * Adds a new ramp gradient used to remap particle colors
  15593. * @param gradient defines the gradient to use (between 0 and 1)
  15594. * @param color defines the color to affect to the specified gradient
  15595. * @returns the current particle system
  15596. */
  15597. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  15598. /**
  15599. * Remove a specific ramp gradient
  15600. * @param gradient defines the gradient to remove
  15601. * @returns the current particle system
  15602. */
  15603. removeRampGradient(gradient: number): ParticleSystem;
  15604. /**
  15605. * Adds a new color gradient
  15606. * @param gradient defines the gradient to use (between 0 and 1)
  15607. * @param color1 defines the color to affect to the specified gradient
  15608. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  15609. * @returns this particle system
  15610. */
  15611. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  15612. /**
  15613. * Remove a specific color gradient
  15614. * @param gradient defines the gradient to remove
  15615. * @returns this particle system
  15616. */
  15617. removeColorGradient(gradient: number): IParticleSystem;
  15618. private _fetchR;
  15619. protected _reset(): void;
  15620. private _resetEffect;
  15621. private _createVertexBuffers;
  15622. private _createIndexBuffer;
  15623. /**
  15624. * Gets the maximum number of particles active at the same time.
  15625. * @returns The max number of active particles.
  15626. */
  15627. getCapacity(): number;
  15628. /**
  15629. * Gets whether there are still active particles in the system.
  15630. * @returns True if it is alive, otherwise false.
  15631. */
  15632. isAlive(): boolean;
  15633. /**
  15634. * Gets if the system has been started. (Note: this will still be true after stop is called)
  15635. * @returns True if it has been started, otherwise false.
  15636. */
  15637. isStarted(): boolean;
  15638. private _prepareSubEmitterInternalArray;
  15639. /**
  15640. * Starts the particle system and begins to emit
  15641. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  15642. */
  15643. start(delay?: number): void;
  15644. /**
  15645. * Stops the particle system.
  15646. * @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.
  15647. */
  15648. stop(stopSubEmitters?: boolean): void;
  15649. /**
  15650. * Remove all active particles
  15651. */
  15652. reset(): void;
  15653. /**
  15654. * @hidden (for internal use only)
  15655. */
  15656. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  15657. /**
  15658. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  15659. * Its lifetime will start back at 0.
  15660. */
  15661. recycleParticle: (particle: Particle) => void;
  15662. private _stopSubEmitters;
  15663. private _createParticle;
  15664. private _removeFromRoot;
  15665. private _emitFromParticle;
  15666. private _update;
  15667. /** @hidden */
  15668. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  15669. /** @hidden */
  15670. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  15671. /** @hidden */
  15672. private _getEffect;
  15673. /**
  15674. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  15675. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  15676. */
  15677. animate(preWarmOnly?: boolean): void;
  15678. private _appendParticleVertices;
  15679. /**
  15680. * Rebuilds the particle system.
  15681. */
  15682. rebuild(): void;
  15683. /**
  15684. * Is this system ready to be used/rendered
  15685. * @return true if the system is ready
  15686. */
  15687. isReady(): boolean;
  15688. private _render;
  15689. /**
  15690. * Renders the particle system in its current state.
  15691. * @returns the current number of particles
  15692. */
  15693. render(): number;
  15694. /**
  15695. * Disposes the particle system and free the associated resources
  15696. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  15697. */
  15698. dispose(disposeTexture?: boolean): void;
  15699. /**
  15700. * Clones the particle system.
  15701. * @param name The name of the cloned object
  15702. * @param newEmitter The new emitter to use
  15703. * @returns the cloned particle system
  15704. */
  15705. clone(name: string, newEmitter: any): ParticleSystem;
  15706. /**
  15707. * Serializes the particle system to a JSON object.
  15708. * @returns the JSON object
  15709. */
  15710. serialize(): any;
  15711. /** @hidden */
  15712. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  15713. /** @hidden */
  15714. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  15715. /**
  15716. * Parses a JSON object to create a particle system.
  15717. * @param parsedParticleSystem The JSON object to parse
  15718. * @param scene The scene to create the particle system in
  15719. * @param rootUrl The root url to use to load external dependencies like texture
  15720. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  15721. * @returns the Parsed particle system
  15722. */
  15723. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  15724. }
  15725. }
  15726. declare module "babylonjs/Particles/particle" {
  15727. import { Nullable } from "babylonjs/types";
  15728. import { Color4, Vector2, Vector3, Vector4 } from "babylonjs/Maths/math";
  15729. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  15730. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  15731. import { ColorGradient, FactorGradient } from "babylonjs/Misc/tools";
  15732. /**
  15733. * A particle represents one of the element emitted by a particle system.
  15734. * This is mainly define by its coordinates, direction, velocity and age.
  15735. */
  15736. export class Particle {
  15737. /**
  15738. * The particle system the particle belongs to.
  15739. */
  15740. particleSystem: ParticleSystem;
  15741. private static _Count;
  15742. /**
  15743. * Unique ID of the particle
  15744. */
  15745. id: number;
  15746. /**
  15747. * The world position of the particle in the scene.
  15748. */
  15749. position: Vector3;
  15750. /**
  15751. * The world direction of the particle in the scene.
  15752. */
  15753. direction: Vector3;
  15754. /**
  15755. * The color of the particle.
  15756. */
  15757. color: Color4;
  15758. /**
  15759. * The color change of the particle per step.
  15760. */
  15761. colorStep: Color4;
  15762. /**
  15763. * Defines how long will the life of the particle be.
  15764. */
  15765. lifeTime: number;
  15766. /**
  15767. * The current age of the particle.
  15768. */
  15769. age: number;
  15770. /**
  15771. * The current size of the particle.
  15772. */
  15773. size: number;
  15774. /**
  15775. * The current scale of the particle.
  15776. */
  15777. scale: Vector2;
  15778. /**
  15779. * The current angle of the particle.
  15780. */
  15781. angle: number;
  15782. /**
  15783. * Defines how fast is the angle changing.
  15784. */
  15785. angularSpeed: number;
  15786. /**
  15787. * Defines the cell index used by the particle to be rendered from a sprite.
  15788. */
  15789. cellIndex: number;
  15790. /**
  15791. * The information required to support color remapping
  15792. */
  15793. remapData: Vector4;
  15794. /** @hidden */
  15795. _randomCellOffset?: number;
  15796. /** @hidden */
  15797. _initialDirection: Nullable<Vector3>;
  15798. /** @hidden */
  15799. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  15800. /** @hidden */
  15801. _initialStartSpriteCellID: number;
  15802. /** @hidden */
  15803. _initialEndSpriteCellID: number;
  15804. /** @hidden */
  15805. _currentColorGradient: Nullable<ColorGradient>;
  15806. /** @hidden */
  15807. _currentColor1: Color4;
  15808. /** @hidden */
  15809. _currentColor2: Color4;
  15810. /** @hidden */
  15811. _currentSizeGradient: Nullable<FactorGradient>;
  15812. /** @hidden */
  15813. _currentSize1: number;
  15814. /** @hidden */
  15815. _currentSize2: number;
  15816. /** @hidden */
  15817. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  15818. /** @hidden */
  15819. _currentAngularSpeed1: number;
  15820. /** @hidden */
  15821. _currentAngularSpeed2: number;
  15822. /** @hidden */
  15823. _currentVelocityGradient: Nullable<FactorGradient>;
  15824. /** @hidden */
  15825. _currentVelocity1: number;
  15826. /** @hidden */
  15827. _currentVelocity2: number;
  15828. /** @hidden */
  15829. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  15830. /** @hidden */
  15831. _currentLimitVelocity1: number;
  15832. /** @hidden */
  15833. _currentLimitVelocity2: number;
  15834. /** @hidden */
  15835. _currentDragGradient: Nullable<FactorGradient>;
  15836. /** @hidden */
  15837. _currentDrag1: number;
  15838. /** @hidden */
  15839. _currentDrag2: number;
  15840. /** @hidden */
  15841. _randomNoiseCoordinates1: Vector3;
  15842. /** @hidden */
  15843. _randomNoiseCoordinates2: Vector3;
  15844. /**
  15845. * Creates a new instance Particle
  15846. * @param particleSystem the particle system the particle belongs to
  15847. */
  15848. constructor(
  15849. /**
  15850. * The particle system the particle belongs to.
  15851. */
  15852. particleSystem: ParticleSystem);
  15853. private updateCellInfoFromSystem;
  15854. /**
  15855. * Defines how the sprite cell index is updated for the particle
  15856. */
  15857. updateCellIndex(): void;
  15858. /** @hidden */
  15859. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  15860. /** @hidden */
  15861. _inheritParticleInfoToSubEmitters(): void;
  15862. /** @hidden */
  15863. _reset(): void;
  15864. /**
  15865. * Copy the properties of particle to another one.
  15866. * @param other the particle to copy the information to.
  15867. */
  15868. copyTo(other: Particle): void;
  15869. }
  15870. }
  15871. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  15872. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15873. import { Effect } from "babylonjs/Materials/effect";
  15874. import { Particle } from "babylonjs/Particles/particle";
  15875. /**
  15876. * Particle emitter represents a volume emitting particles.
  15877. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  15878. */
  15879. export interface IParticleEmitterType {
  15880. /**
  15881. * Called by the particle System when the direction is computed for the created particle.
  15882. * @param worldMatrix is the world matrix of the particle system
  15883. * @param directionToUpdate is the direction vector to update with the result
  15884. * @param particle is the particle we are computed the direction for
  15885. */
  15886. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15887. /**
  15888. * Called by the particle System when the position is computed for the created particle.
  15889. * @param worldMatrix is the world matrix of the particle system
  15890. * @param positionToUpdate is the position vector to update with the result
  15891. * @param particle is the particle we are computed the position for
  15892. */
  15893. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15894. /**
  15895. * Clones the current emitter and returns a copy of it
  15896. * @returns the new emitter
  15897. */
  15898. clone(): IParticleEmitterType;
  15899. /**
  15900. * Called by the GPUParticleSystem to setup the update shader
  15901. * @param effect defines the update shader
  15902. */
  15903. applyToShader(effect: Effect): void;
  15904. /**
  15905. * Returns a string to use to update the GPU particles update shader
  15906. * @returns the effect defines string
  15907. */
  15908. getEffectDefines(): string;
  15909. /**
  15910. * Returns a string representing the class name
  15911. * @returns a string containing the class name
  15912. */
  15913. getClassName(): string;
  15914. /**
  15915. * Serializes the particle system to a JSON object.
  15916. * @returns the JSON object
  15917. */
  15918. serialize(): any;
  15919. /**
  15920. * Parse properties from a JSON object
  15921. * @param serializationObject defines the JSON object
  15922. */
  15923. parse(serializationObject: any): void;
  15924. }
  15925. }
  15926. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  15927. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15928. import { Effect } from "babylonjs/Materials/effect";
  15929. import { Particle } from "babylonjs/Particles/particle";
  15930. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15931. /**
  15932. * Particle emitter emitting particles from the inside of a box.
  15933. * It emits the particles randomly between 2 given directions.
  15934. */
  15935. export class BoxParticleEmitter implements IParticleEmitterType {
  15936. /**
  15937. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15938. */
  15939. direction1: Vector3;
  15940. /**
  15941. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15942. */
  15943. direction2: Vector3;
  15944. /**
  15945. * 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.
  15946. */
  15947. minEmitBox: Vector3;
  15948. /**
  15949. * 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.
  15950. */
  15951. maxEmitBox: Vector3;
  15952. /**
  15953. * Creates a new instance BoxParticleEmitter
  15954. */
  15955. constructor();
  15956. /**
  15957. * Called by the particle System when the direction is computed for the created particle.
  15958. * @param worldMatrix is the world matrix of the particle system
  15959. * @param directionToUpdate is the direction vector to update with the result
  15960. * @param particle is the particle we are computed the direction for
  15961. */
  15962. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15963. /**
  15964. * Called by the particle System when the position is computed for the created particle.
  15965. * @param worldMatrix is the world matrix of the particle system
  15966. * @param positionToUpdate is the position vector to update with the result
  15967. * @param particle is the particle we are computed the position for
  15968. */
  15969. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15970. /**
  15971. * Clones the current emitter and returns a copy of it
  15972. * @returns the new emitter
  15973. */
  15974. clone(): BoxParticleEmitter;
  15975. /**
  15976. * Called by the GPUParticleSystem to setup the update shader
  15977. * @param effect defines the update shader
  15978. */
  15979. applyToShader(effect: Effect): void;
  15980. /**
  15981. * Returns a string to use to update the GPU particles update shader
  15982. * @returns a string containng the defines string
  15983. */
  15984. getEffectDefines(): string;
  15985. /**
  15986. * Returns the string "BoxParticleEmitter"
  15987. * @returns a string containing the class name
  15988. */
  15989. getClassName(): string;
  15990. /**
  15991. * Serializes the particle system to a JSON object.
  15992. * @returns the JSON object
  15993. */
  15994. serialize(): any;
  15995. /**
  15996. * Parse properties from a JSON object
  15997. * @param serializationObject defines the JSON object
  15998. */
  15999. parse(serializationObject: any): void;
  16000. }
  16001. }
  16002. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  16003. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16004. import { Effect } from "babylonjs/Materials/effect";
  16005. import { Particle } from "babylonjs/Particles/particle";
  16006. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16007. /**
  16008. * Particle emitter emitting particles from the inside of a cone.
  16009. * It emits the particles alongside the cone volume from the base to the particle.
  16010. * The emission direction might be randomized.
  16011. */
  16012. export class ConeParticleEmitter implements IParticleEmitterType {
  16013. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  16014. directionRandomizer: number;
  16015. private _radius;
  16016. private _angle;
  16017. private _height;
  16018. /**
  16019. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  16020. */
  16021. radiusRange: number;
  16022. /**
  16023. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  16024. */
  16025. heightRange: number;
  16026. /**
  16027. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  16028. */
  16029. emitFromSpawnPointOnly: boolean;
  16030. /**
  16031. * Gets or sets the radius of the emission cone
  16032. */
  16033. radius: number;
  16034. /**
  16035. * Gets or sets the angle of the emission cone
  16036. */
  16037. angle: number;
  16038. private _buildHeight;
  16039. /**
  16040. * Creates a new instance ConeParticleEmitter
  16041. * @param radius the radius of the emission cone (1 by default)
  16042. * @param angle the cone base angle (PI by default)
  16043. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  16044. */
  16045. constructor(radius?: number, angle?: number,
  16046. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  16047. directionRandomizer?: number);
  16048. /**
  16049. * Called by the particle System when the direction is computed for the created particle.
  16050. * @param worldMatrix is the world matrix of the particle system
  16051. * @param directionToUpdate is the direction vector to update with the result
  16052. * @param particle is the particle we are computed the direction for
  16053. */
  16054. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16055. /**
  16056. * Called by the particle System when the position is computed for the created particle.
  16057. * @param worldMatrix is the world matrix of the particle system
  16058. * @param positionToUpdate is the position vector to update with the result
  16059. * @param particle is the particle we are computed the position for
  16060. */
  16061. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16062. /**
  16063. * Clones the current emitter and returns a copy of it
  16064. * @returns the new emitter
  16065. */
  16066. clone(): ConeParticleEmitter;
  16067. /**
  16068. * Called by the GPUParticleSystem to setup the update shader
  16069. * @param effect defines the update shader
  16070. */
  16071. applyToShader(effect: Effect): void;
  16072. /**
  16073. * Returns a string to use to update the GPU particles update shader
  16074. * @returns a string containng the defines string
  16075. */
  16076. getEffectDefines(): string;
  16077. /**
  16078. * Returns the string "ConeParticleEmitter"
  16079. * @returns a string containing the class name
  16080. */
  16081. getClassName(): string;
  16082. /**
  16083. * Serializes the particle system to a JSON object.
  16084. * @returns the JSON object
  16085. */
  16086. serialize(): any;
  16087. /**
  16088. * Parse properties from a JSON object
  16089. * @param serializationObject defines the JSON object
  16090. */
  16091. parse(serializationObject: any): void;
  16092. }
  16093. }
  16094. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  16095. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16096. import { Effect } from "babylonjs/Materials/effect";
  16097. import { Particle } from "babylonjs/Particles/particle";
  16098. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16099. /**
  16100. * Particle emitter emitting particles from the inside of a cylinder.
  16101. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  16102. */
  16103. export class CylinderParticleEmitter implements IParticleEmitterType {
  16104. /**
  16105. * The radius of the emission cylinder.
  16106. */
  16107. radius: number;
  16108. /**
  16109. * The height of the emission cylinder.
  16110. */
  16111. height: number;
  16112. /**
  16113. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16114. */
  16115. radiusRange: number;
  16116. /**
  16117. * How much to randomize the particle direction [0-1].
  16118. */
  16119. directionRandomizer: number;
  16120. /**
  16121. * Creates a new instance CylinderParticleEmitter
  16122. * @param radius the radius of the emission cylinder (1 by default)
  16123. * @param height the height of the emission cylinder (1 by default)
  16124. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16125. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16126. */
  16127. constructor(
  16128. /**
  16129. * The radius of the emission cylinder.
  16130. */
  16131. radius?: number,
  16132. /**
  16133. * The height of the emission cylinder.
  16134. */
  16135. height?: number,
  16136. /**
  16137. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16138. */
  16139. radiusRange?: number,
  16140. /**
  16141. * How much to randomize the particle direction [0-1].
  16142. */
  16143. directionRandomizer?: number);
  16144. /**
  16145. * Called by the particle System when the direction is computed for the created particle.
  16146. * @param worldMatrix is the world matrix of the particle system
  16147. * @param directionToUpdate is the direction vector to update with the result
  16148. * @param particle is the particle we are computed the direction for
  16149. */
  16150. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16151. /**
  16152. * Called by the particle System when the position is computed for the created particle.
  16153. * @param worldMatrix is the world matrix of the particle system
  16154. * @param positionToUpdate is the position vector to update with the result
  16155. * @param particle is the particle we are computed the position for
  16156. */
  16157. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16158. /**
  16159. * Clones the current emitter and returns a copy of it
  16160. * @returns the new emitter
  16161. */
  16162. clone(): CylinderParticleEmitter;
  16163. /**
  16164. * Called by the GPUParticleSystem to setup the update shader
  16165. * @param effect defines the update shader
  16166. */
  16167. applyToShader(effect: Effect): void;
  16168. /**
  16169. * Returns a string to use to update the GPU particles update shader
  16170. * @returns a string containng the defines string
  16171. */
  16172. getEffectDefines(): string;
  16173. /**
  16174. * Returns the string "CylinderParticleEmitter"
  16175. * @returns a string containing the class name
  16176. */
  16177. getClassName(): string;
  16178. /**
  16179. * Serializes the particle system to a JSON object.
  16180. * @returns the JSON object
  16181. */
  16182. serialize(): any;
  16183. /**
  16184. * Parse properties from a JSON object
  16185. * @param serializationObject defines the JSON object
  16186. */
  16187. parse(serializationObject: any): void;
  16188. }
  16189. /**
  16190. * Particle emitter emitting particles from the inside of a cylinder.
  16191. * It emits the particles randomly between two vectors.
  16192. */
  16193. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  16194. /**
  16195. * The min limit of the emission direction.
  16196. */
  16197. direction1: Vector3;
  16198. /**
  16199. * The max limit of the emission direction.
  16200. */
  16201. direction2: Vector3;
  16202. /**
  16203. * Creates a new instance CylinderDirectedParticleEmitter
  16204. * @param radius the radius of the emission cylinder (1 by default)
  16205. * @param height the height of the emission cylinder (1 by default)
  16206. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16207. * @param direction1 the min limit of the emission direction (up vector by default)
  16208. * @param direction2 the max limit of the emission direction (up vector by default)
  16209. */
  16210. constructor(radius?: number, height?: number, radiusRange?: number,
  16211. /**
  16212. * The min limit of the emission direction.
  16213. */
  16214. direction1?: Vector3,
  16215. /**
  16216. * The max limit of the emission direction.
  16217. */
  16218. direction2?: Vector3);
  16219. /**
  16220. * Called by the particle System when the direction is computed for the created particle.
  16221. * @param worldMatrix is the world matrix of the particle system
  16222. * @param directionToUpdate is the direction vector to update with the result
  16223. * @param particle is the particle we are computed the direction for
  16224. */
  16225. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16226. /**
  16227. * Clones the current emitter and returns a copy of it
  16228. * @returns the new emitter
  16229. */
  16230. clone(): CylinderDirectedParticleEmitter;
  16231. /**
  16232. * Called by the GPUParticleSystem to setup the update shader
  16233. * @param effect defines the update shader
  16234. */
  16235. applyToShader(effect: Effect): void;
  16236. /**
  16237. * Returns a string to use to update the GPU particles update shader
  16238. * @returns a string containng the defines string
  16239. */
  16240. getEffectDefines(): string;
  16241. /**
  16242. * Returns the string "CylinderDirectedParticleEmitter"
  16243. * @returns a string containing the class name
  16244. */
  16245. getClassName(): string;
  16246. /**
  16247. * Serializes the particle system to a JSON object.
  16248. * @returns the JSON object
  16249. */
  16250. serialize(): any;
  16251. /**
  16252. * Parse properties from a JSON object
  16253. * @param serializationObject defines the JSON object
  16254. */
  16255. parse(serializationObject: any): void;
  16256. }
  16257. }
  16258. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  16259. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16260. import { Effect } from "babylonjs/Materials/effect";
  16261. import { Particle } from "babylonjs/Particles/particle";
  16262. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16263. /**
  16264. * Particle emitter emitting particles from the inside of a hemisphere.
  16265. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  16266. */
  16267. export class HemisphericParticleEmitter implements IParticleEmitterType {
  16268. /**
  16269. * The radius of the emission hemisphere.
  16270. */
  16271. radius: number;
  16272. /**
  16273. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16274. */
  16275. radiusRange: number;
  16276. /**
  16277. * How much to randomize the particle direction [0-1].
  16278. */
  16279. directionRandomizer: number;
  16280. /**
  16281. * Creates a new instance HemisphericParticleEmitter
  16282. * @param radius the radius of the emission hemisphere (1 by default)
  16283. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16284. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16285. */
  16286. constructor(
  16287. /**
  16288. * The radius of the emission hemisphere.
  16289. */
  16290. radius?: number,
  16291. /**
  16292. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16293. */
  16294. radiusRange?: number,
  16295. /**
  16296. * How much to randomize the particle direction [0-1].
  16297. */
  16298. directionRandomizer?: number);
  16299. /**
  16300. * Called by the particle System when the direction is computed for the created particle.
  16301. * @param worldMatrix is the world matrix of the particle system
  16302. * @param directionToUpdate is the direction vector to update with the result
  16303. * @param particle is the particle we are computed the direction for
  16304. */
  16305. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16306. /**
  16307. * Called by the particle System when the position is computed for the created particle.
  16308. * @param worldMatrix is the world matrix of the particle system
  16309. * @param positionToUpdate is the position vector to update with the result
  16310. * @param particle is the particle we are computed the position for
  16311. */
  16312. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16313. /**
  16314. * Clones the current emitter and returns a copy of it
  16315. * @returns the new emitter
  16316. */
  16317. clone(): HemisphericParticleEmitter;
  16318. /**
  16319. * Called by the GPUParticleSystem to setup the update shader
  16320. * @param effect defines the update shader
  16321. */
  16322. applyToShader(effect: Effect): void;
  16323. /**
  16324. * Returns a string to use to update the GPU particles update shader
  16325. * @returns a string containng the defines string
  16326. */
  16327. getEffectDefines(): string;
  16328. /**
  16329. * Returns the string "HemisphericParticleEmitter"
  16330. * @returns a string containing the class name
  16331. */
  16332. getClassName(): string;
  16333. /**
  16334. * Serializes the particle system to a JSON object.
  16335. * @returns the JSON object
  16336. */
  16337. serialize(): any;
  16338. /**
  16339. * Parse properties from a JSON object
  16340. * @param serializationObject defines the JSON object
  16341. */
  16342. parse(serializationObject: any): void;
  16343. }
  16344. }
  16345. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  16346. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16347. import { Effect } from "babylonjs/Materials/effect";
  16348. import { Particle } from "babylonjs/Particles/particle";
  16349. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16350. /**
  16351. * Particle emitter emitting particles from a point.
  16352. * It emits the particles randomly between 2 given directions.
  16353. */
  16354. export class PointParticleEmitter implements IParticleEmitterType {
  16355. /**
  16356. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16357. */
  16358. direction1: Vector3;
  16359. /**
  16360. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16361. */
  16362. direction2: Vector3;
  16363. /**
  16364. * Creates a new instance PointParticleEmitter
  16365. */
  16366. constructor();
  16367. /**
  16368. * Called by the particle System when the direction is computed for the created particle.
  16369. * @param worldMatrix is the world matrix of the particle system
  16370. * @param directionToUpdate is the direction vector to update with the result
  16371. * @param particle is the particle we are computed the direction for
  16372. */
  16373. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16374. /**
  16375. * Called by the particle System when the position is computed for the created particle.
  16376. * @param worldMatrix is the world matrix of the particle system
  16377. * @param positionToUpdate is the position vector to update with the result
  16378. * @param particle is the particle we are computed the position for
  16379. */
  16380. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16381. /**
  16382. * Clones the current emitter and returns a copy of it
  16383. * @returns the new emitter
  16384. */
  16385. clone(): PointParticleEmitter;
  16386. /**
  16387. * Called by the GPUParticleSystem to setup the update shader
  16388. * @param effect defines the update shader
  16389. */
  16390. applyToShader(effect: Effect): void;
  16391. /**
  16392. * Returns a string to use to update the GPU particles update shader
  16393. * @returns a string containng the defines string
  16394. */
  16395. getEffectDefines(): string;
  16396. /**
  16397. * Returns the string "PointParticleEmitter"
  16398. * @returns a string containing the class name
  16399. */
  16400. getClassName(): string;
  16401. /**
  16402. * Serializes the particle system to a JSON object.
  16403. * @returns the JSON object
  16404. */
  16405. serialize(): any;
  16406. /**
  16407. * Parse properties from a JSON object
  16408. * @param serializationObject defines the JSON object
  16409. */
  16410. parse(serializationObject: any): void;
  16411. }
  16412. }
  16413. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  16414. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16415. import { Effect } from "babylonjs/Materials/effect";
  16416. import { Particle } from "babylonjs/Particles/particle";
  16417. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16418. /**
  16419. * Particle emitter emitting particles from the inside of a sphere.
  16420. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  16421. */
  16422. export class SphereParticleEmitter implements IParticleEmitterType {
  16423. /**
  16424. * The radius of the emission sphere.
  16425. */
  16426. radius: number;
  16427. /**
  16428. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16429. */
  16430. radiusRange: number;
  16431. /**
  16432. * How much to randomize the particle direction [0-1].
  16433. */
  16434. directionRandomizer: number;
  16435. /**
  16436. * Creates a new instance SphereParticleEmitter
  16437. * @param radius the radius of the emission sphere (1 by default)
  16438. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16439. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16440. */
  16441. constructor(
  16442. /**
  16443. * The radius of the emission sphere.
  16444. */
  16445. radius?: number,
  16446. /**
  16447. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16448. */
  16449. radiusRange?: number,
  16450. /**
  16451. * How much to randomize the particle direction [0-1].
  16452. */
  16453. directionRandomizer?: number);
  16454. /**
  16455. * Called by the particle System when the direction is computed for the created particle.
  16456. * @param worldMatrix is the world matrix of the particle system
  16457. * @param directionToUpdate is the direction vector to update with the result
  16458. * @param particle is the particle we are computed the direction for
  16459. */
  16460. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16461. /**
  16462. * Called by the particle System when the position is computed for the created particle.
  16463. * @param worldMatrix is the world matrix of the particle system
  16464. * @param positionToUpdate is the position vector to update with the result
  16465. * @param particle is the particle we are computed the position for
  16466. */
  16467. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16468. /**
  16469. * Clones the current emitter and returns a copy of it
  16470. * @returns the new emitter
  16471. */
  16472. clone(): SphereParticleEmitter;
  16473. /**
  16474. * Called by the GPUParticleSystem to setup the update shader
  16475. * @param effect defines the update shader
  16476. */
  16477. applyToShader(effect: Effect): void;
  16478. /**
  16479. * Returns a string to use to update the GPU particles update shader
  16480. * @returns a string containng the defines string
  16481. */
  16482. getEffectDefines(): string;
  16483. /**
  16484. * Returns the string "SphereParticleEmitter"
  16485. * @returns a string containing the class name
  16486. */
  16487. getClassName(): string;
  16488. /**
  16489. * Serializes the particle system to a JSON object.
  16490. * @returns the JSON object
  16491. */
  16492. serialize(): any;
  16493. /**
  16494. * Parse properties from a JSON object
  16495. * @param serializationObject defines the JSON object
  16496. */
  16497. parse(serializationObject: any): void;
  16498. }
  16499. /**
  16500. * Particle emitter emitting particles from the inside of a sphere.
  16501. * It emits the particles randomly between two vectors.
  16502. */
  16503. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  16504. /**
  16505. * The min limit of the emission direction.
  16506. */
  16507. direction1: Vector3;
  16508. /**
  16509. * The max limit of the emission direction.
  16510. */
  16511. direction2: Vector3;
  16512. /**
  16513. * Creates a new instance SphereDirectedParticleEmitter
  16514. * @param radius the radius of the emission sphere (1 by default)
  16515. * @param direction1 the min limit of the emission direction (up vector by default)
  16516. * @param direction2 the max limit of the emission direction (up vector by default)
  16517. */
  16518. constructor(radius?: number,
  16519. /**
  16520. * The min limit of the emission direction.
  16521. */
  16522. direction1?: Vector3,
  16523. /**
  16524. * The max limit of the emission direction.
  16525. */
  16526. direction2?: Vector3);
  16527. /**
  16528. * Called by the particle System when the direction is computed for the created particle.
  16529. * @param worldMatrix is the world matrix of the particle system
  16530. * @param directionToUpdate is the direction vector to update with the result
  16531. * @param particle is the particle we are computed the direction for
  16532. */
  16533. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16534. /**
  16535. * Clones the current emitter and returns a copy of it
  16536. * @returns the new emitter
  16537. */
  16538. clone(): SphereDirectedParticleEmitter;
  16539. /**
  16540. * Called by the GPUParticleSystem to setup the update shader
  16541. * @param effect defines the update shader
  16542. */
  16543. applyToShader(effect: Effect): void;
  16544. /**
  16545. * Returns a string to use to update the GPU particles update shader
  16546. * @returns a string containng the defines string
  16547. */
  16548. getEffectDefines(): string;
  16549. /**
  16550. * Returns the string "SphereDirectedParticleEmitter"
  16551. * @returns a string containing the class name
  16552. */
  16553. getClassName(): string;
  16554. /**
  16555. * Serializes the particle system to a JSON object.
  16556. * @returns the JSON object
  16557. */
  16558. serialize(): any;
  16559. /**
  16560. * Parse properties from a JSON object
  16561. * @param serializationObject defines the JSON object
  16562. */
  16563. parse(serializationObject: any): void;
  16564. }
  16565. }
  16566. declare module "babylonjs/Particles/EmitterTypes/index" {
  16567. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  16568. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  16569. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  16570. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  16571. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16572. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  16573. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  16574. }
  16575. declare module "babylonjs/Particles/IParticleSystem" {
  16576. import { Nullable } from "babylonjs/types";
  16577. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  16578. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16579. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16580. import { Texture } from "babylonjs/Materials/Textures/texture";
  16581. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  16582. import { Scene } from "babylonjs/scene";
  16583. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  16584. import { Animation } from "babylonjs/Animations/animation";
  16585. /**
  16586. * Interface representing a particle system in Babylon.js.
  16587. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  16588. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  16589. */
  16590. export interface IParticleSystem {
  16591. /**
  16592. * List of animations used by the particle system.
  16593. */
  16594. animations: Animation[];
  16595. /**
  16596. * The id of the Particle system.
  16597. */
  16598. id: string;
  16599. /**
  16600. * The name of the Particle system.
  16601. */
  16602. name: string;
  16603. /**
  16604. * The emitter represents the Mesh or position we are attaching the particle system to.
  16605. */
  16606. emitter: Nullable<AbstractMesh | Vector3>;
  16607. /**
  16608. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16609. */
  16610. isBillboardBased: boolean;
  16611. /**
  16612. * The rendering group used by the Particle system to chose when to render.
  16613. */
  16614. renderingGroupId: number;
  16615. /**
  16616. * The layer mask we are rendering the particles through.
  16617. */
  16618. layerMask: number;
  16619. /**
  16620. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16621. */
  16622. updateSpeed: number;
  16623. /**
  16624. * The amount of time the particle system is running (depends of the overall update speed).
  16625. */
  16626. targetStopDuration: number;
  16627. /**
  16628. * The texture used to render each particle. (this can be a spritesheet)
  16629. */
  16630. particleTexture: Nullable<Texture>;
  16631. /**
  16632. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  16633. */
  16634. blendMode: number;
  16635. /**
  16636. * Minimum life time of emitting particles.
  16637. */
  16638. minLifeTime: number;
  16639. /**
  16640. * Maximum life time of emitting particles.
  16641. */
  16642. maxLifeTime: number;
  16643. /**
  16644. * Minimum Size of emitting particles.
  16645. */
  16646. minSize: number;
  16647. /**
  16648. * Maximum Size of emitting particles.
  16649. */
  16650. maxSize: number;
  16651. /**
  16652. * Minimum scale of emitting particles on X axis.
  16653. */
  16654. minScaleX: number;
  16655. /**
  16656. * Maximum scale of emitting particles on X axis.
  16657. */
  16658. maxScaleX: number;
  16659. /**
  16660. * Minimum scale of emitting particles on Y axis.
  16661. */
  16662. minScaleY: number;
  16663. /**
  16664. * Maximum scale of emitting particles on Y axis.
  16665. */
  16666. maxScaleY: number;
  16667. /**
  16668. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16669. */
  16670. color1: Color4;
  16671. /**
  16672. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16673. */
  16674. color2: Color4;
  16675. /**
  16676. * Color the particle will have at the end of its lifetime.
  16677. */
  16678. colorDead: Color4;
  16679. /**
  16680. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  16681. */
  16682. emitRate: number;
  16683. /**
  16684. * You can use gravity if you want to give an orientation to your particles.
  16685. */
  16686. gravity: Vector3;
  16687. /**
  16688. * Minimum power of emitting particles.
  16689. */
  16690. minEmitPower: number;
  16691. /**
  16692. * Maximum power of emitting particles.
  16693. */
  16694. maxEmitPower: number;
  16695. /**
  16696. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16697. */
  16698. minAngularSpeed: number;
  16699. /**
  16700. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16701. */
  16702. maxAngularSpeed: number;
  16703. /**
  16704. * Gets or sets the minimal initial rotation in radians.
  16705. */
  16706. minInitialRotation: number;
  16707. /**
  16708. * Gets or sets the maximal initial rotation in radians.
  16709. */
  16710. maxInitialRotation: number;
  16711. /**
  16712. * The particle emitter type defines the emitter used by the particle system.
  16713. * It can be for example box, sphere, or cone...
  16714. */
  16715. particleEmitterType: Nullable<IParticleEmitterType>;
  16716. /**
  16717. * Defines the delay in milliseconds before starting the system (0 by default)
  16718. */
  16719. startDelay: number;
  16720. /**
  16721. * 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
  16722. */
  16723. preWarmCycles: number;
  16724. /**
  16725. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  16726. */
  16727. preWarmStepOffset: number;
  16728. /**
  16729. * 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)
  16730. */
  16731. spriteCellChangeSpeed: number;
  16732. /**
  16733. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16734. */
  16735. startSpriteCellID: number;
  16736. /**
  16737. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16738. */
  16739. endSpriteCellID: number;
  16740. /**
  16741. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16742. */
  16743. spriteCellWidth: number;
  16744. /**
  16745. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16746. */
  16747. spriteCellHeight: number;
  16748. /**
  16749. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16750. */
  16751. spriteRandomStartCell: boolean;
  16752. /**
  16753. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  16754. */
  16755. isAnimationSheetEnabled: boolean;
  16756. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16757. translationPivot: Vector2;
  16758. /**
  16759. * Gets or sets a texture used to add random noise to particle positions
  16760. */
  16761. noiseTexture: Nullable<BaseTexture>;
  16762. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16763. noiseStrength: Vector3;
  16764. /**
  16765. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16766. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16767. */
  16768. billboardMode: number;
  16769. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16770. limitVelocityDamping: number;
  16771. /**
  16772. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16773. */
  16774. beginAnimationOnStart: boolean;
  16775. /**
  16776. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16777. */
  16778. beginAnimationFrom: number;
  16779. /**
  16780. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16781. */
  16782. beginAnimationTo: number;
  16783. /**
  16784. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16785. */
  16786. beginAnimationLoop: boolean;
  16787. /**
  16788. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16789. */
  16790. disposeOnStop: boolean;
  16791. /**
  16792. * Gets the maximum number of particles active at the same time.
  16793. * @returns The max number of active particles.
  16794. */
  16795. getCapacity(): number;
  16796. /**
  16797. * Gets if the system has been started. (Note: this will still be true after stop is called)
  16798. * @returns True if it has been started, otherwise false.
  16799. */
  16800. isStarted(): boolean;
  16801. /**
  16802. * Animates the particle system for this frame.
  16803. */
  16804. animate(): void;
  16805. /**
  16806. * Renders the particle system in its current state.
  16807. * @returns the current number of particles
  16808. */
  16809. render(): number;
  16810. /**
  16811. * Dispose the particle system and frees its associated resources.
  16812. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  16813. */
  16814. dispose(disposeTexture?: boolean): void;
  16815. /**
  16816. * Clones the particle system.
  16817. * @param name The name of the cloned object
  16818. * @param newEmitter The new emitter to use
  16819. * @returns the cloned particle system
  16820. */
  16821. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  16822. /**
  16823. * Serializes the particle system to a JSON object.
  16824. * @returns the JSON object
  16825. */
  16826. serialize(): any;
  16827. /**
  16828. * Rebuild the particle system
  16829. */
  16830. rebuild(): void;
  16831. /**
  16832. * Starts the particle system and begins to emit
  16833. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  16834. */
  16835. start(delay?: number): void;
  16836. /**
  16837. * Stops the particle system.
  16838. */
  16839. stop(): void;
  16840. /**
  16841. * Remove all active particles
  16842. */
  16843. reset(): void;
  16844. /**
  16845. * Is this system ready to be used/rendered
  16846. * @return true if the system is ready
  16847. */
  16848. isReady(): boolean;
  16849. /**
  16850. * Adds a new color gradient
  16851. * @param gradient defines the gradient to use (between 0 and 1)
  16852. * @param color1 defines the color to affect to the specified gradient
  16853. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  16854. * @returns the current particle system
  16855. */
  16856. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  16857. /**
  16858. * Remove a specific color gradient
  16859. * @param gradient defines the gradient to remove
  16860. * @returns the current particle system
  16861. */
  16862. removeColorGradient(gradient: number): IParticleSystem;
  16863. /**
  16864. * Adds a new size gradient
  16865. * @param gradient defines the gradient to use (between 0 and 1)
  16866. * @param factor defines the size factor to affect to the specified gradient
  16867. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16868. * @returns the current particle system
  16869. */
  16870. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16871. /**
  16872. * Remove a specific size gradient
  16873. * @param gradient defines the gradient to remove
  16874. * @returns the current particle system
  16875. */
  16876. removeSizeGradient(gradient: number): IParticleSystem;
  16877. /**
  16878. * Gets the current list of color gradients.
  16879. * You must use addColorGradient and removeColorGradient to udpate this list
  16880. * @returns the list of color gradients
  16881. */
  16882. getColorGradients(): Nullable<Array<ColorGradient>>;
  16883. /**
  16884. * Gets the current list of size gradients.
  16885. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16886. * @returns the list of size gradients
  16887. */
  16888. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16889. /**
  16890. * Gets the current list of angular speed gradients.
  16891. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16892. * @returns the list of angular speed gradients
  16893. */
  16894. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16895. /**
  16896. * Adds a new angular speed gradient
  16897. * @param gradient defines the gradient to use (between 0 and 1)
  16898. * @param factor defines the angular speed to affect to the specified gradient
  16899. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16900. * @returns the current particle system
  16901. */
  16902. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16903. /**
  16904. * Remove a specific angular speed gradient
  16905. * @param gradient defines the gradient to remove
  16906. * @returns the current particle system
  16907. */
  16908. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16909. /**
  16910. * Gets the current list of velocity gradients.
  16911. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16912. * @returns the list of velocity gradients
  16913. */
  16914. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16915. /**
  16916. * Adds a new velocity gradient
  16917. * @param gradient defines the gradient to use (between 0 and 1)
  16918. * @param factor defines the velocity to affect to the specified gradient
  16919. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16920. * @returns the current particle system
  16921. */
  16922. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16923. /**
  16924. * Remove a specific velocity gradient
  16925. * @param gradient defines the gradient to remove
  16926. * @returns the current particle system
  16927. */
  16928. removeVelocityGradient(gradient: number): IParticleSystem;
  16929. /**
  16930. * Gets the current list of limit velocity gradients.
  16931. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16932. * @returns the list of limit velocity gradients
  16933. */
  16934. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16935. /**
  16936. * Adds a new limit velocity gradient
  16937. * @param gradient defines the gradient to use (between 0 and 1)
  16938. * @param factor defines the limit velocity to affect to the specified gradient
  16939. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16940. * @returns the current particle system
  16941. */
  16942. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16943. /**
  16944. * Remove a specific limit velocity gradient
  16945. * @param gradient defines the gradient to remove
  16946. * @returns the current particle system
  16947. */
  16948. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16949. /**
  16950. * Adds a new drag gradient
  16951. * @param gradient defines the gradient to use (between 0 and 1)
  16952. * @param factor defines the drag to affect to the specified gradient
  16953. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16954. * @returns the current particle system
  16955. */
  16956. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16957. /**
  16958. * Remove a specific drag gradient
  16959. * @param gradient defines the gradient to remove
  16960. * @returns the current particle system
  16961. */
  16962. removeDragGradient(gradient: number): IParticleSystem;
  16963. /**
  16964. * Gets the current list of drag gradients.
  16965. * You must use addDragGradient and removeDragGradient to udpate this list
  16966. * @returns the list of drag gradients
  16967. */
  16968. getDragGradients(): Nullable<Array<FactorGradient>>;
  16969. /**
  16970. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16971. * @param gradient defines the gradient to use (between 0 and 1)
  16972. * @param factor defines the emit rate to affect to the specified gradient
  16973. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16974. * @returns the current particle system
  16975. */
  16976. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16977. /**
  16978. * Remove a specific emit rate gradient
  16979. * @param gradient defines the gradient to remove
  16980. * @returns the current particle system
  16981. */
  16982. removeEmitRateGradient(gradient: number): IParticleSystem;
  16983. /**
  16984. * Gets the current list of emit rate gradients.
  16985. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16986. * @returns the list of emit rate gradients
  16987. */
  16988. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16989. /**
  16990. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  16991. * @param gradient defines the gradient to use (between 0 and 1)
  16992. * @param factor defines the start size to affect to the specified gradient
  16993. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16994. * @returns the current particle system
  16995. */
  16996. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16997. /**
  16998. * Remove a specific start size gradient
  16999. * @param gradient defines the gradient to remove
  17000. * @returns the current particle system
  17001. */
  17002. removeStartSizeGradient(gradient: number): IParticleSystem;
  17003. /**
  17004. * Gets the current list of start size gradients.
  17005. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  17006. * @returns the list of start size gradients
  17007. */
  17008. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  17009. /**
  17010. * Adds a new life time gradient
  17011. * @param gradient defines the gradient to use (between 0 and 1)
  17012. * @param factor defines the life time factor to affect to the specified gradient
  17013. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17014. * @returns the current particle system
  17015. */
  17016. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17017. /**
  17018. * Remove a specific life time gradient
  17019. * @param gradient defines the gradient to remove
  17020. * @returns the current particle system
  17021. */
  17022. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17023. /**
  17024. * Gets the current list of life time gradients.
  17025. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  17026. * @returns the list of life time gradients
  17027. */
  17028. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  17029. /**
  17030. * Gets the current list of color gradients.
  17031. * You must use addColorGradient and removeColorGradient to udpate this list
  17032. * @returns the list of color gradients
  17033. */
  17034. getColorGradients(): Nullable<Array<ColorGradient>>;
  17035. /**
  17036. * Adds a new ramp gradient used to remap particle colors
  17037. * @param gradient defines the gradient to use (between 0 and 1)
  17038. * @param color defines the color to affect to the specified gradient
  17039. * @returns the current particle system
  17040. */
  17041. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  17042. /**
  17043. * Gets the current list of ramp gradients.
  17044. * You must use addRampGradient and removeRampGradient to udpate this list
  17045. * @returns the list of ramp gradients
  17046. */
  17047. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17048. /** Gets or sets a boolean indicating that ramp gradients must be used
  17049. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17050. */
  17051. useRampGradients: boolean;
  17052. /**
  17053. * Adds a new color remap gradient
  17054. * @param gradient defines the gradient to use (between 0 and 1)
  17055. * @param min defines the color remap minimal range
  17056. * @param max defines the color remap maximal range
  17057. * @returns the current particle system
  17058. */
  17059. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17060. /**
  17061. * Gets the current list of color remap gradients.
  17062. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  17063. * @returns the list of color remap gradients
  17064. */
  17065. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  17066. /**
  17067. * Adds a new alpha remap gradient
  17068. * @param gradient defines the gradient to use (between 0 and 1)
  17069. * @param min defines the alpha remap minimal range
  17070. * @param max defines the alpha remap maximal range
  17071. * @returns the current particle system
  17072. */
  17073. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17074. /**
  17075. * Gets the current list of alpha remap gradients.
  17076. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  17077. * @returns the list of alpha remap gradients
  17078. */
  17079. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  17080. /**
  17081. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17082. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17083. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17084. * @returns the emitter
  17085. */
  17086. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17087. /**
  17088. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17089. * @param radius The radius of the hemisphere to emit from
  17090. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17091. * @returns the emitter
  17092. */
  17093. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  17094. /**
  17095. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17096. * @param radius The radius of the sphere to emit from
  17097. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17098. * @returns the emitter
  17099. */
  17100. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  17101. /**
  17102. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17103. * @param radius The radius of the sphere to emit from
  17104. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17105. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17106. * @returns the emitter
  17107. */
  17108. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  17109. /**
  17110. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17111. * @param radius The radius of the emission cylinder
  17112. * @param height The height of the emission cylinder
  17113. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17114. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17115. * @returns the emitter
  17116. */
  17117. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  17118. /**
  17119. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17120. * @param radius The radius of the cylinder to emit from
  17121. * @param height The height of the emission cylinder
  17122. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17123. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17124. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17125. * @returns the emitter
  17126. */
  17127. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  17128. /**
  17129. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17130. * @param radius The radius of the cone to emit from
  17131. * @param angle The base angle of the cone
  17132. * @returns the emitter
  17133. */
  17134. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  17135. /**
  17136. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17137. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17138. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17139. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17140. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17141. * @returns the emitter
  17142. */
  17143. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17144. /**
  17145. * Get hosting scene
  17146. * @returns the scene
  17147. */
  17148. getScene(): Scene;
  17149. }
  17150. }
  17151. declare module "babylonjs/Meshes/instancedMesh" {
  17152. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  17153. import { Vector3, Matrix } from "babylonjs/Maths/math";
  17154. import { Camera } from "babylonjs/Cameras/camera";
  17155. import { Node } from "babylonjs/node";
  17156. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17157. import { Mesh } from "babylonjs/Meshes/mesh";
  17158. import { Material } from "babylonjs/Materials/material";
  17159. import { Skeleton } from "babylonjs/Bones/skeleton";
  17160. import { Light } from "babylonjs/Lights/light";
  17161. /**
  17162. * Creates an instance based on a source mesh.
  17163. */
  17164. export class InstancedMesh extends AbstractMesh {
  17165. private _sourceMesh;
  17166. private _currentLOD;
  17167. /** @hidden */
  17168. _indexInSourceMeshInstanceArray: number;
  17169. constructor(name: string, source: Mesh);
  17170. /**
  17171. * Returns the string "InstancedMesh".
  17172. */
  17173. getClassName(): string;
  17174. /** Gets the list of lights affecting that mesh */
  17175. readonly lightSources: Light[];
  17176. _resyncLightSources(): void;
  17177. _resyncLighSource(light: Light): void;
  17178. _removeLightSource(light: Light): void;
  17179. /**
  17180. * If the source mesh receives shadows
  17181. */
  17182. readonly receiveShadows: boolean;
  17183. /**
  17184. * The material of the source mesh
  17185. */
  17186. readonly material: Nullable<Material>;
  17187. /**
  17188. * Visibility of the source mesh
  17189. */
  17190. readonly visibility: number;
  17191. /**
  17192. * Skeleton of the source mesh
  17193. */
  17194. readonly skeleton: Nullable<Skeleton>;
  17195. /**
  17196. * Rendering ground id of the source mesh
  17197. */
  17198. renderingGroupId: number;
  17199. /**
  17200. * Returns the total number of vertices (integer).
  17201. */
  17202. getTotalVertices(): number;
  17203. /**
  17204. * Returns a positive integer : the total number of indices in this mesh geometry.
  17205. * @returns the numner of indices or zero if the mesh has no geometry.
  17206. */
  17207. getTotalIndices(): number;
  17208. /**
  17209. * The source mesh of the instance
  17210. */
  17211. readonly sourceMesh: Mesh;
  17212. /**
  17213. * Is this node ready to be used/rendered
  17214. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  17215. * @return {boolean} is it ready
  17216. */
  17217. isReady(completeCheck?: boolean): boolean;
  17218. /**
  17219. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  17220. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  17221. * @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.
  17222. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  17223. */
  17224. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  17225. /**
  17226. * Sets the vertex data of the mesh geometry for the requested `kind`.
  17227. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  17228. * The `data` are either a numeric array either a Float32Array.
  17229. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  17230. * 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).
  17231. * Note that a new underlying VertexBuffer object is created each call.
  17232. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  17233. *
  17234. * Possible `kind` values :
  17235. * - VertexBuffer.PositionKind
  17236. * - VertexBuffer.UVKind
  17237. * - VertexBuffer.UV2Kind
  17238. * - VertexBuffer.UV3Kind
  17239. * - VertexBuffer.UV4Kind
  17240. * - VertexBuffer.UV5Kind
  17241. * - VertexBuffer.UV6Kind
  17242. * - VertexBuffer.ColorKind
  17243. * - VertexBuffer.MatricesIndicesKind
  17244. * - VertexBuffer.MatricesIndicesExtraKind
  17245. * - VertexBuffer.MatricesWeightsKind
  17246. * - VertexBuffer.MatricesWeightsExtraKind
  17247. *
  17248. * Returns the Mesh.
  17249. */
  17250. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  17251. /**
  17252. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  17253. * If the mesh has no geometry, it is simply returned as it is.
  17254. * The `data` are either a numeric array either a Float32Array.
  17255. * No new underlying VertexBuffer object is created.
  17256. * 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.
  17257. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  17258. *
  17259. * Possible `kind` values :
  17260. * - VertexBuffer.PositionKind
  17261. * - VertexBuffer.UVKind
  17262. * - VertexBuffer.UV2Kind
  17263. * - VertexBuffer.UV3Kind
  17264. * - VertexBuffer.UV4Kind
  17265. * - VertexBuffer.UV5Kind
  17266. * - VertexBuffer.UV6Kind
  17267. * - VertexBuffer.ColorKind
  17268. * - VertexBuffer.MatricesIndicesKind
  17269. * - VertexBuffer.MatricesIndicesExtraKind
  17270. * - VertexBuffer.MatricesWeightsKind
  17271. * - VertexBuffer.MatricesWeightsExtraKind
  17272. *
  17273. * Returns the Mesh.
  17274. */
  17275. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  17276. /**
  17277. * Sets the mesh indices.
  17278. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  17279. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  17280. * This method creates a new index buffer each call.
  17281. * Returns the Mesh.
  17282. */
  17283. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  17284. /**
  17285. * Boolean : True if the mesh owns the requested kind of data.
  17286. */
  17287. isVerticesDataPresent(kind: string): boolean;
  17288. /**
  17289. * Returns an array of indices (IndicesArray).
  17290. */
  17291. getIndices(): Nullable<IndicesArray>;
  17292. readonly _positions: Nullable<Vector3[]>;
  17293. /**
  17294. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  17295. * This means the mesh underlying bounding box and sphere are recomputed.
  17296. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  17297. * @returns the current mesh
  17298. */
  17299. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  17300. /** @hidden */
  17301. _preActivate(): InstancedMesh;
  17302. /** @hidden */
  17303. _activate(renderId: number): boolean;
  17304. /** @hidden */
  17305. _postActivate(): void;
  17306. getWorldMatrix(): Matrix;
  17307. readonly isAnInstance: boolean;
  17308. /**
  17309. * Returns the current associated LOD AbstractMesh.
  17310. */
  17311. getLOD(camera: Camera): AbstractMesh;
  17312. /** @hidden */
  17313. _syncSubMeshes(): InstancedMesh;
  17314. /** @hidden */
  17315. _generatePointsArray(): boolean;
  17316. /**
  17317. * Creates a new InstancedMesh from the current mesh.
  17318. * - name (string) : the cloned mesh name
  17319. * - newParent (optional Node) : the optional Node to parent the clone to.
  17320. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  17321. *
  17322. * Returns the clone.
  17323. */
  17324. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  17325. /**
  17326. * Disposes the InstancedMesh.
  17327. * Returns nothing.
  17328. */
  17329. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  17330. }
  17331. }
  17332. declare module "babylonjs/Materials/shaderMaterial" {
  17333. import { Scene } from "babylonjs/scene";
  17334. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  17335. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17336. import { Mesh } from "babylonjs/Meshes/mesh";
  17337. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  17338. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  17339. import { Texture } from "babylonjs/Materials/Textures/texture";
  17340. import { Material } from "babylonjs/Materials/material";
  17341. /**
  17342. * Defines the options associated with the creation of a shader material.
  17343. */
  17344. export interface IShaderMaterialOptions {
  17345. /**
  17346. * Does the material work in alpha blend mode
  17347. */
  17348. needAlphaBlending: boolean;
  17349. /**
  17350. * Does the material work in alpha test mode
  17351. */
  17352. needAlphaTesting: boolean;
  17353. /**
  17354. * The list of attribute names used in the shader
  17355. */
  17356. attributes: string[];
  17357. /**
  17358. * The list of unifrom names used in the shader
  17359. */
  17360. uniforms: string[];
  17361. /**
  17362. * The list of UBO names used in the shader
  17363. */
  17364. uniformBuffers: string[];
  17365. /**
  17366. * The list of sampler names used in the shader
  17367. */
  17368. samplers: string[];
  17369. /**
  17370. * The list of defines used in the shader
  17371. */
  17372. defines: string[];
  17373. }
  17374. /**
  17375. * 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.
  17376. *
  17377. * This returned material effects how the mesh will look based on the code in the shaders.
  17378. *
  17379. * @see http://doc.babylonjs.com/how_to/shader_material
  17380. */
  17381. export class ShaderMaterial extends Material {
  17382. private _shaderPath;
  17383. private _options;
  17384. private _textures;
  17385. private _textureArrays;
  17386. private _floats;
  17387. private _ints;
  17388. private _floatsArrays;
  17389. private _colors3;
  17390. private _colors3Arrays;
  17391. private _colors4;
  17392. private _vectors2;
  17393. private _vectors3;
  17394. private _vectors4;
  17395. private _matrices;
  17396. private _matrices3x3;
  17397. private _matrices2x2;
  17398. private _vectors2Arrays;
  17399. private _vectors3Arrays;
  17400. private _cachedWorldViewMatrix;
  17401. private _renderId;
  17402. /**
  17403. * Instantiate a new shader material.
  17404. * 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.
  17405. * This returned material effects how the mesh will look based on the code in the shaders.
  17406. * @see http://doc.babylonjs.com/how_to/shader_material
  17407. * @param name Define the name of the material in the scene
  17408. * @param scene Define the scene the material belongs to
  17409. * @param shaderPath Defines the route to the shader code in one of three ways:
  17410. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  17411. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  17412. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  17413. * @param options Define the options used to create the shader
  17414. */
  17415. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  17416. /**
  17417. * Gets the options used to compile the shader.
  17418. * They can be modified to trigger a new compilation
  17419. */
  17420. readonly options: IShaderMaterialOptions;
  17421. /**
  17422. * Gets the current class name of the material e.g. "ShaderMaterial"
  17423. * Mainly use in serialization.
  17424. * @returns the class name
  17425. */
  17426. getClassName(): string;
  17427. /**
  17428. * Specifies if the material will require alpha blending
  17429. * @returns a boolean specifying if alpha blending is needed
  17430. */
  17431. needAlphaBlending(): boolean;
  17432. /**
  17433. * Specifies if this material should be rendered in alpha test mode
  17434. * @returns a boolean specifying if an alpha test is needed.
  17435. */
  17436. needAlphaTesting(): boolean;
  17437. private _checkUniform;
  17438. /**
  17439. * Set a texture in the shader.
  17440. * @param name Define the name of the uniform samplers as defined in the shader
  17441. * @param texture Define the texture to bind to this sampler
  17442. * @return the material itself allowing "fluent" like uniform updates
  17443. */
  17444. setTexture(name: string, texture: Texture): ShaderMaterial;
  17445. /**
  17446. * Set a texture array in the shader.
  17447. * @param name Define the name of the uniform sampler array as defined in the shader
  17448. * @param textures Define the list of textures to bind to this sampler
  17449. * @return the material itself allowing "fluent" like uniform updates
  17450. */
  17451. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  17452. /**
  17453. * Set a float in the shader.
  17454. * @param name Define the name of the uniform as defined in the shader
  17455. * @param value Define the value to give to the uniform
  17456. * @return the material itself allowing "fluent" like uniform updates
  17457. */
  17458. setFloat(name: string, value: number): ShaderMaterial;
  17459. /**
  17460. * Set a int in the shader.
  17461. * @param name Define the name of the uniform as defined in the shader
  17462. * @param value Define the value to give to the uniform
  17463. * @return the material itself allowing "fluent" like uniform updates
  17464. */
  17465. setInt(name: string, value: number): ShaderMaterial;
  17466. /**
  17467. * Set an array of floats in the shader.
  17468. * @param name Define the name of the uniform as defined in the shader
  17469. * @param value Define the value to give to the uniform
  17470. * @return the material itself allowing "fluent" like uniform updates
  17471. */
  17472. setFloats(name: string, value: number[]): ShaderMaterial;
  17473. /**
  17474. * Set a vec3 in the shader from a Color3.
  17475. * @param name Define the name of the uniform as defined in the shader
  17476. * @param value Define the value to give to the uniform
  17477. * @return the material itself allowing "fluent" like uniform updates
  17478. */
  17479. setColor3(name: string, value: Color3): ShaderMaterial;
  17480. /**
  17481. * Set a vec3 array in the shader from a Color3 array.
  17482. * @param name Define the name of the uniform as defined in the shader
  17483. * @param value Define the value to give to the uniform
  17484. * @return the material itself allowing "fluent" like uniform updates
  17485. */
  17486. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  17487. /**
  17488. * Set a vec4 in the shader from a Color4.
  17489. * @param name Define the name of the uniform as defined in the shader
  17490. * @param value Define the value to give to the uniform
  17491. * @return the material itself allowing "fluent" like uniform updates
  17492. */
  17493. setColor4(name: string, value: Color4): ShaderMaterial;
  17494. /**
  17495. * Set a vec2 in the shader from a Vector2.
  17496. * @param name Define the name of the uniform as defined in the shader
  17497. * @param value Define the value to give to the uniform
  17498. * @return the material itself allowing "fluent" like uniform updates
  17499. */
  17500. setVector2(name: string, value: Vector2): ShaderMaterial;
  17501. /**
  17502. * Set a vec3 in the shader from a Vector3.
  17503. * @param name Define the name of the uniform as defined in the shader
  17504. * @param value Define the value to give to the uniform
  17505. * @return the material itself allowing "fluent" like uniform updates
  17506. */
  17507. setVector3(name: string, value: Vector3): ShaderMaterial;
  17508. /**
  17509. * Set a vec4 in the shader from a Vector4.
  17510. * @param name Define the name of the uniform as defined in the shader
  17511. * @param value Define the value to give to the uniform
  17512. * @return the material itself allowing "fluent" like uniform updates
  17513. */
  17514. setVector4(name: string, value: Vector4): ShaderMaterial;
  17515. /**
  17516. * Set a mat4 in the shader from a Matrix.
  17517. * @param name Define the name of the uniform as defined in the shader
  17518. * @param value Define the value to give to the uniform
  17519. * @return the material itself allowing "fluent" like uniform updates
  17520. */
  17521. setMatrix(name: string, value: Matrix): ShaderMaterial;
  17522. /**
  17523. * Set a mat3 in the shader from a Float32Array.
  17524. * @param name Define the name of the uniform as defined in the shader
  17525. * @param value Define the value to give to the uniform
  17526. * @return the material itself allowing "fluent" like uniform updates
  17527. */
  17528. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  17529. /**
  17530. * Set a mat2 in the shader from a Float32Array.
  17531. * @param name Define the name of the uniform as defined in the shader
  17532. * @param value Define the value to give to the uniform
  17533. * @return the material itself allowing "fluent" like uniform updates
  17534. */
  17535. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  17536. /**
  17537. * Set a vec2 array in the shader from a number array.
  17538. * @param name Define the name of the uniform as defined in the shader
  17539. * @param value Define the value to give to the uniform
  17540. * @return the material itself allowing "fluent" like uniform updates
  17541. */
  17542. setArray2(name: string, value: number[]): ShaderMaterial;
  17543. /**
  17544. * Set a vec3 array in the shader from a number array.
  17545. * @param name Define the name of the uniform as defined in the shader
  17546. * @param value Define the value to give to the uniform
  17547. * @return the material itself allowing "fluent" like uniform updates
  17548. */
  17549. setArray3(name: string, value: number[]): ShaderMaterial;
  17550. private _checkCache;
  17551. /**
  17552. * Specifies that the submesh is ready to be used
  17553. * @param mesh defines the mesh to check
  17554. * @param subMesh defines which submesh to check
  17555. * @param useInstances specifies that instances should be used
  17556. * @returns a boolean indicating that the submesh is ready or not
  17557. */
  17558. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  17559. /**
  17560. * Checks if the material is ready to render the requested mesh
  17561. * @param mesh Define the mesh to render
  17562. * @param useInstances Define whether or not the material is used with instances
  17563. * @returns true if ready, otherwise false
  17564. */
  17565. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17566. /**
  17567. * Binds the world matrix to the material
  17568. * @param world defines the world transformation matrix
  17569. */
  17570. bindOnlyWorldMatrix(world: Matrix): void;
  17571. /**
  17572. * Binds the material to the mesh
  17573. * @param world defines the world transformation matrix
  17574. * @param mesh defines the mesh to bind the material to
  17575. */
  17576. bind(world: Matrix, mesh?: Mesh): void;
  17577. /**
  17578. * Gets the active textures from the material
  17579. * @returns an array of textures
  17580. */
  17581. getActiveTextures(): BaseTexture[];
  17582. /**
  17583. * Specifies if the material uses a texture
  17584. * @param texture defines the texture to check against the material
  17585. * @returns a boolean specifying if the material uses the texture
  17586. */
  17587. hasTexture(texture: BaseTexture): boolean;
  17588. /**
  17589. * Makes a duplicate of the material, and gives it a new name
  17590. * @param name defines the new name for the duplicated material
  17591. * @returns the cloned material
  17592. */
  17593. clone(name: string): ShaderMaterial;
  17594. /**
  17595. * Disposes the material
  17596. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17597. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17598. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  17599. */
  17600. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  17601. /**
  17602. * Serializes this material in a JSON representation
  17603. * @returns the serialized material object
  17604. */
  17605. serialize(): any;
  17606. /**
  17607. * Creates a shader material from parsed shader material data
  17608. * @param source defines the JSON represnetation of the material
  17609. * @param scene defines the hosting scene
  17610. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17611. * @returns a new material
  17612. */
  17613. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  17614. }
  17615. }
  17616. declare module "babylonjs/Shaders/color.fragment" {
  17617. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17618. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17619. /** @hidden */
  17620. export var colorPixelShader: {
  17621. name: string;
  17622. shader: string;
  17623. };
  17624. }
  17625. declare module "babylonjs/Shaders/color.vertex" {
  17626. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  17627. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17628. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17629. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17630. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  17631. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17632. /** @hidden */
  17633. export var colorVertexShader: {
  17634. name: string;
  17635. shader: string;
  17636. };
  17637. }
  17638. declare module "babylonjs/Meshes/linesMesh" {
  17639. import { Nullable } from "babylonjs/types";
  17640. import { Scene } from "babylonjs/scene";
  17641. import { Color3 } from "babylonjs/Maths/math";
  17642. import { Node } from "babylonjs/node";
  17643. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17644. import { Mesh } from "babylonjs/Meshes/mesh";
  17645. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  17646. import { Effect } from "babylonjs/Materials/effect";
  17647. import { Material } from "babylonjs/Materials/material";
  17648. import "babylonjs/Shaders/color.fragment";
  17649. import "babylonjs/Shaders/color.vertex";
  17650. /**
  17651. * Line mesh
  17652. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  17653. */
  17654. export class LinesMesh extends Mesh {
  17655. /**
  17656. * If vertex color should be applied to the mesh
  17657. */
  17658. useVertexColor?: boolean | undefined;
  17659. /**
  17660. * If vertex alpha should be applied to the mesh
  17661. */
  17662. useVertexAlpha?: boolean | undefined;
  17663. /**
  17664. * Color of the line (Default: White)
  17665. */
  17666. color: Color3;
  17667. /**
  17668. * Alpha of the line (Default: 1)
  17669. */
  17670. alpha: number;
  17671. /**
  17672. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17673. * This margin is expressed in world space coordinates, so its value may vary.
  17674. * Default value is 0.1
  17675. */
  17676. intersectionThreshold: number;
  17677. private _colorShader;
  17678. /**
  17679. * Creates a new LinesMesh
  17680. * @param name defines the name
  17681. * @param scene defines the hosting scene
  17682. * @param parent defines the parent mesh if any
  17683. * @param source defines the optional source LinesMesh used to clone data from
  17684. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  17685. * When false, achieved by calling a clone(), also passing False.
  17686. * This will make creation of children, recursive.
  17687. * @param useVertexColor defines if this LinesMesh supports vertex color
  17688. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  17689. */
  17690. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  17691. /**
  17692. * If vertex color should be applied to the mesh
  17693. */
  17694. useVertexColor?: boolean | undefined,
  17695. /**
  17696. * If vertex alpha should be applied to the mesh
  17697. */
  17698. useVertexAlpha?: boolean | undefined);
  17699. private _addClipPlaneDefine;
  17700. private _removeClipPlaneDefine;
  17701. isReady(): boolean;
  17702. /**
  17703. * Returns the string "LineMesh"
  17704. */
  17705. getClassName(): string;
  17706. /**
  17707. * @hidden
  17708. */
  17709. /**
  17710. * @hidden
  17711. */
  17712. material: Material;
  17713. /**
  17714. * @hidden
  17715. */
  17716. readonly checkCollisions: boolean;
  17717. /** @hidden */
  17718. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  17719. /** @hidden */
  17720. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  17721. /**
  17722. * Disposes of the line mesh
  17723. * @param doNotRecurse If children should be disposed
  17724. */
  17725. dispose(doNotRecurse?: boolean): void;
  17726. /**
  17727. * Returns a new LineMesh object cloned from the current one.
  17728. */
  17729. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  17730. /**
  17731. * Creates a new InstancedLinesMesh object from the mesh model.
  17732. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  17733. * @param name defines the name of the new instance
  17734. * @returns a new InstancedLinesMesh
  17735. */
  17736. createInstance(name: string): InstancedLinesMesh;
  17737. }
  17738. /**
  17739. * Creates an instance based on a source LinesMesh
  17740. */
  17741. export class InstancedLinesMesh extends InstancedMesh {
  17742. /**
  17743. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17744. * This margin is expressed in world space coordinates, so its value may vary.
  17745. * Initilized with the intersectionThreshold value of the source LinesMesh
  17746. */
  17747. intersectionThreshold: number;
  17748. constructor(name: string, source: LinesMesh);
  17749. /**
  17750. * Returns the string "InstancedLinesMesh".
  17751. */
  17752. getClassName(): string;
  17753. }
  17754. }
  17755. declare module "babylonjs/Shaders/line.fragment" {
  17756. /** @hidden */
  17757. export var linePixelShader: {
  17758. name: string;
  17759. shader: string;
  17760. };
  17761. }
  17762. declare module "babylonjs/Shaders/line.vertex" {
  17763. /** @hidden */
  17764. export var lineVertexShader: {
  17765. name: string;
  17766. shader: string;
  17767. };
  17768. }
  17769. declare module "babylonjs/Rendering/edgesRenderer" {
  17770. import { Nullable } from "babylonjs/types";
  17771. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  17772. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17773. import { Vector3 } from "babylonjs/Maths/math";
  17774. import { IDisposable } from "babylonjs/scene";
  17775. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  17776. import "babylonjs/Shaders/line.fragment";
  17777. import "babylonjs/Shaders/line.vertex";
  17778. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  17779. module "babylonjs/Meshes/abstractMesh" {
  17780. interface AbstractMesh {
  17781. /**
  17782. * Gets the edgesRenderer associated with the mesh
  17783. */
  17784. edgesRenderer: Nullable<EdgesRenderer>;
  17785. }
  17786. }
  17787. module "babylonjs/Meshes/linesMesh" {
  17788. interface LinesMesh {
  17789. /**
  17790. * Enables the edge rendering mode on the mesh.
  17791. * This mode makes the mesh edges visible
  17792. * @param epsilon defines the maximal distance between two angles to detect a face
  17793. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17794. * @returns the currentAbstractMesh
  17795. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17796. */
  17797. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17798. }
  17799. }
  17800. module "babylonjs/Meshes/linesMesh" {
  17801. interface InstancedLinesMesh {
  17802. /**
  17803. * Enables the edge rendering mode on the mesh.
  17804. * This mode makes the mesh edges visible
  17805. * @param epsilon defines the maximal distance between two angles to detect a face
  17806. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17807. * @returns the current InstancedLinesMesh
  17808. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17809. */
  17810. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17811. }
  17812. }
  17813. /**
  17814. * Defines the minimum contract an Edges renderer should follow.
  17815. */
  17816. export interface IEdgesRenderer extends IDisposable {
  17817. /**
  17818. * Gets or sets a boolean indicating if the edgesRenderer is active
  17819. */
  17820. isEnabled: boolean;
  17821. /**
  17822. * Renders the edges of the attached mesh,
  17823. */
  17824. render(): void;
  17825. /**
  17826. * Checks wether or not the edges renderer is ready to render.
  17827. * @return true if ready, otherwise false.
  17828. */
  17829. isReady(): boolean;
  17830. }
  17831. /**
  17832. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17833. */
  17834. export class EdgesRenderer implements IEdgesRenderer {
  17835. /**
  17836. * Define the size of the edges with an orthographic camera
  17837. */
  17838. edgesWidthScalerForOrthographic: number;
  17839. /**
  17840. * Define the size of the edges with a perspective camera
  17841. */
  17842. edgesWidthScalerForPerspective: number;
  17843. protected _source: AbstractMesh;
  17844. protected _linesPositions: number[];
  17845. protected _linesNormals: number[];
  17846. protected _linesIndices: number[];
  17847. protected _epsilon: number;
  17848. protected _indicesCount: number;
  17849. protected _lineShader: ShaderMaterial;
  17850. protected _ib: DataBuffer;
  17851. protected _buffers: {
  17852. [key: string]: Nullable<VertexBuffer>;
  17853. };
  17854. protected _checkVerticesInsteadOfIndices: boolean;
  17855. private _meshRebuildObserver;
  17856. private _meshDisposeObserver;
  17857. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17858. isEnabled: boolean;
  17859. /**
  17860. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17861. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17862. * @param source Mesh used to create edges
  17863. * @param epsilon sum of angles in adjacency to check for edge
  17864. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  17865. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17866. */
  17867. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  17868. protected _prepareRessources(): void;
  17869. /** @hidden */
  17870. _rebuild(): void;
  17871. /**
  17872. * Releases the required resources for the edges renderer
  17873. */
  17874. dispose(): void;
  17875. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17876. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17877. /**
  17878. * Checks if the pair of p0 and p1 is en edge
  17879. * @param faceIndex
  17880. * @param edge
  17881. * @param faceNormals
  17882. * @param p0
  17883. * @param p1
  17884. * @private
  17885. */
  17886. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17887. /**
  17888. * push line into the position, normal and index buffer
  17889. * @protected
  17890. */
  17891. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17892. /**
  17893. * Generates lines edges from adjacencjes
  17894. * @private
  17895. */
  17896. _generateEdgesLines(): void;
  17897. /**
  17898. * Checks wether or not the edges renderer is ready to render.
  17899. * @return true if ready, otherwise false.
  17900. */
  17901. isReady(): boolean;
  17902. /**
  17903. * Renders the edges of the attached mesh,
  17904. */
  17905. render(): void;
  17906. }
  17907. /**
  17908. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17909. */
  17910. export class LineEdgesRenderer extends EdgesRenderer {
  17911. /**
  17912. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17913. * @param source LineMesh used to generate edges
  17914. * @param epsilon not important (specified angle for edge detection)
  17915. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17916. */
  17917. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17918. /**
  17919. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17920. */
  17921. _generateEdgesLines(): void;
  17922. }
  17923. }
  17924. declare module "babylonjs/Rendering/renderingGroup" {
  17925. import { SmartArray } from "babylonjs/Misc/smartArray";
  17926. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17927. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17928. import { Nullable } from "babylonjs/types";
  17929. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17930. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  17931. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17932. import { Material } from "babylonjs/Materials/material";
  17933. import { Scene } from "babylonjs/scene";
  17934. /**
  17935. * This represents the object necessary to create a rendering group.
  17936. * This is exclusively used and created by the rendering manager.
  17937. * To modify the behavior, you use the available helpers in your scene or meshes.
  17938. * @hidden
  17939. */
  17940. export class RenderingGroup {
  17941. index: number;
  17942. private _scene;
  17943. private _opaqueSubMeshes;
  17944. private _transparentSubMeshes;
  17945. private _alphaTestSubMeshes;
  17946. private _depthOnlySubMeshes;
  17947. private _particleSystems;
  17948. private _spriteManagers;
  17949. private _opaqueSortCompareFn;
  17950. private _alphaTestSortCompareFn;
  17951. private _transparentSortCompareFn;
  17952. private _renderOpaque;
  17953. private _renderAlphaTest;
  17954. private _renderTransparent;
  17955. /** @hidden */
  17956. _edgesRenderers: SmartArray<IEdgesRenderer>;
  17957. onBeforeTransparentRendering: () => void;
  17958. /**
  17959. * Set the opaque sort comparison function.
  17960. * If null the sub meshes will be render in the order they were created
  17961. */
  17962. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17963. /**
  17964. * Set the alpha test sort comparison function.
  17965. * If null the sub meshes will be render in the order they were created
  17966. */
  17967. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17968. /**
  17969. * Set the transparent sort comparison function.
  17970. * If null the sub meshes will be render in the order they were created
  17971. */
  17972. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17973. /**
  17974. * Creates a new rendering group.
  17975. * @param index The rendering group index
  17976. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17977. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17978. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17979. */
  17980. 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>);
  17981. /**
  17982. * Render all the sub meshes contained in the group.
  17983. * @param customRenderFunction Used to override the default render behaviour of the group.
  17984. * @returns true if rendered some submeshes.
  17985. */
  17986. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17987. /**
  17988. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17989. * @param subMeshes The submeshes to render
  17990. */
  17991. private renderOpaqueSorted;
  17992. /**
  17993. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17994. * @param subMeshes The submeshes to render
  17995. */
  17996. private renderAlphaTestSorted;
  17997. /**
  17998. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17999. * @param subMeshes The submeshes to render
  18000. */
  18001. private renderTransparentSorted;
  18002. /**
  18003. * Renders the submeshes in a specified order.
  18004. * @param subMeshes The submeshes to sort before render
  18005. * @param sortCompareFn The comparison function use to sort
  18006. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  18007. * @param transparent Specifies to activate blending if true
  18008. */
  18009. private static renderSorted;
  18010. /**
  18011. * Renders the submeshes in the order they were dispatched (no sort applied).
  18012. * @param subMeshes The submeshes to render
  18013. */
  18014. private static renderUnsorted;
  18015. /**
  18016. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  18017. * are rendered back to front if in the same alpha index.
  18018. *
  18019. * @param a The first submesh
  18020. * @param b The second submesh
  18021. * @returns The result of the comparison
  18022. */
  18023. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  18024. /**
  18025. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  18026. * are rendered back to front.
  18027. *
  18028. * @param a The first submesh
  18029. * @param b The second submesh
  18030. * @returns The result of the comparison
  18031. */
  18032. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  18033. /**
  18034. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  18035. * are rendered front to back (prevent overdraw).
  18036. *
  18037. * @param a The first submesh
  18038. * @param b The second submesh
  18039. * @returns The result of the comparison
  18040. */
  18041. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  18042. /**
  18043. * Resets the different lists of submeshes to prepare a new frame.
  18044. */
  18045. prepare(): void;
  18046. dispose(): void;
  18047. /**
  18048. * Inserts the submesh in its correct queue depending on its material.
  18049. * @param subMesh The submesh to dispatch
  18050. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  18051. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  18052. */
  18053. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  18054. dispatchSprites(spriteManager: ISpriteManager): void;
  18055. dispatchParticles(particleSystem: IParticleSystem): void;
  18056. private _renderParticles;
  18057. private _renderSprites;
  18058. }
  18059. }
  18060. declare module "babylonjs/Rendering/renderingManager" {
  18061. import { Nullable } from "babylonjs/types";
  18062. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18063. import { SubMesh } from "babylonjs/Meshes/subMesh";
  18064. import { SmartArray } from "babylonjs/Misc/smartArray";
  18065. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  18066. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  18067. import { Material } from "babylonjs/Materials/material";
  18068. import { Scene } from "babylonjs/scene";
  18069. import { Camera } from "babylonjs/Cameras/camera";
  18070. /**
  18071. * Interface describing the different options available in the rendering manager
  18072. * regarding Auto Clear between groups.
  18073. */
  18074. export interface IRenderingManagerAutoClearSetup {
  18075. /**
  18076. * Defines whether or not autoclear is enable.
  18077. */
  18078. autoClear: boolean;
  18079. /**
  18080. * Defines whether or not to autoclear the depth buffer.
  18081. */
  18082. depth: boolean;
  18083. /**
  18084. * Defines whether or not to autoclear the stencil buffer.
  18085. */
  18086. stencil: boolean;
  18087. }
  18088. /**
  18089. * This class is used by the onRenderingGroupObservable
  18090. */
  18091. export class RenderingGroupInfo {
  18092. /**
  18093. * The Scene that being rendered
  18094. */
  18095. scene: Scene;
  18096. /**
  18097. * The camera currently used for the rendering pass
  18098. */
  18099. camera: Nullable<Camera>;
  18100. /**
  18101. * The ID of the renderingGroup being processed
  18102. */
  18103. renderingGroupId: number;
  18104. }
  18105. /**
  18106. * This is the manager responsible of all the rendering for meshes sprites and particles.
  18107. * It is enable to manage the different groups as well as the different necessary sort functions.
  18108. * This should not be used directly aside of the few static configurations
  18109. */
  18110. export class RenderingManager {
  18111. /**
  18112. * The max id used for rendering groups (not included)
  18113. */
  18114. static MAX_RENDERINGGROUPS: number;
  18115. /**
  18116. * The min id used for rendering groups (included)
  18117. */
  18118. static MIN_RENDERINGGROUPS: number;
  18119. /**
  18120. * Used to globally prevent autoclearing scenes.
  18121. */
  18122. static AUTOCLEAR: boolean;
  18123. /**
  18124. * @hidden
  18125. */
  18126. _useSceneAutoClearSetup: boolean;
  18127. private _scene;
  18128. private _renderingGroups;
  18129. private _depthStencilBufferAlreadyCleaned;
  18130. private _autoClearDepthStencil;
  18131. private _customOpaqueSortCompareFn;
  18132. private _customAlphaTestSortCompareFn;
  18133. private _customTransparentSortCompareFn;
  18134. private _renderingGroupInfo;
  18135. /**
  18136. * Instantiates a new rendering group for a particular scene
  18137. * @param scene Defines the scene the groups belongs to
  18138. */
  18139. constructor(scene: Scene);
  18140. private _clearDepthStencilBuffer;
  18141. /**
  18142. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  18143. * @hidden
  18144. */
  18145. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  18146. /**
  18147. * Resets the different information of the group to prepare a new frame
  18148. * @hidden
  18149. */
  18150. reset(): void;
  18151. /**
  18152. * Dispose and release the group and its associated resources.
  18153. * @hidden
  18154. */
  18155. dispose(): void;
  18156. /**
  18157. * Clear the info related to rendering groups preventing retention points during dispose.
  18158. */
  18159. freeRenderingGroups(): void;
  18160. private _prepareRenderingGroup;
  18161. /**
  18162. * Add a sprite manager to the rendering manager in order to render it this frame.
  18163. * @param spriteManager Define the sprite manager to render
  18164. */
  18165. dispatchSprites(spriteManager: ISpriteManager): void;
  18166. /**
  18167. * Add a particle system to the rendering manager in order to render it this frame.
  18168. * @param particleSystem Define the particle system to render
  18169. */
  18170. dispatchParticles(particleSystem: IParticleSystem): void;
  18171. /**
  18172. * Add a submesh to the manager in order to render it this frame
  18173. * @param subMesh The submesh to dispatch
  18174. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  18175. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  18176. */
  18177. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  18178. /**
  18179. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  18180. * This allowed control for front to back rendering or reversly depending of the special needs.
  18181. *
  18182. * @param renderingGroupId The rendering group id corresponding to its index
  18183. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  18184. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  18185. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  18186. */
  18187. 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;
  18188. /**
  18189. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  18190. *
  18191. * @param renderingGroupId The rendering group id corresponding to its index
  18192. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  18193. * @param depth Automatically clears depth between groups if true and autoClear is true.
  18194. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  18195. */
  18196. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  18197. /**
  18198. * Gets the current auto clear configuration for one rendering group of the rendering
  18199. * manager.
  18200. * @param index the rendering group index to get the information for
  18201. * @returns The auto clear setup for the requested rendering group
  18202. */
  18203. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  18204. }
  18205. }
  18206. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  18207. import { Observable } from "babylonjs/Misc/observable";
  18208. import { SmartArray } from "babylonjs/Misc/smartArray";
  18209. import { Nullable } from "babylonjs/types";
  18210. import { Camera } from "babylonjs/Cameras/camera";
  18211. import { Scene } from "babylonjs/scene";
  18212. import { Matrix, Vector3, Color4 } from "babylonjs/Maths/math";
  18213. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  18214. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18215. import { SubMesh } from "babylonjs/Meshes/subMesh";
  18216. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  18217. import { Texture } from "babylonjs/Materials/Textures/texture";
  18218. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  18219. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  18220. import "babylonjs/Engines/Extensions/engine.renderTarget";
  18221. import { Engine } from "babylonjs/Engines/engine";
  18222. /**
  18223. * This Helps creating a texture that will be created from a camera in your scene.
  18224. * It is basically a dynamic texture that could be used to create special effects for instance.
  18225. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  18226. */
  18227. export class RenderTargetTexture extends Texture {
  18228. isCube: boolean;
  18229. /**
  18230. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  18231. */
  18232. static readonly REFRESHRATE_RENDER_ONCE: number;
  18233. /**
  18234. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  18235. */
  18236. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  18237. /**
  18238. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  18239. * the central point of your effect and can save a lot of performances.
  18240. */
  18241. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  18242. /**
  18243. * Use this predicate to dynamically define the list of mesh you want to render.
  18244. * If set, the renderList property will be overwritten.
  18245. */
  18246. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  18247. private _renderList;
  18248. /**
  18249. * Use this list to define the list of mesh you want to render.
  18250. */
  18251. renderList: Nullable<Array<AbstractMesh>>;
  18252. private _hookArray;
  18253. /**
  18254. * Define if particles should be rendered in your texture.
  18255. */
  18256. renderParticles: boolean;
  18257. /**
  18258. * Define if sprites should be rendered in your texture.
  18259. */
  18260. renderSprites: boolean;
  18261. /**
  18262. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  18263. */
  18264. coordinatesMode: number;
  18265. /**
  18266. * Define the camera used to render the texture.
  18267. */
  18268. activeCamera: Nullable<Camera>;
  18269. /**
  18270. * Override the render function of the texture with your own one.
  18271. */
  18272. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  18273. /**
  18274. * Define if camera post processes should be use while rendering the texture.
  18275. */
  18276. useCameraPostProcesses: boolean;
  18277. /**
  18278. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  18279. */
  18280. ignoreCameraViewport: boolean;
  18281. private _postProcessManager;
  18282. private _postProcesses;
  18283. private _resizeObserver;
  18284. /**
  18285. * An event triggered when the texture is unbind.
  18286. */
  18287. onBeforeBindObservable: Observable<RenderTargetTexture>;
  18288. /**
  18289. * An event triggered when the texture is unbind.
  18290. */
  18291. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  18292. private _onAfterUnbindObserver;
  18293. /**
  18294. * Set a after unbind callback in the texture.
  18295. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  18296. */
  18297. onAfterUnbind: () => void;
  18298. /**
  18299. * An event triggered before rendering the texture
  18300. */
  18301. onBeforeRenderObservable: Observable<number>;
  18302. private _onBeforeRenderObserver;
  18303. /**
  18304. * Set a before render callback in the texture.
  18305. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  18306. */
  18307. onBeforeRender: (faceIndex: number) => void;
  18308. /**
  18309. * An event triggered after rendering the texture
  18310. */
  18311. onAfterRenderObservable: Observable<number>;
  18312. private _onAfterRenderObserver;
  18313. /**
  18314. * Set a after render callback in the texture.
  18315. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  18316. */
  18317. onAfterRender: (faceIndex: number) => void;
  18318. /**
  18319. * An event triggered after the texture clear
  18320. */
  18321. onClearObservable: Observable<import("babylonjs/Engines/engine").Engine>;
  18322. private _onClearObserver;
  18323. /**
  18324. * Set a clear callback in the texture.
  18325. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  18326. */
  18327. onClear: (Engine: Engine) => void;
  18328. /**
  18329. * Define the clear color of the Render Target if it should be different from the scene.
  18330. */
  18331. clearColor: Color4;
  18332. protected _size: number | {
  18333. width: number;
  18334. height: number;
  18335. };
  18336. protected _initialSizeParameter: number | {
  18337. width: number;
  18338. height: number;
  18339. } | {
  18340. ratio: number;
  18341. };
  18342. protected _sizeRatio: Nullable<number>;
  18343. /** @hidden */
  18344. _generateMipMaps: boolean;
  18345. protected _renderingManager: RenderingManager;
  18346. /** @hidden */
  18347. _waitingRenderList: string[];
  18348. protected _doNotChangeAspectRatio: boolean;
  18349. protected _currentRefreshId: number;
  18350. protected _refreshRate: number;
  18351. protected _textureMatrix: Matrix;
  18352. protected _samples: number;
  18353. protected _renderTargetOptions: RenderTargetCreationOptions;
  18354. /**
  18355. * Gets render target creation options that were used.
  18356. */
  18357. readonly renderTargetOptions: RenderTargetCreationOptions;
  18358. protected _engine: Engine;
  18359. protected _onRatioRescale(): void;
  18360. /**
  18361. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  18362. * It must define where the camera used to render the texture is set
  18363. */
  18364. boundingBoxPosition: Vector3;
  18365. private _boundingBoxSize;
  18366. /**
  18367. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  18368. * When defined, the cubemap will switch to local mode
  18369. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  18370. * @example https://www.babylonjs-playground.com/#RNASML
  18371. */
  18372. boundingBoxSize: Vector3;
  18373. /**
  18374. * In case the RTT has been created with a depth texture, get the associated
  18375. * depth texture.
  18376. * Otherwise, return null.
  18377. */
  18378. depthStencilTexture: Nullable<InternalTexture>;
  18379. /**
  18380. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  18381. * or used a shadow, depth texture...
  18382. * @param name The friendly name of the texture
  18383. * @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)
  18384. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  18385. * @param generateMipMaps True if mip maps need to be generated after render.
  18386. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  18387. * @param type The type of the buffer in the RTT (int, half float, float...)
  18388. * @param isCube True if a cube texture needs to be created
  18389. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  18390. * @param generateDepthBuffer True to generate a depth buffer
  18391. * @param generateStencilBuffer True to generate a stencil buffer
  18392. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  18393. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  18394. * @param delayAllocation if the texture allocation should be delayed (default: false)
  18395. */
  18396. constructor(name: string, size: number | {
  18397. width: number;
  18398. height: number;
  18399. } | {
  18400. ratio: number;
  18401. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  18402. /**
  18403. * Creates a depth stencil texture.
  18404. * This is only available in WebGL 2 or with the depth texture extension available.
  18405. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  18406. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  18407. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  18408. */
  18409. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  18410. private _processSizeParameter;
  18411. /**
  18412. * Define the number of samples to use in case of MSAA.
  18413. * It defaults to one meaning no MSAA has been enabled.
  18414. */
  18415. samples: number;
  18416. /**
  18417. * Resets the refresh counter of the texture and start bak from scratch.
  18418. * Could be useful to regenerate the texture if it is setup to render only once.
  18419. */
  18420. resetRefreshCounter(): void;
  18421. /**
  18422. * Define the refresh rate of the texture or the rendering frequency.
  18423. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  18424. */
  18425. refreshRate: number;
  18426. /**
  18427. * Adds a post process to the render target rendering passes.
  18428. * @param postProcess define the post process to add
  18429. */
  18430. addPostProcess(postProcess: PostProcess): void;
  18431. /**
  18432. * Clear all the post processes attached to the render target
  18433. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  18434. */
  18435. clearPostProcesses(dispose?: boolean): void;
  18436. /**
  18437. * Remove one of the post process from the list of attached post processes to the texture
  18438. * @param postProcess define the post process to remove from the list
  18439. */
  18440. removePostProcess(postProcess: PostProcess): void;
  18441. /** @hidden */
  18442. _shouldRender(): boolean;
  18443. /**
  18444. * Gets the actual render size of the texture.
  18445. * @returns the width of the render size
  18446. */
  18447. getRenderSize(): number;
  18448. /**
  18449. * Gets the actual render width of the texture.
  18450. * @returns the width of the render size
  18451. */
  18452. getRenderWidth(): number;
  18453. /**
  18454. * Gets the actual render height of the texture.
  18455. * @returns the height of the render size
  18456. */
  18457. getRenderHeight(): number;
  18458. /**
  18459. * Get if the texture can be rescaled or not.
  18460. */
  18461. readonly canRescale: boolean;
  18462. /**
  18463. * Resize the texture using a ratio.
  18464. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  18465. */
  18466. scale(ratio: number): void;
  18467. /**
  18468. * Get the texture reflection matrix used to rotate/transform the reflection.
  18469. * @returns the reflection matrix
  18470. */
  18471. getReflectionTextureMatrix(): Matrix;
  18472. /**
  18473. * Resize the texture to a new desired size.
  18474. * Be carrefull as it will recreate all the data in the new texture.
  18475. * @param size Define the new size. It can be:
  18476. * - a number for squared texture,
  18477. * - an object containing { width: number, height: number }
  18478. * - or an object containing a ratio { ratio: number }
  18479. */
  18480. resize(size: number | {
  18481. width: number;
  18482. height: number;
  18483. } | {
  18484. ratio: number;
  18485. }): void;
  18486. /**
  18487. * Renders all the objects from the render list into the texture.
  18488. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  18489. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  18490. */
  18491. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  18492. private _bestReflectionRenderTargetDimension;
  18493. /**
  18494. * @hidden
  18495. * @param faceIndex face index to bind to if this is a cubetexture
  18496. */
  18497. _bindFrameBuffer(faceIndex?: number): void;
  18498. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  18499. private renderToTarget;
  18500. /**
  18501. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  18502. * This allowed control for front to back rendering or reversly depending of the special needs.
  18503. *
  18504. * @param renderingGroupId The rendering group id corresponding to its index
  18505. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  18506. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  18507. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  18508. */
  18509. 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;
  18510. /**
  18511. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  18512. *
  18513. * @param renderingGroupId The rendering group id corresponding to its index
  18514. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  18515. */
  18516. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  18517. /**
  18518. * Clones the texture.
  18519. * @returns the cloned texture
  18520. */
  18521. clone(): RenderTargetTexture;
  18522. /**
  18523. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18524. * @returns The JSON representation of the texture
  18525. */
  18526. serialize(): any;
  18527. /**
  18528. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  18529. */
  18530. disposeFramebufferObjects(): void;
  18531. /**
  18532. * Dispose the texture and release its associated resources.
  18533. */
  18534. dispose(): void;
  18535. /** @hidden */
  18536. _rebuild(): void;
  18537. /**
  18538. * Clear the info related to rendering groups preventing retention point in material dispose.
  18539. */
  18540. freeRenderingGroups(): void;
  18541. /**
  18542. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  18543. * @returns the view count
  18544. */
  18545. getViewCount(): number;
  18546. }
  18547. }
  18548. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  18549. import { Scene } from "babylonjs/scene";
  18550. import { Plane } from "babylonjs/Maths/math";
  18551. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  18552. /**
  18553. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18554. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18555. * You can then easily use it as a reflectionTexture on a flat surface.
  18556. * In case the surface is not a plane, please consider relying on reflection probes.
  18557. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18558. */
  18559. export class MirrorTexture extends RenderTargetTexture {
  18560. private scene;
  18561. /**
  18562. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  18563. * 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.
  18564. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18565. */
  18566. mirrorPlane: Plane;
  18567. /**
  18568. * Define the blur ratio used to blur the reflection if needed.
  18569. */
  18570. blurRatio: number;
  18571. /**
  18572. * Define the adaptive blur kernel used to blur the reflection if needed.
  18573. * This will autocompute the closest best match for the `blurKernel`
  18574. */
  18575. adaptiveBlurKernel: number;
  18576. /**
  18577. * Define the blur kernel used to blur the reflection if needed.
  18578. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18579. */
  18580. blurKernel: number;
  18581. /**
  18582. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  18583. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18584. */
  18585. blurKernelX: number;
  18586. /**
  18587. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  18588. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18589. */
  18590. blurKernelY: number;
  18591. private _autoComputeBlurKernel;
  18592. protected _onRatioRescale(): void;
  18593. private _updateGammaSpace;
  18594. private _imageProcessingConfigChangeObserver;
  18595. private _transformMatrix;
  18596. private _mirrorMatrix;
  18597. private _savedViewMatrix;
  18598. private _blurX;
  18599. private _blurY;
  18600. private _adaptiveBlurKernel;
  18601. private _blurKernelX;
  18602. private _blurKernelY;
  18603. private _blurRatio;
  18604. /**
  18605. * Instantiates a Mirror Texture.
  18606. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18607. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18608. * You can then easily use it as a reflectionTexture on a flat surface.
  18609. * In case the surface is not a plane, please consider relying on reflection probes.
  18610. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18611. * @param name
  18612. * @param size
  18613. * @param scene
  18614. * @param generateMipMaps
  18615. * @param type
  18616. * @param samplingMode
  18617. * @param generateDepthBuffer
  18618. */
  18619. constructor(name: string, size: number | {
  18620. width: number;
  18621. height: number;
  18622. } | {
  18623. ratio: number;
  18624. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  18625. private _preparePostProcesses;
  18626. /**
  18627. * Clone the mirror texture.
  18628. * @returns the cloned texture
  18629. */
  18630. clone(): MirrorTexture;
  18631. /**
  18632. * Serialize the texture to a JSON representation you could use in Parse later on
  18633. * @returns the serialized JSON representation
  18634. */
  18635. serialize(): any;
  18636. /**
  18637. * Dispose the texture and release its associated resources.
  18638. */
  18639. dispose(): void;
  18640. }
  18641. }
  18642. declare module "babylonjs/Materials/Textures/texture" {
  18643. import { Observable } from "babylonjs/Misc/observable";
  18644. import { Nullable } from "babylonjs/types";
  18645. import { Scene } from "babylonjs/scene";
  18646. import { Matrix } from "babylonjs/Maths/math";
  18647. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18648. import { IInspectable } from "babylonjs/Misc/iInspectable";
  18649. /**
  18650. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18651. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18652. */
  18653. export class Texture extends BaseTexture {
  18654. /** @hidden */
  18655. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  18656. /** @hidden */
  18657. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  18658. /** @hidden */
  18659. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  18660. /** nearest is mag = nearest and min = nearest and mip = linear */
  18661. static readonly NEAREST_SAMPLINGMODE: number;
  18662. /** nearest is mag = nearest and min = nearest and mip = linear */
  18663. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  18664. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18665. static readonly BILINEAR_SAMPLINGMODE: number;
  18666. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18667. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  18668. /** Trilinear is mag = linear and min = linear and mip = linear */
  18669. static readonly TRILINEAR_SAMPLINGMODE: number;
  18670. /** Trilinear is mag = linear and min = linear and mip = linear */
  18671. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  18672. /** mag = nearest and min = nearest and mip = nearest */
  18673. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  18674. /** mag = nearest and min = linear and mip = nearest */
  18675. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  18676. /** mag = nearest and min = linear and mip = linear */
  18677. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  18678. /** mag = nearest and min = linear and mip = none */
  18679. static readonly NEAREST_LINEAR: number;
  18680. /** mag = nearest and min = nearest and mip = none */
  18681. static readonly NEAREST_NEAREST: number;
  18682. /** mag = linear and min = nearest and mip = nearest */
  18683. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  18684. /** mag = linear and min = nearest and mip = linear */
  18685. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  18686. /** mag = linear and min = linear and mip = none */
  18687. static readonly LINEAR_LINEAR: number;
  18688. /** mag = linear and min = nearest and mip = none */
  18689. static readonly LINEAR_NEAREST: number;
  18690. /** Explicit coordinates mode */
  18691. static readonly EXPLICIT_MODE: number;
  18692. /** Spherical coordinates mode */
  18693. static readonly SPHERICAL_MODE: number;
  18694. /** Planar coordinates mode */
  18695. static readonly PLANAR_MODE: number;
  18696. /** Cubic coordinates mode */
  18697. static readonly CUBIC_MODE: number;
  18698. /** Projection coordinates mode */
  18699. static readonly PROJECTION_MODE: number;
  18700. /** Inverse Cubic coordinates mode */
  18701. static readonly SKYBOX_MODE: number;
  18702. /** Inverse Cubic coordinates mode */
  18703. static readonly INVCUBIC_MODE: number;
  18704. /** Equirectangular coordinates mode */
  18705. static readonly EQUIRECTANGULAR_MODE: number;
  18706. /** Equirectangular Fixed coordinates mode */
  18707. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  18708. /** Equirectangular Fixed Mirrored coordinates mode */
  18709. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  18710. /** Texture is not repeating outside of 0..1 UVs */
  18711. static readonly CLAMP_ADDRESSMODE: number;
  18712. /** Texture is repeating outside of 0..1 UVs */
  18713. static readonly WRAP_ADDRESSMODE: number;
  18714. /** Texture is repeating and mirrored */
  18715. static readonly MIRROR_ADDRESSMODE: number;
  18716. /**
  18717. * 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
  18718. */
  18719. static UseSerializedUrlIfAny: boolean;
  18720. /**
  18721. * Define the url of the texture.
  18722. */
  18723. url: Nullable<string>;
  18724. /**
  18725. * Define an offset on the texture to offset the u coordinates of the UVs
  18726. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18727. */
  18728. uOffset: number;
  18729. /**
  18730. * Define an offset on the texture to offset the v coordinates of the UVs
  18731. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18732. */
  18733. vOffset: number;
  18734. /**
  18735. * Define an offset on the texture to scale the u coordinates of the UVs
  18736. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18737. */
  18738. uScale: number;
  18739. /**
  18740. * Define an offset on the texture to scale the v coordinates of the UVs
  18741. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18742. */
  18743. vScale: number;
  18744. /**
  18745. * Define an offset on the texture to rotate around the u coordinates of the UVs
  18746. * @see http://doc.babylonjs.com/how_to/more_materials
  18747. */
  18748. uAng: number;
  18749. /**
  18750. * Define an offset on the texture to rotate around the v coordinates of the UVs
  18751. * @see http://doc.babylonjs.com/how_to/more_materials
  18752. */
  18753. vAng: number;
  18754. /**
  18755. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  18756. * @see http://doc.babylonjs.com/how_to/more_materials
  18757. */
  18758. wAng: number;
  18759. /**
  18760. * Defines the center of rotation (U)
  18761. */
  18762. uRotationCenter: number;
  18763. /**
  18764. * Defines the center of rotation (V)
  18765. */
  18766. vRotationCenter: number;
  18767. /**
  18768. * Defines the center of rotation (W)
  18769. */
  18770. wRotationCenter: number;
  18771. /**
  18772. * Are mip maps generated for this texture or not.
  18773. */
  18774. readonly noMipmap: boolean;
  18775. /**
  18776. * List of inspectable custom properties (used by the Inspector)
  18777. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  18778. */
  18779. inspectableCustomProperties: Nullable<IInspectable[]>;
  18780. private _noMipmap;
  18781. /** @hidden */
  18782. _invertY: boolean;
  18783. private _rowGenerationMatrix;
  18784. private _cachedTextureMatrix;
  18785. private _projectionModeMatrix;
  18786. private _t0;
  18787. private _t1;
  18788. private _t2;
  18789. private _cachedUOffset;
  18790. private _cachedVOffset;
  18791. private _cachedUScale;
  18792. private _cachedVScale;
  18793. private _cachedUAng;
  18794. private _cachedVAng;
  18795. private _cachedWAng;
  18796. private _cachedProjectionMatrixId;
  18797. private _cachedCoordinatesMode;
  18798. /** @hidden */
  18799. protected _initialSamplingMode: number;
  18800. /** @hidden */
  18801. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  18802. private _deleteBuffer;
  18803. protected _format: Nullable<number>;
  18804. private _delayedOnLoad;
  18805. private _delayedOnError;
  18806. /**
  18807. * Observable triggered once the texture has been loaded.
  18808. */
  18809. onLoadObservable: Observable<Texture>;
  18810. protected _isBlocking: boolean;
  18811. /**
  18812. * Is the texture preventing material to render while loading.
  18813. * If false, a default texture will be used instead of the loading one during the preparation step.
  18814. */
  18815. isBlocking: boolean;
  18816. /**
  18817. * Get the current sampling mode associated with the texture.
  18818. */
  18819. readonly samplingMode: number;
  18820. /**
  18821. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  18822. */
  18823. readonly invertY: boolean;
  18824. /**
  18825. * Instantiates a new texture.
  18826. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18827. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18828. * @param url define the url of the picture to load as a texture
  18829. * @param scene define the scene the texture will belong to
  18830. * @param noMipmap define if the texture will require mip maps or not
  18831. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18832. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18833. * @param onLoad define a callback triggered when the texture has been loaded
  18834. * @param onError define a callback triggered when an error occurred during the loading session
  18835. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18836. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18837. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18838. */
  18839. 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);
  18840. /**
  18841. * Update the url (and optional buffer) of this texture if url was null during construction.
  18842. * @param url the url of the texture
  18843. * @param buffer the buffer of the texture (defaults to null)
  18844. * @param onLoad callback called when the texture is loaded (defaults to null)
  18845. */
  18846. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  18847. /**
  18848. * Finish the loading sequence of a texture flagged as delayed load.
  18849. * @hidden
  18850. */
  18851. delayLoad(): void;
  18852. private _prepareRowForTextureGeneration;
  18853. /**
  18854. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  18855. * @returns the transform matrix of the texture.
  18856. */
  18857. getTextureMatrix(): Matrix;
  18858. /**
  18859. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  18860. * @returns The reflection texture transform
  18861. */
  18862. getReflectionTextureMatrix(): Matrix;
  18863. /**
  18864. * Clones the texture.
  18865. * @returns the cloned texture
  18866. */
  18867. clone(): Texture;
  18868. /**
  18869. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18870. * @returns The JSON representation of the texture
  18871. */
  18872. serialize(): any;
  18873. /**
  18874. * Get the current class name of the texture useful for serialization or dynamic coding.
  18875. * @returns "Texture"
  18876. */
  18877. getClassName(): string;
  18878. /**
  18879. * Dispose the texture and release its associated resources.
  18880. */
  18881. dispose(): void;
  18882. /**
  18883. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  18884. * @param parsedTexture Define the JSON representation of the texture
  18885. * @param scene Define the scene the parsed texture should be instantiated in
  18886. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  18887. * @returns The parsed texture if successful
  18888. */
  18889. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  18890. /**
  18891. * Creates a texture from its base 64 representation.
  18892. * @param data Define the base64 payload without the data: prefix
  18893. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18894. * @param scene Define the scene the texture should belong to
  18895. * @param noMipmap Forces the texture to not create mip map information if true
  18896. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18897. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18898. * @param onLoad define a callback triggered when the texture has been loaded
  18899. * @param onError define a callback triggered when an error occurred during the loading session
  18900. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18901. * @returns the created texture
  18902. */
  18903. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  18904. /**
  18905. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  18906. * @param data Define the base64 payload without the data: prefix
  18907. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18908. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18909. * @param scene Define the scene the texture should belong to
  18910. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18911. * @param noMipmap Forces the texture to not create mip map information if true
  18912. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18913. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18914. * @param onLoad define a callback triggered when the texture has been loaded
  18915. * @param onError define a callback triggered when an error occurred during the loading session
  18916. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18917. * @returns the created texture
  18918. */
  18919. 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;
  18920. }
  18921. }
  18922. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  18923. import { Nullable } from "babylonjs/types";
  18924. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  18925. import { Scene } from "babylonjs/scene";
  18926. module "babylonjs/Engines/engine" {
  18927. interface Engine {
  18928. /**
  18929. * Creates a raw texture
  18930. * @param data defines the data to store in the texture
  18931. * @param width defines the width of the texture
  18932. * @param height defines the height of the texture
  18933. * @param format defines the format of the data
  18934. * @param generateMipMaps defines if the engine should generate the mip levels
  18935. * @param invertY defines if data must be stored with Y axis inverted
  18936. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  18937. * @param compression defines the compression used (null by default)
  18938. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18939. * @returns the raw texture inside an InternalTexture
  18940. */
  18941. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  18942. /**
  18943. * Update a raw texture
  18944. * @param texture defines the texture to update
  18945. * @param data defines the data to store in the texture
  18946. * @param format defines the format of the data
  18947. * @param invertY defines if data must be stored with Y axis inverted
  18948. */
  18949. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  18950. /**
  18951. * Update a raw texture
  18952. * @param texture defines the texture to update
  18953. * @param data defines the data to store in the texture
  18954. * @param format defines the format of the data
  18955. * @param invertY defines if data must be stored with Y axis inverted
  18956. * @param compression defines the compression used (null by default)
  18957. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18958. */
  18959. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  18960. /**
  18961. * Creates a new raw cube texture
  18962. * @param data defines the array of data to use to create each face
  18963. * @param size defines the size of the textures
  18964. * @param format defines the format of the data
  18965. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  18966. * @param generateMipMaps defines if the engine should generate the mip levels
  18967. * @param invertY defines if data must be stored with Y axis inverted
  18968. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  18969. * @param compression defines the compression used (null by default)
  18970. * @returns the cube texture as an InternalTexture
  18971. */
  18972. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  18973. /**
  18974. * Update a raw cube texture
  18975. * @param texture defines the texture to udpdate
  18976. * @param data defines the data to store
  18977. * @param format defines the data format
  18978. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18979. * @param invertY defines if data must be stored with Y axis inverted
  18980. */
  18981. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  18982. /**
  18983. * Update a raw cube texture
  18984. * @param texture defines the texture to udpdate
  18985. * @param data defines the data to store
  18986. * @param format defines the data format
  18987. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18988. * @param invertY defines if data must be stored with Y axis inverted
  18989. * @param compression defines the compression used (null by default)
  18990. */
  18991. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  18992. /**
  18993. * Update a raw cube texture
  18994. * @param texture defines the texture to udpdate
  18995. * @param data defines the data to store
  18996. * @param format defines the data format
  18997. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18998. * @param invertY defines if data must be stored with Y axis inverted
  18999. * @param compression defines the compression used (null by default)
  19000. * @param level defines which level of the texture to update
  19001. */
  19002. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  19003. /**
  19004. * Creates a new raw cube texture from a specified url
  19005. * @param url defines the url where the data is located
  19006. * @param scene defines the current scene
  19007. * @param size defines the size of the textures
  19008. * @param format defines the format of the data
  19009. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  19010. * @param noMipmap defines if the engine should avoid generating the mip levels
  19011. * @param callback defines a callback used to extract texture data from loaded data
  19012. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  19013. * @param onLoad defines a callback called when texture is loaded
  19014. * @param onError defines a callback called if there is an error
  19015. * @returns the cube texture as an InternalTexture
  19016. */
  19017. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>): InternalTexture;
  19018. /**
  19019. * Creates a new raw cube texture from a specified url
  19020. * @param url defines the url where the data is located
  19021. * @param scene defines the current scene
  19022. * @param size defines the size of the textures
  19023. * @param format defines the format of the data
  19024. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  19025. * @param noMipmap defines if the engine should avoid generating the mip levels
  19026. * @param callback defines a callback used to extract texture data from loaded data
  19027. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  19028. * @param onLoad defines a callback called when texture is loaded
  19029. * @param onError defines a callback called if there is an error
  19030. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  19031. * @param invertY defines if data must be stored with Y axis inverted
  19032. * @returns the cube texture as an InternalTexture
  19033. */
  19034. 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;
  19035. /**
  19036. * Creates a new raw 3D texture
  19037. * @param data defines the data used to create the texture
  19038. * @param width defines the width of the texture
  19039. * @param height defines the height of the texture
  19040. * @param depth defines the depth of the texture
  19041. * @param format defines the format of the texture
  19042. * @param generateMipMaps defines if the engine must generate mip levels
  19043. * @param invertY defines if data must be stored with Y axis inverted
  19044. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  19045. * @param compression defines the compressed used (can be null)
  19046. * @param textureType defines the compressed used (can be null)
  19047. * @returns a new raw 3D texture (stored in an InternalTexture)
  19048. */
  19049. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  19050. /**
  19051. * Update a raw 3D texture
  19052. * @param texture defines the texture to update
  19053. * @param data defines the data to store
  19054. * @param format defines the data format
  19055. * @param invertY defines if data must be stored with Y axis inverted
  19056. */
  19057. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  19058. /**
  19059. * Update a raw 3D texture
  19060. * @param texture defines the texture to update
  19061. * @param data defines the data to store
  19062. * @param format defines the data format
  19063. * @param invertY defines if data must be stored with Y axis inverted
  19064. * @param compression defines the used compression (can be null)
  19065. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  19066. */
  19067. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  19068. }
  19069. }
  19070. }
  19071. declare module "babylonjs/Materials/Textures/rawTexture" {
  19072. import { Scene } from "babylonjs/scene";
  19073. import { Texture } from "babylonjs/Materials/Textures/texture";
  19074. import "babylonjs/Engines/Extensions/engine.rawTexture";
  19075. /**
  19076. * Raw texture can help creating a texture directly from an array of data.
  19077. * This can be super useful if you either get the data from an uncompressed source or
  19078. * if you wish to create your texture pixel by pixel.
  19079. */
  19080. export class RawTexture extends Texture {
  19081. /**
  19082. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  19083. */
  19084. format: number;
  19085. private _engine;
  19086. /**
  19087. * Instantiates a new RawTexture.
  19088. * Raw texture can help creating a texture directly from an array of data.
  19089. * This can be super useful if you either get the data from an uncompressed source or
  19090. * if you wish to create your texture pixel by pixel.
  19091. * @param data define the array of data to use to create the texture
  19092. * @param width define the width of the texture
  19093. * @param height define the height of the texture
  19094. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  19095. * @param scene define the scene the texture belongs to
  19096. * @param generateMipMaps define whether mip maps should be generated or not
  19097. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19098. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19099. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  19100. */
  19101. constructor(data: ArrayBufferView, width: number, height: number,
  19102. /**
  19103. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  19104. */
  19105. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  19106. /**
  19107. * Updates the texture underlying data.
  19108. * @param data Define the new data of the texture
  19109. */
  19110. update(data: ArrayBufferView): void;
  19111. /**
  19112. * Creates a luminance texture from some data.
  19113. * @param data Define the texture data
  19114. * @param width Define the width of the texture
  19115. * @param height Define the height of the texture
  19116. * @param scene Define the scene the texture belongs to
  19117. * @param generateMipMaps Define whether or not to create mip maps for the texture
  19118. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19119. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19120. * @returns the luminance texture
  19121. */
  19122. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  19123. /**
  19124. * Creates a luminance alpha texture from some data.
  19125. * @param data Define the texture data
  19126. * @param width Define the width of the texture
  19127. * @param height Define the height of the texture
  19128. * @param scene Define the scene the texture belongs to
  19129. * @param generateMipMaps Define whether or not to create mip maps for the texture
  19130. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19131. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19132. * @returns the luminance alpha texture
  19133. */
  19134. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  19135. /**
  19136. * Creates an alpha texture from some data.
  19137. * @param data Define the texture data
  19138. * @param width Define the width of the texture
  19139. * @param height Define the height of the texture
  19140. * @param scene Define the scene the texture belongs to
  19141. * @param generateMipMaps Define whether or not to create mip maps for the texture
  19142. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19143. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19144. * @returns the alpha texture
  19145. */
  19146. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  19147. /**
  19148. * Creates a RGB texture from some data.
  19149. * @param data Define the texture data
  19150. * @param width Define the width of the texture
  19151. * @param height Define the height of the texture
  19152. * @param scene Define the scene the texture belongs to
  19153. * @param generateMipMaps Define whether or not to create mip maps for the texture
  19154. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19155. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19156. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  19157. * @returns the RGB alpha texture
  19158. */
  19159. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  19160. /**
  19161. * Creates a RGBA texture from some data.
  19162. * @param data Define the texture data
  19163. * @param width Define the width of the texture
  19164. * @param height Define the height of the texture
  19165. * @param scene Define the scene the texture belongs to
  19166. * @param generateMipMaps Define whether or not to create mip maps for the texture
  19167. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19168. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19169. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  19170. * @returns the RGBA texture
  19171. */
  19172. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  19173. /**
  19174. * Creates a R texture from some data.
  19175. * @param data Define the texture data
  19176. * @param width Define the width of the texture
  19177. * @param height Define the height of the texture
  19178. * @param scene Define the scene the texture belongs to
  19179. * @param generateMipMaps Define whether or not to create mip maps for the texture
  19180. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19181. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19182. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  19183. * @returns the R texture
  19184. */
  19185. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  19186. }
  19187. }
  19188. declare module "babylonjs/Animations/runtimeAnimation" {
  19189. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  19190. import { Animatable } from "babylonjs/Animations/animatable";
  19191. import { Scene } from "babylonjs/scene";
  19192. /**
  19193. * Defines a runtime animation
  19194. */
  19195. export class RuntimeAnimation {
  19196. private _events;
  19197. /**
  19198. * The current frame of the runtime animation
  19199. */
  19200. private _currentFrame;
  19201. /**
  19202. * The animation used by the runtime animation
  19203. */
  19204. private _animation;
  19205. /**
  19206. * The target of the runtime animation
  19207. */
  19208. private _target;
  19209. /**
  19210. * The initiating animatable
  19211. */
  19212. private _host;
  19213. /**
  19214. * The original value of the runtime animation
  19215. */
  19216. private _originalValue;
  19217. /**
  19218. * The original blend value of the runtime animation
  19219. */
  19220. private _originalBlendValue;
  19221. /**
  19222. * The offsets cache of the runtime animation
  19223. */
  19224. private _offsetsCache;
  19225. /**
  19226. * The high limits cache of the runtime animation
  19227. */
  19228. private _highLimitsCache;
  19229. /**
  19230. * Specifies if the runtime animation has been stopped
  19231. */
  19232. private _stopped;
  19233. /**
  19234. * The blending factor of the runtime animation
  19235. */
  19236. private _blendingFactor;
  19237. /**
  19238. * The BabylonJS scene
  19239. */
  19240. private _scene;
  19241. /**
  19242. * The current value of the runtime animation
  19243. */
  19244. private _currentValue;
  19245. /** @hidden */
  19246. _animationState: _IAnimationState;
  19247. /**
  19248. * The active target of the runtime animation
  19249. */
  19250. private _activeTargets;
  19251. private _currentActiveTarget;
  19252. private _directTarget;
  19253. /**
  19254. * The target path of the runtime animation
  19255. */
  19256. private _targetPath;
  19257. /**
  19258. * The weight of the runtime animation
  19259. */
  19260. private _weight;
  19261. /**
  19262. * The ratio offset of the runtime animation
  19263. */
  19264. private _ratioOffset;
  19265. /**
  19266. * The previous delay of the runtime animation
  19267. */
  19268. private _previousDelay;
  19269. /**
  19270. * The previous ratio of the runtime animation
  19271. */
  19272. private _previousRatio;
  19273. private _enableBlending;
  19274. private _keys;
  19275. private _minFrame;
  19276. private _maxFrame;
  19277. private _minValue;
  19278. private _maxValue;
  19279. private _targetIsArray;
  19280. /**
  19281. * Gets the current frame of the runtime animation
  19282. */
  19283. readonly currentFrame: number;
  19284. /**
  19285. * Gets the weight of the runtime animation
  19286. */
  19287. readonly weight: number;
  19288. /**
  19289. * Gets the current value of the runtime animation
  19290. */
  19291. readonly currentValue: any;
  19292. /**
  19293. * Gets the target path of the runtime animation
  19294. */
  19295. readonly targetPath: string;
  19296. /**
  19297. * Gets the actual target of the runtime animation
  19298. */
  19299. readonly target: any;
  19300. /** @hidden */
  19301. _onLoop: () => void;
  19302. /**
  19303. * Create a new RuntimeAnimation object
  19304. * @param target defines the target of the animation
  19305. * @param animation defines the source animation object
  19306. * @param scene defines the hosting scene
  19307. * @param host defines the initiating Animatable
  19308. */
  19309. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  19310. private _preparePath;
  19311. /**
  19312. * Gets the animation from the runtime animation
  19313. */
  19314. readonly animation: Animation;
  19315. /**
  19316. * Resets the runtime animation to the beginning
  19317. * @param restoreOriginal defines whether to restore the target property to the original value
  19318. */
  19319. reset(restoreOriginal?: boolean): void;
  19320. /**
  19321. * Specifies if the runtime animation is stopped
  19322. * @returns Boolean specifying if the runtime animation is stopped
  19323. */
  19324. isStopped(): boolean;
  19325. /**
  19326. * Disposes of the runtime animation
  19327. */
  19328. dispose(): void;
  19329. /**
  19330. * Apply the interpolated value to the target
  19331. * @param currentValue defines the value computed by the animation
  19332. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  19333. */
  19334. setValue(currentValue: any, weight: number): void;
  19335. private _getOriginalValues;
  19336. private _setValue;
  19337. /**
  19338. * Gets the loop pmode of the runtime animation
  19339. * @returns Loop Mode
  19340. */
  19341. private _getCorrectLoopMode;
  19342. /**
  19343. * Move the current animation to a given frame
  19344. * @param frame defines the frame to move to
  19345. */
  19346. goToFrame(frame: number): void;
  19347. /**
  19348. * @hidden Internal use only
  19349. */
  19350. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  19351. /**
  19352. * Execute the current animation
  19353. * @param delay defines the delay to add to the current frame
  19354. * @param from defines the lower bound of the animation range
  19355. * @param to defines the upper bound of the animation range
  19356. * @param loop defines if the current animation must loop
  19357. * @param speedRatio defines the current speed ratio
  19358. * @param weight defines the weight of the animation (default is -1 so no weight)
  19359. * @param onLoop optional callback called when animation loops
  19360. * @returns a boolean indicating if the animation is running
  19361. */
  19362. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  19363. }
  19364. }
  19365. declare module "babylonjs/Animations/animatable" {
  19366. import { Animation } from "babylonjs/Animations/animation";
  19367. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  19368. import { Nullable } from "babylonjs/types";
  19369. import { Observable } from "babylonjs/Misc/observable";
  19370. import { Scene } from "babylonjs/scene";
  19371. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math";
  19372. import { Node } from "babylonjs/node";
  19373. /**
  19374. * Class used to store an actual running animation
  19375. */
  19376. export class Animatable {
  19377. /** defines the target object */
  19378. target: any;
  19379. /** defines the starting frame number (default is 0) */
  19380. fromFrame: number;
  19381. /** defines the ending frame number (default is 100) */
  19382. toFrame: number;
  19383. /** defines if the animation must loop (default is false) */
  19384. loopAnimation: boolean;
  19385. /** defines a callback to call when animation ends if it is not looping */
  19386. onAnimationEnd?: (() => void) | null | undefined;
  19387. /** defines a callback to call when animation loops */
  19388. onAnimationLoop?: (() => void) | null | undefined;
  19389. private _localDelayOffset;
  19390. private _pausedDelay;
  19391. private _runtimeAnimations;
  19392. private _paused;
  19393. private _scene;
  19394. private _speedRatio;
  19395. private _weight;
  19396. private _syncRoot;
  19397. /**
  19398. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  19399. * This will only apply for non looping animation (default is true)
  19400. */
  19401. disposeOnEnd: boolean;
  19402. /**
  19403. * Gets a boolean indicating if the animation has started
  19404. */
  19405. animationStarted: boolean;
  19406. /**
  19407. * Observer raised when the animation ends
  19408. */
  19409. onAnimationEndObservable: Observable<Animatable>;
  19410. /**
  19411. * Observer raised when the animation loops
  19412. */
  19413. onAnimationLoopObservable: Observable<Animatable>;
  19414. /**
  19415. * Gets the root Animatable used to synchronize and normalize animations
  19416. */
  19417. readonly syncRoot: Nullable<Animatable>;
  19418. /**
  19419. * Gets the current frame of the first RuntimeAnimation
  19420. * Used to synchronize Animatables
  19421. */
  19422. readonly masterFrame: number;
  19423. /**
  19424. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  19425. */
  19426. weight: number;
  19427. /**
  19428. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  19429. */
  19430. speedRatio: number;
  19431. /**
  19432. * Creates a new Animatable
  19433. * @param scene defines the hosting scene
  19434. * @param target defines the target object
  19435. * @param fromFrame defines the starting frame number (default is 0)
  19436. * @param toFrame defines the ending frame number (default is 100)
  19437. * @param loopAnimation defines if the animation must loop (default is false)
  19438. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  19439. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  19440. * @param animations defines a group of animation to add to the new Animatable
  19441. * @param onAnimationLoop defines a callback to call when animation loops
  19442. */
  19443. constructor(scene: Scene,
  19444. /** defines the target object */
  19445. target: any,
  19446. /** defines the starting frame number (default is 0) */
  19447. fromFrame?: number,
  19448. /** defines the ending frame number (default is 100) */
  19449. toFrame?: number,
  19450. /** defines if the animation must loop (default is false) */
  19451. loopAnimation?: boolean, speedRatio?: number,
  19452. /** defines a callback to call when animation ends if it is not looping */
  19453. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  19454. /** defines a callback to call when animation loops */
  19455. onAnimationLoop?: (() => void) | null | undefined);
  19456. /**
  19457. * Synchronize and normalize current Animatable with a source Animatable
  19458. * This is useful when using animation weights and when animations are not of the same length
  19459. * @param root defines the root Animatable to synchronize with
  19460. * @returns the current Animatable
  19461. */
  19462. syncWith(root: Animatable): Animatable;
  19463. /**
  19464. * Gets the list of runtime animations
  19465. * @returns an array of RuntimeAnimation
  19466. */
  19467. getAnimations(): RuntimeAnimation[];
  19468. /**
  19469. * Adds more animations to the current animatable
  19470. * @param target defines the target of the animations
  19471. * @param animations defines the new animations to add
  19472. */
  19473. appendAnimations(target: any, animations: Animation[]): void;
  19474. /**
  19475. * Gets the source animation for a specific property
  19476. * @param property defines the propertyu to look for
  19477. * @returns null or the source animation for the given property
  19478. */
  19479. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  19480. /**
  19481. * Gets the runtime animation for a specific property
  19482. * @param property defines the propertyu to look for
  19483. * @returns null or the runtime animation for the given property
  19484. */
  19485. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  19486. /**
  19487. * Resets the animatable to its original state
  19488. */
  19489. reset(): void;
  19490. /**
  19491. * Allows the animatable to blend with current running animations
  19492. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19493. * @param blendingSpeed defines the blending speed to use
  19494. */
  19495. enableBlending(blendingSpeed: number): void;
  19496. /**
  19497. * Disable animation blending
  19498. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19499. */
  19500. disableBlending(): void;
  19501. /**
  19502. * Jump directly to a given frame
  19503. * @param frame defines the frame to jump to
  19504. */
  19505. goToFrame(frame: number): void;
  19506. /**
  19507. * Pause the animation
  19508. */
  19509. pause(): void;
  19510. /**
  19511. * Restart the animation
  19512. */
  19513. restart(): void;
  19514. private _raiseOnAnimationEnd;
  19515. /**
  19516. * Stop and delete the current animation
  19517. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  19518. * @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)
  19519. */
  19520. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  19521. /**
  19522. * Wait asynchronously for the animation to end
  19523. * @returns a promise which will be fullfilled when the animation ends
  19524. */
  19525. waitAsync(): Promise<Animatable>;
  19526. /** @hidden */
  19527. _animate(delay: number): boolean;
  19528. }
  19529. module "babylonjs/scene" {
  19530. interface Scene {
  19531. /** @hidden */
  19532. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  19533. /** @hidden */
  19534. _processLateAnimationBindingsForMatrices(holder: {
  19535. totalWeight: number;
  19536. animations: RuntimeAnimation[];
  19537. originalValue: Matrix;
  19538. }): any;
  19539. /** @hidden */
  19540. _processLateAnimationBindingsForQuaternions(holder: {
  19541. totalWeight: number;
  19542. animations: RuntimeAnimation[];
  19543. originalValue: Quaternion;
  19544. }, refQuaternion: Quaternion): Quaternion;
  19545. /** @hidden */
  19546. _processLateAnimationBindings(): void;
  19547. /**
  19548. * Will start the animation sequence of a given target
  19549. * @param target defines the target
  19550. * @param from defines from which frame should animation start
  19551. * @param to defines until which frame should animation run.
  19552. * @param weight defines the weight to apply to the animation (1.0 by default)
  19553. * @param loop defines if the animation loops
  19554. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  19555. * @param onAnimationEnd defines the function to be executed when the animation ends
  19556. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  19557. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  19558. * @param onAnimationLoop defines the callback to call when an animation loops
  19559. * @returns the animatable object created for this animation
  19560. */
  19561. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  19562. /**
  19563. * Will start the animation sequence of a given target
  19564. * @param target defines the target
  19565. * @param from defines from which frame should animation start
  19566. * @param to defines until which frame should animation run.
  19567. * @param loop defines if the animation loops
  19568. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  19569. * @param onAnimationEnd defines the function to be executed when the animation ends
  19570. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  19571. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  19572. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  19573. * @param onAnimationLoop defines the callback to call when an animation loops
  19574. * @returns the animatable object created for this animation
  19575. */
  19576. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  19577. /**
  19578. * Will start the animation sequence of a given target and its hierarchy
  19579. * @param target defines the target
  19580. * @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.
  19581. * @param from defines from which frame should animation start
  19582. * @param to defines until which frame should animation run.
  19583. * @param loop defines if the animation loops
  19584. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  19585. * @param onAnimationEnd defines the function to be executed when the animation ends
  19586. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  19587. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  19588. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  19589. * @param onAnimationLoop defines the callback to call when an animation loops
  19590. * @returns the list of created animatables
  19591. */
  19592. 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[];
  19593. /**
  19594. * Begin a new animation on a given node
  19595. * @param target defines the target where the animation will take place
  19596. * @param animations defines the list of animations to start
  19597. * @param from defines the initial value
  19598. * @param to defines the final value
  19599. * @param loop defines if you want animation to loop (off by default)
  19600. * @param speedRatio defines the speed ratio to apply to all animations
  19601. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  19602. * @param onAnimationLoop defines the callback to call when an animation loops
  19603. * @returns the list of created animatables
  19604. */
  19605. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  19606. /**
  19607. * Begin a new animation on a given node and its hierarchy
  19608. * @param target defines the root node where the animation will take place
  19609. * @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.
  19610. * @param animations defines the list of animations to start
  19611. * @param from defines the initial value
  19612. * @param to defines the final value
  19613. * @param loop defines if you want animation to loop (off by default)
  19614. * @param speedRatio defines the speed ratio to apply to all animations
  19615. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  19616. * @param onAnimationLoop defines the callback to call when an animation loops
  19617. * @returns the list of animatables created for all nodes
  19618. */
  19619. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  19620. /**
  19621. * Gets the animatable associated with a specific target
  19622. * @param target defines the target of the animatable
  19623. * @returns the required animatable if found
  19624. */
  19625. getAnimatableByTarget(target: any): Nullable<Animatable>;
  19626. /**
  19627. * Gets all animatables associated with a given target
  19628. * @param target defines the target to look animatables for
  19629. * @returns an array of Animatables
  19630. */
  19631. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  19632. /**
  19633. * Stops and removes all animations that have been applied to the scene
  19634. */
  19635. stopAllAnimations(): void;
  19636. }
  19637. }
  19638. module "babylonjs/Bones/bone" {
  19639. interface Bone {
  19640. /**
  19641. * Copy an animation range from another bone
  19642. * @param source defines the source bone
  19643. * @param rangeName defines the range name to copy
  19644. * @param frameOffset defines the frame offset
  19645. * @param rescaleAsRequired defines if rescaling must be applied if required
  19646. * @param skelDimensionsRatio defines the scaling ratio
  19647. * @returns true if operation was successful
  19648. */
  19649. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  19650. }
  19651. }
  19652. }
  19653. declare module "babylonjs/Bones/skeleton" {
  19654. import { Bone } from "babylonjs/Bones/bone";
  19655. import { IAnimatable } from "babylonjs/Misc/tools";
  19656. import { Observable } from "babylonjs/Misc/observable";
  19657. import { Vector3, Matrix } from "babylonjs/Maths/math";
  19658. import { Scene } from "babylonjs/scene";
  19659. import { Nullable } from "babylonjs/types";
  19660. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19661. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  19662. import { Animatable } from "babylonjs/Animations/animatable";
  19663. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  19664. import { Animation } from "babylonjs/Animations/animation";
  19665. import { AnimationRange } from "babylonjs/Animations/animationRange";
  19666. import { IInspectable } from "babylonjs/Misc/iInspectable";
  19667. /**
  19668. * Class used to handle skinning animations
  19669. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  19670. */
  19671. export class Skeleton implements IAnimatable {
  19672. /** defines the skeleton name */
  19673. name: string;
  19674. /** defines the skeleton Id */
  19675. id: string;
  19676. /**
  19677. * Defines the list of child bones
  19678. */
  19679. bones: Bone[];
  19680. /**
  19681. * Defines an estimate of the dimension of the skeleton at rest
  19682. */
  19683. dimensionsAtRest: Vector3;
  19684. /**
  19685. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  19686. */
  19687. needInitialSkinMatrix: boolean;
  19688. /**
  19689. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  19690. */
  19691. overrideMesh: Nullable<AbstractMesh>;
  19692. /**
  19693. * Gets the list of animations attached to this skeleton
  19694. */
  19695. animations: Array<Animation>;
  19696. private _scene;
  19697. private _isDirty;
  19698. private _transformMatrices;
  19699. private _transformMatrixTexture;
  19700. private _meshesWithPoseMatrix;
  19701. private _animatables;
  19702. private _identity;
  19703. private _synchronizedWithMesh;
  19704. private _ranges;
  19705. private _lastAbsoluteTransformsUpdateId;
  19706. private _canUseTextureForBones;
  19707. private _uniqueId;
  19708. /** @hidden */
  19709. _numBonesWithLinkedTransformNode: number;
  19710. /** @hidden */
  19711. _hasWaitingData: Nullable<boolean>;
  19712. /**
  19713. * Specifies if the skeleton should be serialized
  19714. */
  19715. doNotSerialize: boolean;
  19716. private _useTextureToStoreBoneMatrices;
  19717. /**
  19718. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  19719. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  19720. */
  19721. useTextureToStoreBoneMatrices: boolean;
  19722. private _animationPropertiesOverride;
  19723. /**
  19724. * Gets or sets the animation properties override
  19725. */
  19726. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19727. /**
  19728. * List of inspectable custom properties (used by the Inspector)
  19729. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  19730. */
  19731. inspectableCustomProperties: IInspectable[];
  19732. /**
  19733. * An observable triggered before computing the skeleton's matrices
  19734. */
  19735. onBeforeComputeObservable: Observable<Skeleton>;
  19736. /**
  19737. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  19738. */
  19739. readonly isUsingTextureForMatrices: boolean;
  19740. /**
  19741. * Gets the unique ID of this skeleton
  19742. */
  19743. readonly uniqueId: number;
  19744. /**
  19745. * Creates a new skeleton
  19746. * @param name defines the skeleton name
  19747. * @param id defines the skeleton Id
  19748. * @param scene defines the hosting scene
  19749. */
  19750. constructor(
  19751. /** defines the skeleton name */
  19752. name: string,
  19753. /** defines the skeleton Id */
  19754. id: string, scene: Scene);
  19755. /**
  19756. * Gets the current object class name.
  19757. * @return the class name
  19758. */
  19759. getClassName(): string;
  19760. /**
  19761. * Returns an array containing the root bones
  19762. * @returns an array containing the root bones
  19763. */
  19764. getChildren(): Array<Bone>;
  19765. /**
  19766. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  19767. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  19768. * @returns a Float32Array containing matrices data
  19769. */
  19770. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  19771. /**
  19772. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  19773. * @returns a raw texture containing the data
  19774. */
  19775. getTransformMatrixTexture(): Nullable<RawTexture>;
  19776. /**
  19777. * Gets the current hosting scene
  19778. * @returns a scene object
  19779. */
  19780. getScene(): Scene;
  19781. /**
  19782. * Gets a string representing the current skeleton data
  19783. * @param fullDetails defines a boolean indicating if we want a verbose version
  19784. * @returns a string representing the current skeleton data
  19785. */
  19786. toString(fullDetails?: boolean): string;
  19787. /**
  19788. * Get bone's index searching by name
  19789. * @param name defines bone's name to search for
  19790. * @return the indice of the bone. Returns -1 if not found
  19791. */
  19792. getBoneIndexByName(name: string): number;
  19793. /**
  19794. * Creater a new animation range
  19795. * @param name defines the name of the range
  19796. * @param from defines the start key
  19797. * @param to defines the end key
  19798. */
  19799. createAnimationRange(name: string, from: number, to: number): void;
  19800. /**
  19801. * Delete a specific animation range
  19802. * @param name defines the name of the range
  19803. * @param deleteFrames defines if frames must be removed as well
  19804. */
  19805. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  19806. /**
  19807. * Gets a specific animation range
  19808. * @param name defines the name of the range to look for
  19809. * @returns the requested animation range or null if not found
  19810. */
  19811. getAnimationRange(name: string): Nullable<AnimationRange>;
  19812. /**
  19813. * Gets the list of all animation ranges defined on this skeleton
  19814. * @returns an array
  19815. */
  19816. getAnimationRanges(): Nullable<AnimationRange>[];
  19817. /**
  19818. * Copy animation range from a source skeleton.
  19819. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  19820. * @param source defines the source skeleton
  19821. * @param name defines the name of the range to copy
  19822. * @param rescaleAsRequired defines if rescaling must be applied if required
  19823. * @returns true if operation was successful
  19824. */
  19825. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  19826. /**
  19827. * Forces the skeleton to go to rest pose
  19828. */
  19829. returnToRest(): void;
  19830. private _getHighestAnimationFrame;
  19831. /**
  19832. * Begin a specific animation range
  19833. * @param name defines the name of the range to start
  19834. * @param loop defines if looping must be turned on (false by default)
  19835. * @param speedRatio defines the speed ratio to apply (1 by default)
  19836. * @param onAnimationEnd defines a callback which will be called when animation will end
  19837. * @returns a new animatable
  19838. */
  19839. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  19840. /** @hidden */
  19841. _markAsDirty(): void;
  19842. /** @hidden */
  19843. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19844. /** @hidden */
  19845. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19846. private _computeTransformMatrices;
  19847. /**
  19848. * Build all resources required to render a skeleton
  19849. */
  19850. prepare(): void;
  19851. /**
  19852. * Gets the list of animatables currently running for this skeleton
  19853. * @returns an array of animatables
  19854. */
  19855. getAnimatables(): IAnimatable[];
  19856. /**
  19857. * Clone the current skeleton
  19858. * @param name defines the name of the new skeleton
  19859. * @param id defines the id of the new skeleton
  19860. * @returns the new skeleton
  19861. */
  19862. clone(name: string, id: string): Skeleton;
  19863. /**
  19864. * Enable animation blending for this skeleton
  19865. * @param blendingSpeed defines the blending speed to apply
  19866. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19867. */
  19868. enableBlending(blendingSpeed?: number): void;
  19869. /**
  19870. * Releases all resources associated with the current skeleton
  19871. */
  19872. dispose(): void;
  19873. /**
  19874. * Serialize the skeleton in a JSON object
  19875. * @returns a JSON object
  19876. */
  19877. serialize(): any;
  19878. /**
  19879. * Creates a new skeleton from serialized data
  19880. * @param parsedSkeleton defines the serialized data
  19881. * @param scene defines the hosting scene
  19882. * @returns a new skeleton
  19883. */
  19884. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  19885. /**
  19886. * Compute all node absolute transforms
  19887. * @param forceUpdate defines if computation must be done even if cache is up to date
  19888. */
  19889. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  19890. /**
  19891. * Gets the root pose matrix
  19892. * @returns a matrix
  19893. */
  19894. getPoseMatrix(): Nullable<Matrix>;
  19895. /**
  19896. * Sorts bones per internal index
  19897. */
  19898. sortBones(): void;
  19899. private _sortBones;
  19900. }
  19901. }
  19902. declare module "babylonjs/Morph/morphTarget" {
  19903. import { IAnimatable } from "babylonjs/Misc/tools";
  19904. import { Observable } from "babylonjs/Misc/observable";
  19905. import { Nullable, FloatArray } from "babylonjs/types";
  19906. import { Scene } from "babylonjs/scene";
  19907. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19908. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  19909. /**
  19910. * Defines a target to use with MorphTargetManager
  19911. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19912. */
  19913. export class MorphTarget implements IAnimatable {
  19914. /** defines the name of the target */
  19915. name: string;
  19916. /**
  19917. * Gets or sets the list of animations
  19918. */
  19919. animations: import("babylonjs/Animations/animation").Animation[];
  19920. private _scene;
  19921. private _positions;
  19922. private _normals;
  19923. private _tangents;
  19924. private _influence;
  19925. /**
  19926. * Observable raised when the influence changes
  19927. */
  19928. onInfluenceChanged: Observable<boolean>;
  19929. /** @hidden */
  19930. _onDataLayoutChanged: Observable<void>;
  19931. /**
  19932. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  19933. */
  19934. influence: number;
  19935. /**
  19936. * Gets or sets the id of the morph Target
  19937. */
  19938. id: string;
  19939. private _animationPropertiesOverride;
  19940. /**
  19941. * Gets or sets the animation properties override
  19942. */
  19943. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19944. /**
  19945. * Creates a new MorphTarget
  19946. * @param name defines the name of the target
  19947. * @param influence defines the influence to use
  19948. * @param scene defines the scene the morphtarget belongs to
  19949. */
  19950. constructor(
  19951. /** defines the name of the target */
  19952. name: string, influence?: number, scene?: Nullable<Scene>);
  19953. /**
  19954. * Gets a boolean defining if the target contains position data
  19955. */
  19956. readonly hasPositions: boolean;
  19957. /**
  19958. * Gets a boolean defining if the target contains normal data
  19959. */
  19960. readonly hasNormals: boolean;
  19961. /**
  19962. * Gets a boolean defining if the target contains tangent data
  19963. */
  19964. readonly hasTangents: boolean;
  19965. /**
  19966. * Affects position data to this target
  19967. * @param data defines the position data to use
  19968. */
  19969. setPositions(data: Nullable<FloatArray>): void;
  19970. /**
  19971. * Gets the position data stored in this target
  19972. * @returns a FloatArray containing the position data (or null if not present)
  19973. */
  19974. getPositions(): Nullable<FloatArray>;
  19975. /**
  19976. * Affects normal data to this target
  19977. * @param data defines the normal data to use
  19978. */
  19979. setNormals(data: Nullable<FloatArray>): void;
  19980. /**
  19981. * Gets the normal data stored in this target
  19982. * @returns a FloatArray containing the normal data (or null if not present)
  19983. */
  19984. getNormals(): Nullable<FloatArray>;
  19985. /**
  19986. * Affects tangent data to this target
  19987. * @param data defines the tangent data to use
  19988. */
  19989. setTangents(data: Nullable<FloatArray>): void;
  19990. /**
  19991. * Gets the tangent data stored in this target
  19992. * @returns a FloatArray containing the tangent data (or null if not present)
  19993. */
  19994. getTangents(): Nullable<FloatArray>;
  19995. /**
  19996. * Serializes the current target into a Serialization object
  19997. * @returns the serialized object
  19998. */
  19999. serialize(): any;
  20000. /**
  20001. * Returns the string "MorphTarget"
  20002. * @returns "MorphTarget"
  20003. */
  20004. getClassName(): string;
  20005. /**
  20006. * Creates a new target from serialized data
  20007. * @param serializationObject defines the serialized data to use
  20008. * @returns a new MorphTarget
  20009. */
  20010. static Parse(serializationObject: any): MorphTarget;
  20011. /**
  20012. * Creates a MorphTarget from mesh data
  20013. * @param mesh defines the source mesh
  20014. * @param name defines the name to use for the new target
  20015. * @param influence defines the influence to attach to the target
  20016. * @returns a new MorphTarget
  20017. */
  20018. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  20019. }
  20020. }
  20021. declare module "babylonjs/Morph/morphTargetManager" {
  20022. import { Nullable } from "babylonjs/types";
  20023. import { Scene } from "babylonjs/scene";
  20024. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  20025. /**
  20026. * This class is used to deform meshes using morphing between different targets
  20027. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  20028. */
  20029. export class MorphTargetManager {
  20030. private _targets;
  20031. private _targetInfluenceChangedObservers;
  20032. private _targetDataLayoutChangedObservers;
  20033. private _activeTargets;
  20034. private _scene;
  20035. private _influences;
  20036. private _supportsNormals;
  20037. private _supportsTangents;
  20038. private _vertexCount;
  20039. private _uniqueId;
  20040. private _tempInfluences;
  20041. /**
  20042. * Creates a new MorphTargetManager
  20043. * @param scene defines the current scene
  20044. */
  20045. constructor(scene?: Nullable<Scene>);
  20046. /**
  20047. * Gets the unique ID of this manager
  20048. */
  20049. readonly uniqueId: number;
  20050. /**
  20051. * Gets the number of vertices handled by this manager
  20052. */
  20053. readonly vertexCount: number;
  20054. /**
  20055. * Gets a boolean indicating if this manager supports morphing of normals
  20056. */
  20057. readonly supportsNormals: boolean;
  20058. /**
  20059. * Gets a boolean indicating if this manager supports morphing of tangents
  20060. */
  20061. readonly supportsTangents: boolean;
  20062. /**
  20063. * Gets the number of targets stored in this manager
  20064. */
  20065. readonly numTargets: number;
  20066. /**
  20067. * Gets the number of influencers (ie. the number of targets with influences > 0)
  20068. */
  20069. readonly numInfluencers: number;
  20070. /**
  20071. * Gets the list of influences (one per target)
  20072. */
  20073. readonly influences: Float32Array;
  20074. /**
  20075. * Gets the active target at specified index. An active target is a target with an influence > 0
  20076. * @param index defines the index to check
  20077. * @returns the requested target
  20078. */
  20079. getActiveTarget(index: number): MorphTarget;
  20080. /**
  20081. * Gets the target at specified index
  20082. * @param index defines the index to check
  20083. * @returns the requested target
  20084. */
  20085. getTarget(index: number): MorphTarget;
  20086. /**
  20087. * Add a new target to this manager
  20088. * @param target defines the target to add
  20089. */
  20090. addTarget(target: MorphTarget): void;
  20091. /**
  20092. * Removes a target from the manager
  20093. * @param target defines the target to remove
  20094. */
  20095. removeTarget(target: MorphTarget): void;
  20096. /**
  20097. * Serializes the current manager into a Serialization object
  20098. * @returns the serialized object
  20099. */
  20100. serialize(): any;
  20101. private _syncActiveTargets;
  20102. /**
  20103. * Syncrhonize the targets with all the meshes using this morph target manager
  20104. */
  20105. synchronize(): void;
  20106. /**
  20107. * Creates a new MorphTargetManager from serialized data
  20108. * @param serializationObject defines the serialized data
  20109. * @param scene defines the hosting scene
  20110. * @returns the new MorphTargetManager
  20111. */
  20112. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  20113. }
  20114. }
  20115. declare module "babylonjs/Meshes/meshLODLevel" {
  20116. import { Mesh } from "babylonjs/Meshes/mesh";
  20117. import { Nullable } from "babylonjs/types";
  20118. /**
  20119. * Class used to represent a specific level of detail of a mesh
  20120. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  20121. */
  20122. export class MeshLODLevel {
  20123. /** Defines the distance where this level should star being displayed */
  20124. distance: number;
  20125. /** Defines the mesh to use to render this level */
  20126. mesh: Nullable<Mesh>;
  20127. /**
  20128. * Creates a new LOD level
  20129. * @param distance defines the distance where this level should star being displayed
  20130. * @param mesh defines the mesh to use to render this level
  20131. */
  20132. constructor(
  20133. /** Defines the distance where this level should star being displayed */
  20134. distance: number,
  20135. /** Defines the mesh to use to render this level */
  20136. mesh: Nullable<Mesh>);
  20137. }
  20138. }
  20139. declare module "babylonjs/Meshes/groundMesh" {
  20140. import { Scene } from "babylonjs/scene";
  20141. import { Vector3 } from "babylonjs/Maths/math";
  20142. import { Mesh } from "babylonjs/Meshes/mesh";
  20143. /**
  20144. * Mesh representing the gorund
  20145. */
  20146. export class GroundMesh extends Mesh {
  20147. /** If octree should be generated */
  20148. generateOctree: boolean;
  20149. private _heightQuads;
  20150. /** @hidden */
  20151. _subdivisionsX: number;
  20152. /** @hidden */
  20153. _subdivisionsY: number;
  20154. /** @hidden */
  20155. _width: number;
  20156. /** @hidden */
  20157. _height: number;
  20158. /** @hidden */
  20159. _minX: number;
  20160. /** @hidden */
  20161. _maxX: number;
  20162. /** @hidden */
  20163. _minZ: number;
  20164. /** @hidden */
  20165. _maxZ: number;
  20166. constructor(name: string, scene: Scene);
  20167. /**
  20168. * "GroundMesh"
  20169. * @returns "GroundMesh"
  20170. */
  20171. getClassName(): string;
  20172. /**
  20173. * The minimum of x and y subdivisions
  20174. */
  20175. readonly subdivisions: number;
  20176. /**
  20177. * X subdivisions
  20178. */
  20179. readonly subdivisionsX: number;
  20180. /**
  20181. * Y subdivisions
  20182. */
  20183. readonly subdivisionsY: number;
  20184. /**
  20185. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  20186. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  20187. * @param chunksCount the number of subdivisions for x and y
  20188. * @param octreeBlocksSize (Default: 32)
  20189. */
  20190. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  20191. /**
  20192. * Returns a height (y) value in the Worl system :
  20193. * the ground altitude at the coordinates (x, z) expressed in the World system.
  20194. * @param x x coordinate
  20195. * @param z z coordinate
  20196. * @returns the ground y position if (x, z) are outside the ground surface.
  20197. */
  20198. getHeightAtCoordinates(x: number, z: number): number;
  20199. /**
  20200. * Returns a normalized vector (Vector3) orthogonal to the ground
  20201. * at the ground coordinates (x, z) expressed in the World system.
  20202. * @param x x coordinate
  20203. * @param z z coordinate
  20204. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  20205. */
  20206. getNormalAtCoordinates(x: number, z: number): Vector3;
  20207. /**
  20208. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  20209. * at the ground coordinates (x, z) expressed in the World system.
  20210. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  20211. * @param x x coordinate
  20212. * @param z z coordinate
  20213. * @param ref vector to store the result
  20214. * @returns the GroundMesh.
  20215. */
  20216. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  20217. /**
  20218. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  20219. * if the ground has been updated.
  20220. * This can be used in the render loop.
  20221. * @returns the GroundMesh.
  20222. */
  20223. updateCoordinateHeights(): GroundMesh;
  20224. private _getFacetAt;
  20225. private _initHeightQuads;
  20226. private _computeHeightQuads;
  20227. /**
  20228. * Serializes this ground mesh
  20229. * @param serializationObject object to write serialization to
  20230. */
  20231. serialize(serializationObject: any): void;
  20232. /**
  20233. * Parses a serialized ground mesh
  20234. * @param parsedMesh the serialized mesh
  20235. * @param scene the scene to create the ground mesh in
  20236. * @returns the created ground mesh
  20237. */
  20238. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  20239. }
  20240. }
  20241. declare module "babylonjs/Physics/physicsJoint" {
  20242. import { Vector3 } from "babylonjs/Maths/math";
  20243. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  20244. /**
  20245. * Interface for Physics-Joint data
  20246. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20247. */
  20248. export interface PhysicsJointData {
  20249. /**
  20250. * The main pivot of the joint
  20251. */
  20252. mainPivot?: Vector3;
  20253. /**
  20254. * The connected pivot of the joint
  20255. */
  20256. connectedPivot?: Vector3;
  20257. /**
  20258. * The main axis of the joint
  20259. */
  20260. mainAxis?: Vector3;
  20261. /**
  20262. * The connected axis of the joint
  20263. */
  20264. connectedAxis?: Vector3;
  20265. /**
  20266. * The collision of the joint
  20267. */
  20268. collision?: boolean;
  20269. /**
  20270. * Native Oimo/Cannon/Energy data
  20271. */
  20272. nativeParams?: any;
  20273. }
  20274. /**
  20275. * This is a holder class for the physics joint created by the physics plugin
  20276. * It holds a set of functions to control the underlying joint
  20277. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20278. */
  20279. export class PhysicsJoint {
  20280. /**
  20281. * The type of the physics joint
  20282. */
  20283. type: number;
  20284. /**
  20285. * The data for the physics joint
  20286. */
  20287. jointData: PhysicsJointData;
  20288. private _physicsJoint;
  20289. protected _physicsPlugin: IPhysicsEnginePlugin;
  20290. /**
  20291. * Initializes the physics joint
  20292. * @param type The type of the physics joint
  20293. * @param jointData The data for the physics joint
  20294. */
  20295. constructor(
  20296. /**
  20297. * The type of the physics joint
  20298. */
  20299. type: number,
  20300. /**
  20301. * The data for the physics joint
  20302. */
  20303. jointData: PhysicsJointData);
  20304. /**
  20305. * Gets the physics joint
  20306. */
  20307. /**
  20308. * Sets the physics joint
  20309. */
  20310. physicsJoint: any;
  20311. /**
  20312. * Sets the physics plugin
  20313. */
  20314. physicsPlugin: IPhysicsEnginePlugin;
  20315. /**
  20316. * Execute a function that is physics-plugin specific.
  20317. * @param {Function} func the function that will be executed.
  20318. * It accepts two parameters: the physics world and the physics joint
  20319. */
  20320. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  20321. /**
  20322. * Distance-Joint type
  20323. */
  20324. static DistanceJoint: number;
  20325. /**
  20326. * Hinge-Joint type
  20327. */
  20328. static HingeJoint: number;
  20329. /**
  20330. * Ball-and-Socket joint type
  20331. */
  20332. static BallAndSocketJoint: number;
  20333. /**
  20334. * Wheel-Joint type
  20335. */
  20336. static WheelJoint: number;
  20337. /**
  20338. * Slider-Joint type
  20339. */
  20340. static SliderJoint: number;
  20341. /**
  20342. * Prismatic-Joint type
  20343. */
  20344. static PrismaticJoint: number;
  20345. /**
  20346. * Universal-Joint type
  20347. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  20348. */
  20349. static UniversalJoint: number;
  20350. /**
  20351. * Hinge-Joint 2 type
  20352. */
  20353. static Hinge2Joint: number;
  20354. /**
  20355. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  20356. */
  20357. static PointToPointJoint: number;
  20358. /**
  20359. * Spring-Joint type
  20360. */
  20361. static SpringJoint: number;
  20362. /**
  20363. * Lock-Joint type
  20364. */
  20365. static LockJoint: number;
  20366. }
  20367. /**
  20368. * A class representing a physics distance joint
  20369. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20370. */
  20371. export class DistanceJoint extends PhysicsJoint {
  20372. /**
  20373. *
  20374. * @param jointData The data for the Distance-Joint
  20375. */
  20376. constructor(jointData: DistanceJointData);
  20377. /**
  20378. * Update the predefined distance.
  20379. * @param maxDistance The maximum preferred distance
  20380. * @param minDistance The minimum preferred distance
  20381. */
  20382. updateDistance(maxDistance: number, minDistance?: number): void;
  20383. }
  20384. /**
  20385. * Represents a Motor-Enabled Joint
  20386. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20387. */
  20388. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  20389. /**
  20390. * Initializes the Motor-Enabled Joint
  20391. * @param type The type of the joint
  20392. * @param jointData The physica joint data for the joint
  20393. */
  20394. constructor(type: number, jointData: PhysicsJointData);
  20395. /**
  20396. * Set the motor values.
  20397. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20398. * @param force the force to apply
  20399. * @param maxForce max force for this motor.
  20400. */
  20401. setMotor(force?: number, maxForce?: number): void;
  20402. /**
  20403. * Set the motor's limits.
  20404. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20405. * @param upperLimit The upper limit of the motor
  20406. * @param lowerLimit The lower limit of the motor
  20407. */
  20408. setLimit(upperLimit: number, lowerLimit?: number): void;
  20409. }
  20410. /**
  20411. * This class represents a single physics Hinge-Joint
  20412. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20413. */
  20414. export class HingeJoint extends MotorEnabledJoint {
  20415. /**
  20416. * Initializes the Hinge-Joint
  20417. * @param jointData The joint data for the Hinge-Joint
  20418. */
  20419. constructor(jointData: PhysicsJointData);
  20420. /**
  20421. * Set the motor values.
  20422. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20423. * @param {number} force the force to apply
  20424. * @param {number} maxForce max force for this motor.
  20425. */
  20426. setMotor(force?: number, maxForce?: number): void;
  20427. /**
  20428. * Set the motor's limits.
  20429. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20430. * @param upperLimit The upper limit of the motor
  20431. * @param lowerLimit The lower limit of the motor
  20432. */
  20433. setLimit(upperLimit: number, lowerLimit?: number): void;
  20434. }
  20435. /**
  20436. * This class represents a dual hinge physics joint (same as wheel joint)
  20437. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20438. */
  20439. export class Hinge2Joint extends MotorEnabledJoint {
  20440. /**
  20441. * Initializes the Hinge2-Joint
  20442. * @param jointData The joint data for the Hinge2-Joint
  20443. */
  20444. constructor(jointData: PhysicsJointData);
  20445. /**
  20446. * Set the motor values.
  20447. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20448. * @param {number} targetSpeed the speed the motor is to reach
  20449. * @param {number} maxForce max force for this motor.
  20450. * @param {motorIndex} the motor's index, 0 or 1.
  20451. */
  20452. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  20453. /**
  20454. * Set the motor limits.
  20455. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20456. * @param {number} upperLimit the upper limit
  20457. * @param {number} lowerLimit lower limit
  20458. * @param {motorIndex} the motor's index, 0 or 1.
  20459. */
  20460. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  20461. }
  20462. /**
  20463. * Interface for a motor enabled joint
  20464. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20465. */
  20466. export interface IMotorEnabledJoint {
  20467. /**
  20468. * Physics joint
  20469. */
  20470. physicsJoint: any;
  20471. /**
  20472. * Sets the motor of the motor-enabled joint
  20473. * @param force The force of the motor
  20474. * @param maxForce The maximum force of the motor
  20475. * @param motorIndex The index of the motor
  20476. */
  20477. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  20478. /**
  20479. * Sets the limit of the motor
  20480. * @param upperLimit The upper limit of the motor
  20481. * @param lowerLimit The lower limit of the motor
  20482. * @param motorIndex The index of the motor
  20483. */
  20484. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  20485. }
  20486. /**
  20487. * Joint data for a Distance-Joint
  20488. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20489. */
  20490. export interface DistanceJointData extends PhysicsJointData {
  20491. /**
  20492. * Max distance the 2 joint objects can be apart
  20493. */
  20494. maxDistance: number;
  20495. }
  20496. /**
  20497. * Joint data from a spring joint
  20498. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20499. */
  20500. export interface SpringJointData extends PhysicsJointData {
  20501. /**
  20502. * Length of the spring
  20503. */
  20504. length: number;
  20505. /**
  20506. * Stiffness of the spring
  20507. */
  20508. stiffness: number;
  20509. /**
  20510. * Damping of the spring
  20511. */
  20512. damping: number;
  20513. /** this callback will be called when applying the force to the impostors. */
  20514. forceApplicationCallback: () => void;
  20515. }
  20516. }
  20517. declare module "babylonjs/Physics/physicsRaycastResult" {
  20518. import { Vector3 } from "babylonjs/Maths/math";
  20519. /**
  20520. * Holds the data for the raycast result
  20521. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20522. */
  20523. export class PhysicsRaycastResult {
  20524. private _hasHit;
  20525. private _hitDistance;
  20526. private _hitNormalWorld;
  20527. private _hitPointWorld;
  20528. private _rayFromWorld;
  20529. private _rayToWorld;
  20530. /**
  20531. * Gets if there was a hit
  20532. */
  20533. readonly hasHit: boolean;
  20534. /**
  20535. * Gets the distance from the hit
  20536. */
  20537. readonly hitDistance: number;
  20538. /**
  20539. * Gets the hit normal/direction in the world
  20540. */
  20541. readonly hitNormalWorld: Vector3;
  20542. /**
  20543. * Gets the hit point in the world
  20544. */
  20545. readonly hitPointWorld: Vector3;
  20546. /**
  20547. * Gets the ray "start point" of the ray in the world
  20548. */
  20549. readonly rayFromWorld: Vector3;
  20550. /**
  20551. * Gets the ray "end point" of the ray in the world
  20552. */
  20553. readonly rayToWorld: Vector3;
  20554. /**
  20555. * Sets the hit data (normal & point in world space)
  20556. * @param hitNormalWorld defines the normal in world space
  20557. * @param hitPointWorld defines the point in world space
  20558. */
  20559. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  20560. /**
  20561. * Sets the distance from the start point to the hit point
  20562. * @param distance
  20563. */
  20564. setHitDistance(distance: number): void;
  20565. /**
  20566. * Calculates the distance manually
  20567. */
  20568. calculateHitDistance(): void;
  20569. /**
  20570. * Resets all the values to default
  20571. * @param from The from point on world space
  20572. * @param to The to point on world space
  20573. */
  20574. reset(from?: Vector3, to?: Vector3): void;
  20575. }
  20576. /**
  20577. * Interface for the size containing width and height
  20578. */
  20579. interface IXYZ {
  20580. /**
  20581. * X
  20582. */
  20583. x: number;
  20584. /**
  20585. * Y
  20586. */
  20587. y: number;
  20588. /**
  20589. * Z
  20590. */
  20591. z: number;
  20592. }
  20593. }
  20594. declare module "babylonjs/Physics/IPhysicsEngine" {
  20595. import { Nullable } from "babylonjs/types";
  20596. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  20597. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20598. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  20599. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  20600. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  20601. /**
  20602. * Interface used to describe a physics joint
  20603. */
  20604. export interface PhysicsImpostorJoint {
  20605. /** Defines the main impostor to which the joint is linked */
  20606. mainImpostor: PhysicsImpostor;
  20607. /** Defines the impostor that is connected to the main impostor using this joint */
  20608. connectedImpostor: PhysicsImpostor;
  20609. /** Defines the joint itself */
  20610. joint: PhysicsJoint;
  20611. }
  20612. /** @hidden */
  20613. export interface IPhysicsEnginePlugin {
  20614. world: any;
  20615. name: string;
  20616. setGravity(gravity: Vector3): void;
  20617. setTimeStep(timeStep: number): void;
  20618. getTimeStep(): number;
  20619. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  20620. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  20621. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  20622. generatePhysicsBody(impostor: PhysicsImpostor): void;
  20623. removePhysicsBody(impostor: PhysicsImpostor): void;
  20624. generateJoint(joint: PhysicsImpostorJoint): void;
  20625. removeJoint(joint: PhysicsImpostorJoint): void;
  20626. isSupported(): boolean;
  20627. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  20628. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  20629. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  20630. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  20631. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  20632. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  20633. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  20634. getBodyMass(impostor: PhysicsImpostor): number;
  20635. getBodyFriction(impostor: PhysicsImpostor): number;
  20636. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  20637. getBodyRestitution(impostor: PhysicsImpostor): number;
  20638. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  20639. getBodyPressure?(impostor: PhysicsImpostor): number;
  20640. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  20641. getBodyStiffness?(impostor: PhysicsImpostor): number;
  20642. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  20643. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  20644. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  20645. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  20646. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  20647. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  20648. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  20649. sleepBody(impostor: PhysicsImpostor): void;
  20650. wakeUpBody(impostor: PhysicsImpostor): void;
  20651. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  20652. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  20653. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  20654. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  20655. getRadius(impostor: PhysicsImpostor): number;
  20656. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  20657. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  20658. dispose(): void;
  20659. }
  20660. /**
  20661. * Interface used to define a physics engine
  20662. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  20663. */
  20664. export interface IPhysicsEngine {
  20665. /**
  20666. * Gets the gravity vector used by the simulation
  20667. */
  20668. gravity: Vector3;
  20669. /**
  20670. * Sets the gravity vector used by the simulation
  20671. * @param gravity defines the gravity vector to use
  20672. */
  20673. setGravity(gravity: Vector3): void;
  20674. /**
  20675. * Set the time step of the physics engine.
  20676. * Default is 1/60.
  20677. * To slow it down, enter 1/600 for example.
  20678. * To speed it up, 1/30
  20679. * @param newTimeStep the new timestep to apply to this world.
  20680. */
  20681. setTimeStep(newTimeStep: number): void;
  20682. /**
  20683. * Get the time step of the physics engine.
  20684. * @returns the current time step
  20685. */
  20686. getTimeStep(): number;
  20687. /**
  20688. * Release all resources
  20689. */
  20690. dispose(): void;
  20691. /**
  20692. * Gets the name of the current physics plugin
  20693. * @returns the name of the plugin
  20694. */
  20695. getPhysicsPluginName(): string;
  20696. /**
  20697. * Adding a new impostor for the impostor tracking.
  20698. * This will be done by the impostor itself.
  20699. * @param impostor the impostor to add
  20700. */
  20701. addImpostor(impostor: PhysicsImpostor): void;
  20702. /**
  20703. * Remove an impostor from the engine.
  20704. * This impostor and its mesh will not longer be updated by the physics engine.
  20705. * @param impostor the impostor to remove
  20706. */
  20707. removeImpostor(impostor: PhysicsImpostor): void;
  20708. /**
  20709. * Add a joint to the physics engine
  20710. * @param mainImpostor defines the main impostor to which the joint is added.
  20711. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  20712. * @param joint defines the joint that will connect both impostors.
  20713. */
  20714. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  20715. /**
  20716. * Removes a joint from the simulation
  20717. * @param mainImpostor defines the impostor used with the joint
  20718. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  20719. * @param joint defines the joint to remove
  20720. */
  20721. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  20722. /**
  20723. * Gets the current plugin used to run the simulation
  20724. * @returns current plugin
  20725. */
  20726. getPhysicsPlugin(): IPhysicsEnginePlugin;
  20727. /**
  20728. * Gets the list of physic impostors
  20729. * @returns an array of PhysicsImpostor
  20730. */
  20731. getImpostors(): Array<PhysicsImpostor>;
  20732. /**
  20733. * Gets the impostor for a physics enabled object
  20734. * @param object defines the object impersonated by the impostor
  20735. * @returns the PhysicsImpostor or null if not found
  20736. */
  20737. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  20738. /**
  20739. * Gets the impostor for a physics body object
  20740. * @param body defines physics body used by the impostor
  20741. * @returns the PhysicsImpostor or null if not found
  20742. */
  20743. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  20744. /**
  20745. * Does a raycast in the physics world
  20746. * @param from when should the ray start?
  20747. * @param to when should the ray end?
  20748. * @returns PhysicsRaycastResult
  20749. */
  20750. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  20751. /**
  20752. * Called by the scene. No need to call it.
  20753. * @param delta defines the timespam between frames
  20754. */
  20755. _step(delta: number): void;
  20756. }
  20757. }
  20758. declare module "babylonjs/Physics/physicsImpostor" {
  20759. import { Nullable, IndicesArray } from "babylonjs/types";
  20760. import { Vector3, Matrix, Quaternion, Space } from "babylonjs/Maths/math";
  20761. import { TransformNode } from "babylonjs/Meshes/transformNode";
  20762. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20763. import { Scene } from "babylonjs/scene";
  20764. import { Bone } from "babylonjs/Bones/bone";
  20765. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  20766. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  20767. /**
  20768. * The interface for the physics imposter parameters
  20769. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20770. */
  20771. export interface PhysicsImpostorParameters {
  20772. /**
  20773. * The mass of the physics imposter
  20774. */
  20775. mass: number;
  20776. /**
  20777. * The friction of the physics imposter
  20778. */
  20779. friction?: number;
  20780. /**
  20781. * The coefficient of restitution of the physics imposter
  20782. */
  20783. restitution?: number;
  20784. /**
  20785. * The native options of the physics imposter
  20786. */
  20787. nativeOptions?: any;
  20788. /**
  20789. * Specifies if the parent should be ignored
  20790. */
  20791. ignoreParent?: boolean;
  20792. /**
  20793. * Specifies if bi-directional transformations should be disabled
  20794. */
  20795. disableBidirectionalTransformation?: boolean;
  20796. /**
  20797. * The pressure inside the physics imposter, soft object only
  20798. */
  20799. pressure?: number;
  20800. /**
  20801. * The stiffness the physics imposter, soft object only
  20802. */
  20803. stiffness?: number;
  20804. /**
  20805. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  20806. */
  20807. velocityIterations?: number;
  20808. /**
  20809. * The number of iterations used in maintaining consistent vertex positions, soft object only
  20810. */
  20811. positionIterations?: number;
  20812. /**
  20813. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  20814. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  20815. * Add to fix multiple points
  20816. */
  20817. fixedPoints?: number;
  20818. /**
  20819. * The collision margin around a soft object
  20820. */
  20821. margin?: number;
  20822. /**
  20823. * The collision margin around a soft object
  20824. */
  20825. damping?: number;
  20826. /**
  20827. * The path for a rope based on an extrusion
  20828. */
  20829. path?: any;
  20830. /**
  20831. * The shape of an extrusion used for a rope based on an extrusion
  20832. */
  20833. shape?: any;
  20834. }
  20835. /**
  20836. * Interface for a physics-enabled object
  20837. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20838. */
  20839. export interface IPhysicsEnabledObject {
  20840. /**
  20841. * The position of the physics-enabled object
  20842. */
  20843. position: Vector3;
  20844. /**
  20845. * The rotation of the physics-enabled object
  20846. */
  20847. rotationQuaternion: Nullable<Quaternion>;
  20848. /**
  20849. * The scale of the physics-enabled object
  20850. */
  20851. scaling: Vector3;
  20852. /**
  20853. * The rotation of the physics-enabled object
  20854. */
  20855. rotation?: Vector3;
  20856. /**
  20857. * The parent of the physics-enabled object
  20858. */
  20859. parent?: any;
  20860. /**
  20861. * The bounding info of the physics-enabled object
  20862. * @returns The bounding info of the physics-enabled object
  20863. */
  20864. getBoundingInfo(): BoundingInfo;
  20865. /**
  20866. * Computes the world matrix
  20867. * @param force Specifies if the world matrix should be computed by force
  20868. * @returns A world matrix
  20869. */
  20870. computeWorldMatrix(force: boolean): Matrix;
  20871. /**
  20872. * Gets the world matrix
  20873. * @returns A world matrix
  20874. */
  20875. getWorldMatrix?(): Matrix;
  20876. /**
  20877. * Gets the child meshes
  20878. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  20879. * @returns An array of abstract meshes
  20880. */
  20881. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  20882. /**
  20883. * Gets the vertex data
  20884. * @param kind The type of vertex data
  20885. * @returns A nullable array of numbers, or a float32 array
  20886. */
  20887. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  20888. /**
  20889. * Gets the indices from the mesh
  20890. * @returns A nullable array of index arrays
  20891. */
  20892. getIndices?(): Nullable<IndicesArray>;
  20893. /**
  20894. * Gets the scene from the mesh
  20895. * @returns the indices array or null
  20896. */
  20897. getScene?(): Scene;
  20898. /**
  20899. * Gets the absolute position from the mesh
  20900. * @returns the absolute position
  20901. */
  20902. getAbsolutePosition(): Vector3;
  20903. /**
  20904. * Gets the absolute pivot point from the mesh
  20905. * @returns the absolute pivot point
  20906. */
  20907. getAbsolutePivotPoint(): Vector3;
  20908. /**
  20909. * Rotates the mesh
  20910. * @param axis The axis of rotation
  20911. * @param amount The amount of rotation
  20912. * @param space The space of the rotation
  20913. * @returns The rotation transform node
  20914. */
  20915. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  20916. /**
  20917. * Translates the mesh
  20918. * @param axis The axis of translation
  20919. * @param distance The distance of translation
  20920. * @param space The space of the translation
  20921. * @returns The transform node
  20922. */
  20923. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  20924. /**
  20925. * Sets the absolute position of the mesh
  20926. * @param absolutePosition The absolute position of the mesh
  20927. * @returns The transform node
  20928. */
  20929. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  20930. /**
  20931. * Gets the class name of the mesh
  20932. * @returns The class name
  20933. */
  20934. getClassName(): string;
  20935. }
  20936. /**
  20937. * Represents a physics imposter
  20938. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20939. */
  20940. export class PhysicsImpostor {
  20941. /**
  20942. * The physics-enabled object used as the physics imposter
  20943. */
  20944. object: IPhysicsEnabledObject;
  20945. /**
  20946. * The type of the physics imposter
  20947. */
  20948. type: number;
  20949. private _options;
  20950. private _scene?;
  20951. /**
  20952. * The default object size of the imposter
  20953. */
  20954. static DEFAULT_OBJECT_SIZE: Vector3;
  20955. /**
  20956. * The identity quaternion of the imposter
  20957. */
  20958. static IDENTITY_QUATERNION: Quaternion;
  20959. /** @hidden */
  20960. _pluginData: any;
  20961. private _physicsEngine;
  20962. private _physicsBody;
  20963. private _bodyUpdateRequired;
  20964. private _onBeforePhysicsStepCallbacks;
  20965. private _onAfterPhysicsStepCallbacks;
  20966. /** @hidden */
  20967. _onPhysicsCollideCallbacks: Array<{
  20968. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  20969. otherImpostors: Array<PhysicsImpostor>;
  20970. }>;
  20971. private _deltaPosition;
  20972. private _deltaRotation;
  20973. private _deltaRotationConjugated;
  20974. /** hidden */
  20975. _isFromLine: boolean;
  20976. private _parent;
  20977. private _isDisposed;
  20978. private static _tmpVecs;
  20979. private static _tmpQuat;
  20980. /**
  20981. * Specifies if the physics imposter is disposed
  20982. */
  20983. readonly isDisposed: boolean;
  20984. /**
  20985. * Gets the mass of the physics imposter
  20986. */
  20987. mass: number;
  20988. /**
  20989. * Gets the coefficient of friction
  20990. */
  20991. /**
  20992. * Sets the coefficient of friction
  20993. */
  20994. friction: number;
  20995. /**
  20996. * Gets the coefficient of restitution
  20997. */
  20998. /**
  20999. * Sets the coefficient of restitution
  21000. */
  21001. restitution: number;
  21002. /**
  21003. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  21004. */
  21005. /**
  21006. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  21007. */
  21008. pressure: number;
  21009. /**
  21010. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  21011. */
  21012. /**
  21013. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  21014. */
  21015. stiffness: number;
  21016. /**
  21017. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  21018. */
  21019. /**
  21020. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  21021. */
  21022. velocityIterations: number;
  21023. /**
  21024. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  21025. */
  21026. /**
  21027. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  21028. */
  21029. positionIterations: number;
  21030. /**
  21031. * The unique id of the physics imposter
  21032. * set by the physics engine when adding this impostor to the array
  21033. */
  21034. uniqueId: number;
  21035. /**
  21036. * @hidden
  21037. */
  21038. soft: boolean;
  21039. /**
  21040. * @hidden
  21041. */
  21042. segments: number;
  21043. private _joints;
  21044. /**
  21045. * Initializes the physics imposter
  21046. * @param object The physics-enabled object used as the physics imposter
  21047. * @param type The type of the physics imposter
  21048. * @param _options The options for the physics imposter
  21049. * @param _scene The Babylon scene
  21050. */
  21051. constructor(
  21052. /**
  21053. * The physics-enabled object used as the physics imposter
  21054. */
  21055. object: IPhysicsEnabledObject,
  21056. /**
  21057. * The type of the physics imposter
  21058. */
  21059. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  21060. /**
  21061. * This function will completly initialize this impostor.
  21062. * It will create a new body - but only if this mesh has no parent.
  21063. * If it has, this impostor will not be used other than to define the impostor
  21064. * of the child mesh.
  21065. * @hidden
  21066. */
  21067. _init(): void;
  21068. private _getPhysicsParent;
  21069. /**
  21070. * Should a new body be generated.
  21071. * @returns boolean specifying if body initialization is required
  21072. */
  21073. isBodyInitRequired(): boolean;
  21074. /**
  21075. * Sets the updated scaling
  21076. * @param updated Specifies if the scaling is updated
  21077. */
  21078. setScalingUpdated(): void;
  21079. /**
  21080. * Force a regeneration of this or the parent's impostor's body.
  21081. * Use under cautious - This will remove all joints already implemented.
  21082. */
  21083. forceUpdate(): void;
  21084. /**
  21085. * Gets the body that holds this impostor. Either its own, or its parent.
  21086. */
  21087. /**
  21088. * Set the physics body. Used mainly by the physics engine/plugin
  21089. */
  21090. physicsBody: any;
  21091. /**
  21092. * Get the parent of the physics imposter
  21093. * @returns Physics imposter or null
  21094. */
  21095. /**
  21096. * Sets the parent of the physics imposter
  21097. */
  21098. parent: Nullable<PhysicsImpostor>;
  21099. /**
  21100. * Resets the update flags
  21101. */
  21102. resetUpdateFlags(): void;
  21103. /**
  21104. * Gets the object extend size
  21105. * @returns the object extend size
  21106. */
  21107. getObjectExtendSize(): Vector3;
  21108. /**
  21109. * Gets the object center
  21110. * @returns The object center
  21111. */
  21112. getObjectCenter(): Vector3;
  21113. /**
  21114. * Get a specific parametes from the options parameter
  21115. * @param paramName The object parameter name
  21116. * @returns The object parameter
  21117. */
  21118. getParam(paramName: string): any;
  21119. /**
  21120. * Sets a specific parameter in the options given to the physics plugin
  21121. * @param paramName The parameter name
  21122. * @param value The value of the parameter
  21123. */
  21124. setParam(paramName: string, value: number): void;
  21125. /**
  21126. * Specifically change the body's mass option. Won't recreate the physics body object
  21127. * @param mass The mass of the physics imposter
  21128. */
  21129. setMass(mass: number): void;
  21130. /**
  21131. * Gets the linear velocity
  21132. * @returns linear velocity or null
  21133. */
  21134. getLinearVelocity(): Nullable<Vector3>;
  21135. /**
  21136. * Sets the linear velocity
  21137. * @param velocity linear velocity or null
  21138. */
  21139. setLinearVelocity(velocity: Nullable<Vector3>): void;
  21140. /**
  21141. * Gets the angular velocity
  21142. * @returns angular velocity or null
  21143. */
  21144. getAngularVelocity(): Nullable<Vector3>;
  21145. /**
  21146. * Sets the angular velocity
  21147. * @param velocity The velocity or null
  21148. */
  21149. setAngularVelocity(velocity: Nullable<Vector3>): void;
  21150. /**
  21151. * Execute a function with the physics plugin native code
  21152. * Provide a function the will have two variables - the world object and the physics body object
  21153. * @param func The function to execute with the physics plugin native code
  21154. */
  21155. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  21156. /**
  21157. * Register a function that will be executed before the physics world is stepping forward
  21158. * @param func The function to execute before the physics world is stepped forward
  21159. */
  21160. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  21161. /**
  21162. * Unregister a function that will be executed before the physics world is stepping forward
  21163. * @param func The function to execute before the physics world is stepped forward
  21164. */
  21165. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  21166. /**
  21167. * Register a function that will be executed after the physics step
  21168. * @param func The function to execute after physics step
  21169. */
  21170. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  21171. /**
  21172. * Unregisters a function that will be executed after the physics step
  21173. * @param func The function to execute after physics step
  21174. */
  21175. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  21176. /**
  21177. * register a function that will be executed when this impostor collides against a different body
  21178. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  21179. * @param func Callback that is executed on collision
  21180. */
  21181. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  21182. /**
  21183. * Unregisters the physics imposter on contact
  21184. * @param collideAgainst The physics object to collide against
  21185. * @param func Callback to execute on collision
  21186. */
  21187. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  21188. private _tmpQuat;
  21189. private _tmpQuat2;
  21190. /**
  21191. * Get the parent rotation
  21192. * @returns The parent rotation
  21193. */
  21194. getParentsRotation(): Quaternion;
  21195. /**
  21196. * this function is executed by the physics engine.
  21197. */
  21198. beforeStep: () => void;
  21199. /**
  21200. * this function is executed by the physics engine
  21201. */
  21202. afterStep: () => void;
  21203. /**
  21204. * Legacy collision detection event support
  21205. */
  21206. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  21207. /**
  21208. * event and body object due to cannon's event-based architecture.
  21209. */
  21210. onCollide: (e: {
  21211. body: any;
  21212. }) => void;
  21213. /**
  21214. * Apply a force
  21215. * @param force The force to apply
  21216. * @param contactPoint The contact point for the force
  21217. * @returns The physics imposter
  21218. */
  21219. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  21220. /**
  21221. * Apply an impulse
  21222. * @param force The impulse force
  21223. * @param contactPoint The contact point for the impulse force
  21224. * @returns The physics imposter
  21225. */
  21226. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  21227. /**
  21228. * A help function to create a joint
  21229. * @param otherImpostor A physics imposter used to create a joint
  21230. * @param jointType The type of joint
  21231. * @param jointData The data for the joint
  21232. * @returns The physics imposter
  21233. */
  21234. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  21235. /**
  21236. * Add a joint to this impostor with a different impostor
  21237. * @param otherImpostor A physics imposter used to add a joint
  21238. * @param joint The joint to add
  21239. * @returns The physics imposter
  21240. */
  21241. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  21242. /**
  21243. * Add an anchor to a cloth impostor
  21244. * @param otherImpostor rigid impostor to anchor to
  21245. * @param width ratio across width from 0 to 1
  21246. * @param height ratio up height from 0 to 1
  21247. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  21248. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  21249. * @returns impostor the soft imposter
  21250. */
  21251. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  21252. /**
  21253. * Add a hook to a rope impostor
  21254. * @param otherImpostor rigid impostor to anchor to
  21255. * @param length ratio across rope from 0 to 1
  21256. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  21257. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  21258. * @returns impostor the rope imposter
  21259. */
  21260. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  21261. /**
  21262. * Will keep this body still, in a sleep mode.
  21263. * @returns the physics imposter
  21264. */
  21265. sleep(): PhysicsImpostor;
  21266. /**
  21267. * Wake the body up.
  21268. * @returns The physics imposter
  21269. */
  21270. wakeUp(): PhysicsImpostor;
  21271. /**
  21272. * Clones the physics imposter
  21273. * @param newObject The physics imposter clones to this physics-enabled object
  21274. * @returns A nullable physics imposter
  21275. */
  21276. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  21277. /**
  21278. * Disposes the physics imposter
  21279. */
  21280. dispose(): void;
  21281. /**
  21282. * Sets the delta position
  21283. * @param position The delta position amount
  21284. */
  21285. setDeltaPosition(position: Vector3): void;
  21286. /**
  21287. * Sets the delta rotation
  21288. * @param rotation The delta rotation amount
  21289. */
  21290. setDeltaRotation(rotation: Quaternion): void;
  21291. /**
  21292. * Gets the box size of the physics imposter and stores the result in the input parameter
  21293. * @param result Stores the box size
  21294. * @returns The physics imposter
  21295. */
  21296. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  21297. /**
  21298. * Gets the radius of the physics imposter
  21299. * @returns Radius of the physics imposter
  21300. */
  21301. getRadius(): number;
  21302. /**
  21303. * Sync a bone with this impostor
  21304. * @param bone The bone to sync to the impostor.
  21305. * @param boneMesh The mesh that the bone is influencing.
  21306. * @param jointPivot The pivot of the joint / bone in local space.
  21307. * @param distToJoint Optional distance from the impostor to the joint.
  21308. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  21309. */
  21310. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  21311. /**
  21312. * Sync impostor to a bone
  21313. * @param bone The bone that the impostor will be synced to.
  21314. * @param boneMesh The mesh that the bone is influencing.
  21315. * @param jointPivot The pivot of the joint / bone in local space.
  21316. * @param distToJoint Optional distance from the impostor to the joint.
  21317. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  21318. * @param boneAxis Optional vector3 axis the bone is aligned with
  21319. */
  21320. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  21321. /**
  21322. * No-Imposter type
  21323. */
  21324. static NoImpostor: number;
  21325. /**
  21326. * Sphere-Imposter type
  21327. */
  21328. static SphereImpostor: number;
  21329. /**
  21330. * Box-Imposter type
  21331. */
  21332. static BoxImpostor: number;
  21333. /**
  21334. * Plane-Imposter type
  21335. */
  21336. static PlaneImpostor: number;
  21337. /**
  21338. * Mesh-imposter type
  21339. */
  21340. static MeshImpostor: number;
  21341. /**
  21342. * Cylinder-Imposter type
  21343. */
  21344. static CylinderImpostor: number;
  21345. /**
  21346. * Particle-Imposter type
  21347. */
  21348. static ParticleImpostor: number;
  21349. /**
  21350. * Heightmap-Imposter type
  21351. */
  21352. static HeightmapImpostor: number;
  21353. /**
  21354. * ConvexHull-Impostor type (Ammo.js plugin only)
  21355. */
  21356. static ConvexHullImpostor: number;
  21357. /**
  21358. * Rope-Imposter type
  21359. */
  21360. static RopeImpostor: number;
  21361. /**
  21362. * Cloth-Imposter type
  21363. */
  21364. static ClothImpostor: number;
  21365. /**
  21366. * Softbody-Imposter type
  21367. */
  21368. static SoftbodyImpostor: number;
  21369. }
  21370. }
  21371. declare module "babylonjs/Meshes/mesh" {
  21372. import { Observable } from "babylonjs/Misc/observable";
  21373. import { IAnimatable } from "babylonjs/Misc/tools";
  21374. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  21375. import { Camera } from "babylonjs/Cameras/camera";
  21376. import { Scene } from "babylonjs/scene";
  21377. import { Matrix, Vector3, Vector2, Color4, Plane, Vector4, Path3D } from "babylonjs/Maths/math";
  21378. import { Engine } from "babylonjs/Engines/engine";
  21379. import { Node } from "babylonjs/node";
  21380. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  21381. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  21382. import { Buffer } from "babylonjs/Meshes/buffer";
  21383. import { Geometry } from "babylonjs/Meshes/geometry";
  21384. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21385. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21386. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  21387. import { Effect } from "babylonjs/Materials/effect";
  21388. import { Material } from "babylonjs/Materials/material";
  21389. import { Skeleton } from "babylonjs/Bones/skeleton";
  21390. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  21391. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  21392. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  21393. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  21394. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  21395. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  21396. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  21397. /**
  21398. * @hidden
  21399. **/
  21400. export class _CreationDataStorage {
  21401. closePath?: boolean;
  21402. closeArray?: boolean;
  21403. idx: number[];
  21404. dashSize: number;
  21405. gapSize: number;
  21406. path3D: Path3D;
  21407. pathArray: Vector3[][];
  21408. arc: number;
  21409. radius: number;
  21410. cap: number;
  21411. tessellation: number;
  21412. }
  21413. /**
  21414. * @hidden
  21415. **/
  21416. class _InstanceDataStorage {
  21417. visibleInstances: any;
  21418. batchCache: _InstancesBatch;
  21419. instancesBufferSize: number;
  21420. instancesBuffer: Nullable<Buffer>;
  21421. instancesData: Float32Array;
  21422. overridenInstanceCount: number;
  21423. isFrozen: boolean;
  21424. previousBatch: _InstancesBatch;
  21425. hardwareInstancedRendering: boolean;
  21426. sideOrientation: number;
  21427. }
  21428. /**
  21429. * @hidden
  21430. **/
  21431. export class _InstancesBatch {
  21432. mustReturn: boolean;
  21433. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  21434. renderSelf: boolean[];
  21435. hardwareInstancedRendering: boolean[];
  21436. }
  21437. /**
  21438. * Class used to represent renderable models
  21439. */
  21440. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  21441. /**
  21442. * Mesh side orientation : usually the external or front surface
  21443. */
  21444. static readonly FRONTSIDE: number;
  21445. /**
  21446. * Mesh side orientation : usually the internal or back surface
  21447. */
  21448. static readonly BACKSIDE: number;
  21449. /**
  21450. * Mesh side orientation : both internal and external or front and back surfaces
  21451. */
  21452. static readonly DOUBLESIDE: number;
  21453. /**
  21454. * Mesh side orientation : by default, `FRONTSIDE`
  21455. */
  21456. static readonly DEFAULTSIDE: number;
  21457. /**
  21458. * Mesh cap setting : no cap
  21459. */
  21460. static readonly NO_CAP: number;
  21461. /**
  21462. * Mesh cap setting : one cap at the beginning of the mesh
  21463. */
  21464. static readonly CAP_START: number;
  21465. /**
  21466. * Mesh cap setting : one cap at the end of the mesh
  21467. */
  21468. static readonly CAP_END: number;
  21469. /**
  21470. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  21471. */
  21472. static readonly CAP_ALL: number;
  21473. /**
  21474. * Gets the default side orientation.
  21475. * @param orientation the orientation to value to attempt to get
  21476. * @returns the default orientation
  21477. * @hidden
  21478. */
  21479. static _GetDefaultSideOrientation(orientation?: number): number;
  21480. private _internalMeshDataInfo;
  21481. /**
  21482. * An event triggered before rendering the mesh
  21483. */
  21484. readonly onBeforeRenderObservable: Observable<Mesh>;
  21485. /**
  21486. * An event triggered before binding the mesh
  21487. */
  21488. readonly onBeforeBindObservable: Observable<Mesh>;
  21489. /**
  21490. * An event triggered after rendering the mesh
  21491. */
  21492. readonly onAfterRenderObservable: Observable<Mesh>;
  21493. /**
  21494. * An event triggered before drawing the mesh
  21495. */
  21496. readonly onBeforeDrawObservable: Observable<Mesh>;
  21497. private _onBeforeDrawObserver;
  21498. /**
  21499. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  21500. */
  21501. onBeforeDraw: () => void;
  21502. /**
  21503. * Gets the delay loading state of the mesh (when delay loading is turned on)
  21504. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  21505. */
  21506. delayLoadState: number;
  21507. /**
  21508. * Gets the list of instances created from this mesh
  21509. * it is not supposed to be modified manually.
  21510. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  21511. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  21512. */
  21513. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  21514. /**
  21515. * Gets the file containing delay loading data for this mesh
  21516. */
  21517. delayLoadingFile: string;
  21518. /** @hidden */
  21519. _binaryInfo: any;
  21520. /**
  21521. * User defined function used to change how LOD level selection is done
  21522. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  21523. */
  21524. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  21525. /**
  21526. * Gets or sets the morph target manager
  21527. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  21528. */
  21529. morphTargetManager: Nullable<MorphTargetManager>;
  21530. /** @hidden */
  21531. _creationDataStorage: Nullable<_CreationDataStorage>;
  21532. /** @hidden */
  21533. _geometry: Nullable<Geometry>;
  21534. /** @hidden */
  21535. _delayInfo: Array<string>;
  21536. /** @hidden */
  21537. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  21538. /** @hidden */
  21539. _instanceDataStorage: _InstanceDataStorage;
  21540. private _effectiveMaterial;
  21541. /** @hidden */
  21542. _shouldGenerateFlatShading: boolean;
  21543. /** @hidden */
  21544. _originalBuilderSideOrientation: number;
  21545. /**
  21546. * Use this property to change the original side orientation defined at construction time
  21547. */
  21548. overrideMaterialSideOrientation: Nullable<number>;
  21549. /**
  21550. * Gets the source mesh (the one used to clone this one from)
  21551. */
  21552. readonly source: Nullable<Mesh>;
  21553. /**
  21554. * Gets or sets a boolean indicating that this mesh does not use index buffer
  21555. */
  21556. isUnIndexed: boolean;
  21557. /**
  21558. * @constructor
  21559. * @param name The value used by scene.getMeshByName() to do a lookup.
  21560. * @param scene The scene to add this mesh to.
  21561. * @param parent The parent of this mesh, if it has one
  21562. * @param source An optional Mesh from which geometry is shared, cloned.
  21563. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  21564. * When false, achieved by calling a clone(), also passing False.
  21565. * This will make creation of children, recursive.
  21566. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  21567. */
  21568. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  21569. /**
  21570. * Gets the class name
  21571. * @returns the string "Mesh".
  21572. */
  21573. getClassName(): string;
  21574. /** @hidden */
  21575. readonly _isMesh: boolean;
  21576. /**
  21577. * Returns a description of this mesh
  21578. * @param fullDetails define if full details about this mesh must be used
  21579. * @returns a descriptive string representing this mesh
  21580. */
  21581. toString(fullDetails?: boolean): string;
  21582. /** @hidden */
  21583. _unBindEffect(): void;
  21584. /**
  21585. * Gets a boolean indicating if this mesh has LOD
  21586. */
  21587. readonly hasLODLevels: boolean;
  21588. /**
  21589. * Gets the list of MeshLODLevel associated with the current mesh
  21590. * @returns an array of MeshLODLevel
  21591. */
  21592. getLODLevels(): MeshLODLevel[];
  21593. private _sortLODLevels;
  21594. /**
  21595. * Add a mesh as LOD level triggered at the given distance.
  21596. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21597. * @param distance The distance from the center of the object to show this level
  21598. * @param mesh The mesh to be added as LOD level (can be null)
  21599. * @return This mesh (for chaining)
  21600. */
  21601. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  21602. /**
  21603. * Returns the LOD level mesh at the passed distance or null if not found.
  21604. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21605. * @param distance The distance from the center of the object to show this level
  21606. * @returns a Mesh or `null`
  21607. */
  21608. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  21609. /**
  21610. * Remove a mesh from the LOD array
  21611. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21612. * @param mesh defines the mesh to be removed
  21613. * @return This mesh (for chaining)
  21614. */
  21615. removeLODLevel(mesh: Mesh): Mesh;
  21616. /**
  21617. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  21618. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21619. * @param camera defines the camera to use to compute distance
  21620. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  21621. * @return This mesh (for chaining)
  21622. */
  21623. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  21624. /**
  21625. * Gets the mesh internal Geometry object
  21626. */
  21627. readonly geometry: Nullable<Geometry>;
  21628. /**
  21629. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  21630. * @returns the total number of vertices
  21631. */
  21632. getTotalVertices(): number;
  21633. /**
  21634. * Returns the content of an associated vertex buffer
  21635. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21636. * - VertexBuffer.PositionKind
  21637. * - VertexBuffer.UVKind
  21638. * - VertexBuffer.UV2Kind
  21639. * - VertexBuffer.UV3Kind
  21640. * - VertexBuffer.UV4Kind
  21641. * - VertexBuffer.UV5Kind
  21642. * - VertexBuffer.UV6Kind
  21643. * - VertexBuffer.ColorKind
  21644. * - VertexBuffer.MatricesIndicesKind
  21645. * - VertexBuffer.MatricesIndicesExtraKind
  21646. * - VertexBuffer.MatricesWeightsKind
  21647. * - VertexBuffer.MatricesWeightsExtraKind
  21648. * @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
  21649. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  21650. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  21651. */
  21652. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21653. /**
  21654. * Returns the mesh VertexBuffer object from the requested `kind`
  21655. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21656. * - VertexBuffer.PositionKind
  21657. * - VertexBuffer.UVKind
  21658. * - VertexBuffer.UV2Kind
  21659. * - VertexBuffer.UV3Kind
  21660. * - VertexBuffer.UV4Kind
  21661. * - VertexBuffer.UV5Kind
  21662. * - VertexBuffer.UV6Kind
  21663. * - VertexBuffer.ColorKind
  21664. * - VertexBuffer.MatricesIndicesKind
  21665. * - VertexBuffer.MatricesIndicesExtraKind
  21666. * - VertexBuffer.MatricesWeightsKind
  21667. * - VertexBuffer.MatricesWeightsExtraKind
  21668. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  21669. */
  21670. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21671. /**
  21672. * Tests if a specific vertex buffer is associated with this mesh
  21673. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  21674. * - VertexBuffer.PositionKind
  21675. * - VertexBuffer.UVKind
  21676. * - VertexBuffer.UV2Kind
  21677. * - VertexBuffer.UV3Kind
  21678. * - VertexBuffer.UV4Kind
  21679. * - VertexBuffer.UV5Kind
  21680. * - VertexBuffer.UV6Kind
  21681. * - VertexBuffer.ColorKind
  21682. * - VertexBuffer.MatricesIndicesKind
  21683. * - VertexBuffer.MatricesIndicesExtraKind
  21684. * - VertexBuffer.MatricesWeightsKind
  21685. * - VertexBuffer.MatricesWeightsExtraKind
  21686. * @returns a boolean
  21687. */
  21688. isVerticesDataPresent(kind: string): boolean;
  21689. /**
  21690. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  21691. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  21692. * - VertexBuffer.PositionKind
  21693. * - VertexBuffer.UVKind
  21694. * - VertexBuffer.UV2Kind
  21695. * - VertexBuffer.UV3Kind
  21696. * - VertexBuffer.UV4Kind
  21697. * - VertexBuffer.UV5Kind
  21698. * - VertexBuffer.UV6Kind
  21699. * - VertexBuffer.ColorKind
  21700. * - VertexBuffer.MatricesIndicesKind
  21701. * - VertexBuffer.MatricesIndicesExtraKind
  21702. * - VertexBuffer.MatricesWeightsKind
  21703. * - VertexBuffer.MatricesWeightsExtraKind
  21704. * @returns a boolean
  21705. */
  21706. isVertexBufferUpdatable(kind: string): boolean;
  21707. /**
  21708. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  21709. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21710. * - VertexBuffer.PositionKind
  21711. * - VertexBuffer.UVKind
  21712. * - VertexBuffer.UV2Kind
  21713. * - VertexBuffer.UV3Kind
  21714. * - VertexBuffer.UV4Kind
  21715. * - VertexBuffer.UV5Kind
  21716. * - VertexBuffer.UV6Kind
  21717. * - VertexBuffer.ColorKind
  21718. * - VertexBuffer.MatricesIndicesKind
  21719. * - VertexBuffer.MatricesIndicesExtraKind
  21720. * - VertexBuffer.MatricesWeightsKind
  21721. * - VertexBuffer.MatricesWeightsExtraKind
  21722. * @returns an array of strings
  21723. */
  21724. getVerticesDataKinds(): string[];
  21725. /**
  21726. * Returns a positive integer : the total number of indices in this mesh geometry.
  21727. * @returns the numner of indices or zero if the mesh has no geometry.
  21728. */
  21729. getTotalIndices(): number;
  21730. /**
  21731. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21732. * @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.
  21733. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21734. * @returns the indices array or an empty array if the mesh has no geometry
  21735. */
  21736. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21737. readonly isBlocked: boolean;
  21738. /**
  21739. * Determine if the current mesh is ready to be rendered
  21740. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  21741. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  21742. * @returns true if all associated assets are ready (material, textures, shaders)
  21743. */
  21744. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  21745. /**
  21746. * 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.
  21747. */
  21748. readonly areNormalsFrozen: boolean;
  21749. /**
  21750. * 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.
  21751. * @returns the current mesh
  21752. */
  21753. freezeNormals(): Mesh;
  21754. /**
  21755. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc. It has no effect at all on other shapes. It reactivates the mesh normals computation if it was previously frozen
  21756. * @returns the current mesh
  21757. */
  21758. unfreezeNormals(): Mesh;
  21759. /**
  21760. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  21761. */
  21762. overridenInstanceCount: number;
  21763. /** @hidden */
  21764. _preActivate(): Mesh;
  21765. /** @hidden */
  21766. _preActivateForIntermediateRendering(renderId: number): Mesh;
  21767. /** @hidden */
  21768. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  21769. /**
  21770. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  21771. * This means the mesh underlying bounding box and sphere are recomputed.
  21772. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  21773. * @returns the current mesh
  21774. */
  21775. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  21776. /** @hidden */
  21777. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  21778. /**
  21779. * This function will subdivide the mesh into multiple submeshes
  21780. * @param count defines the expected number of submeshes
  21781. */
  21782. subdivide(count: number): void;
  21783. /**
  21784. * Copy a FloatArray into a specific associated vertex buffer
  21785. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21786. * - VertexBuffer.PositionKind
  21787. * - VertexBuffer.UVKind
  21788. * - VertexBuffer.UV2Kind
  21789. * - VertexBuffer.UV3Kind
  21790. * - VertexBuffer.UV4Kind
  21791. * - VertexBuffer.UV5Kind
  21792. * - VertexBuffer.UV6Kind
  21793. * - VertexBuffer.ColorKind
  21794. * - VertexBuffer.MatricesIndicesKind
  21795. * - VertexBuffer.MatricesIndicesExtraKind
  21796. * - VertexBuffer.MatricesWeightsKind
  21797. * - VertexBuffer.MatricesWeightsExtraKind
  21798. * @param data defines the data source
  21799. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  21800. * @param stride defines the data stride size (can be null)
  21801. * @returns the current mesh
  21802. */
  21803. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  21804. /**
  21805. * Flags an associated vertex buffer as updatable
  21806. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  21807. * - VertexBuffer.PositionKind
  21808. * - VertexBuffer.UVKind
  21809. * - VertexBuffer.UV2Kind
  21810. * - VertexBuffer.UV3Kind
  21811. * - VertexBuffer.UV4Kind
  21812. * - VertexBuffer.UV5Kind
  21813. * - VertexBuffer.UV6Kind
  21814. * - VertexBuffer.ColorKind
  21815. * - VertexBuffer.MatricesIndicesKind
  21816. * - VertexBuffer.MatricesIndicesExtraKind
  21817. * - VertexBuffer.MatricesWeightsKind
  21818. * - VertexBuffer.MatricesWeightsExtraKind
  21819. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  21820. */
  21821. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  21822. /**
  21823. * Sets the mesh global Vertex Buffer
  21824. * @param buffer defines the buffer to use
  21825. * @returns the current mesh
  21826. */
  21827. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  21828. /**
  21829. * Update a specific associated vertex buffer
  21830. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21831. * - VertexBuffer.PositionKind
  21832. * - VertexBuffer.UVKind
  21833. * - VertexBuffer.UV2Kind
  21834. * - VertexBuffer.UV3Kind
  21835. * - VertexBuffer.UV4Kind
  21836. * - VertexBuffer.UV5Kind
  21837. * - VertexBuffer.UV6Kind
  21838. * - VertexBuffer.ColorKind
  21839. * - VertexBuffer.MatricesIndicesKind
  21840. * - VertexBuffer.MatricesIndicesExtraKind
  21841. * - VertexBuffer.MatricesWeightsKind
  21842. * - VertexBuffer.MatricesWeightsExtraKind
  21843. * @param data defines the data source
  21844. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21845. * @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)
  21846. * @returns the current mesh
  21847. */
  21848. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  21849. /**
  21850. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  21851. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  21852. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  21853. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  21854. * @returns the current mesh
  21855. */
  21856. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  21857. /**
  21858. * Creates a un-shared specific occurence of the geometry for the mesh.
  21859. * @returns the current mesh
  21860. */
  21861. makeGeometryUnique(): Mesh;
  21862. /**
  21863. * Set the index buffer of this mesh
  21864. * @param indices defines the source data
  21865. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  21866. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  21867. * @returns the current mesh
  21868. */
  21869. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  21870. /**
  21871. * Update the current index buffer
  21872. * @param indices defines the source data
  21873. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  21874. * @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)
  21875. * @returns the current mesh
  21876. */
  21877. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  21878. /**
  21879. * Invert the geometry to move from a right handed system to a left handed one.
  21880. * @returns the current mesh
  21881. */
  21882. toLeftHanded(): Mesh;
  21883. /** @hidden */
  21884. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  21885. /** @hidden */
  21886. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  21887. /**
  21888. * Registers for this mesh a javascript function called just before the rendering process
  21889. * @param func defines the function to call before rendering this mesh
  21890. * @returns the current mesh
  21891. */
  21892. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21893. /**
  21894. * Disposes a previously registered javascript function called before the rendering
  21895. * @param func defines the function to remove
  21896. * @returns the current mesh
  21897. */
  21898. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21899. /**
  21900. * Registers for this mesh a javascript function called just after the rendering is complete
  21901. * @param func defines the function to call after rendering this mesh
  21902. * @returns the current mesh
  21903. */
  21904. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21905. /**
  21906. * Disposes a previously registered javascript function called after the rendering.
  21907. * @param func defines the function to remove
  21908. * @returns the current mesh
  21909. */
  21910. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21911. /** @hidden */
  21912. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  21913. /** @hidden */
  21914. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  21915. /** @hidden */
  21916. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  21917. /** @hidden */
  21918. _freeze(): void;
  21919. /** @hidden */
  21920. _unFreeze(): void;
  21921. /**
  21922. * 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
  21923. * @param subMesh defines the subMesh to render
  21924. * @param enableAlphaMode defines if alpha mode can be changed
  21925. * @returns the current mesh
  21926. */
  21927. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  21928. private _onBeforeDraw;
  21929. /**
  21930. * Renormalize the mesh and patch it up if there are no weights
  21931. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  21932. * However in the case of zero weights then we set just a single influence to 1.
  21933. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  21934. */
  21935. cleanMatrixWeights(): void;
  21936. private normalizeSkinFourWeights;
  21937. private normalizeSkinWeightsAndExtra;
  21938. /**
  21939. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  21940. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  21941. * the user know there was an issue with importing the mesh
  21942. * @returns a validation object with skinned, valid and report string
  21943. */
  21944. validateSkinning(): {
  21945. skinned: boolean;
  21946. valid: boolean;
  21947. report: string;
  21948. };
  21949. /** @hidden */
  21950. _checkDelayState(): Mesh;
  21951. private _queueLoad;
  21952. /**
  21953. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  21954. * A mesh is in the frustum if its bounding box intersects the frustum
  21955. * @param frustumPlanes defines the frustum to test
  21956. * @returns true if the mesh is in the frustum planes
  21957. */
  21958. isInFrustum(frustumPlanes: Plane[]): boolean;
  21959. /**
  21960. * Sets the mesh material by the material or multiMaterial `id` property
  21961. * @param id is a string identifying the material or the multiMaterial
  21962. * @returns the current mesh
  21963. */
  21964. setMaterialByID(id: string): Mesh;
  21965. /**
  21966. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  21967. * @returns an array of IAnimatable
  21968. */
  21969. getAnimatables(): IAnimatable[];
  21970. /**
  21971. * Modifies the mesh geometry according to the passed transformation matrix.
  21972. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  21973. * The mesh normals are modified using the same transformation.
  21974. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21975. * @param transform defines the transform matrix to use
  21976. * @see http://doc.babylonjs.com/resources/baking_transformations
  21977. * @returns the current mesh
  21978. */
  21979. bakeTransformIntoVertices(transform: Matrix): Mesh;
  21980. /**
  21981. * Modifies the mesh geometry according to its own current World Matrix.
  21982. * The mesh World Matrix is then reset.
  21983. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  21984. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21985. * @see http://doc.babylonjs.com/resources/baking_transformations
  21986. * @returns the current mesh
  21987. */
  21988. bakeCurrentTransformIntoVertices(): Mesh;
  21989. /** @hidden */
  21990. readonly _positions: Nullable<Vector3[]>;
  21991. /** @hidden */
  21992. _resetPointsArrayCache(): Mesh;
  21993. /** @hidden */
  21994. _generatePointsArray(): boolean;
  21995. /**
  21996. * Returns a new Mesh object generated from the current mesh properties.
  21997. * This method must not get confused with createInstance()
  21998. * @param name is a string, the name given to the new mesh
  21999. * @param newParent can be any Node object (default `null`)
  22000. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  22001. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  22002. * @returns a new mesh
  22003. */
  22004. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  22005. /**
  22006. * Releases resources associated with this mesh.
  22007. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  22008. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  22009. */
  22010. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  22011. /**
  22012. * Modifies the mesh geometry according to a displacement map.
  22013. * 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.
  22014. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  22015. * @param url is a string, the URL from the image file is to be downloaded.
  22016. * @param minHeight is the lower limit of the displacement.
  22017. * @param maxHeight is the upper limit of the displacement.
  22018. * @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.
  22019. * @param uvOffset is an optional vector2 used to offset UV.
  22020. * @param uvScale is an optional vector2 used to scale UV.
  22021. * @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.
  22022. * @returns the Mesh.
  22023. */
  22024. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  22025. /**
  22026. * Modifies the mesh geometry according to a displacementMap buffer.
  22027. * 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.
  22028. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  22029. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  22030. * @param heightMapWidth is the width of the buffer image.
  22031. * @param heightMapHeight is the height of the buffer image.
  22032. * @param minHeight is the lower limit of the displacement.
  22033. * @param maxHeight is the upper limit of the displacement.
  22034. * @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.
  22035. * @param uvOffset is an optional vector2 used to offset UV.
  22036. * @param uvScale is an optional vector2 used to scale UV.
  22037. * @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.
  22038. * @returns the Mesh.
  22039. */
  22040. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  22041. /**
  22042. * Modify the mesh to get a flat shading rendering.
  22043. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  22044. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  22045. * @returns current mesh
  22046. */
  22047. convertToFlatShadedMesh(): Mesh;
  22048. /**
  22049. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  22050. * In other words, more vertices, no more indices and a single bigger VBO.
  22051. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  22052. * @returns current mesh
  22053. */
  22054. convertToUnIndexedMesh(): Mesh;
  22055. /**
  22056. * Inverses facet orientations.
  22057. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  22058. * @param flipNormals will also inverts the normals
  22059. * @returns current mesh
  22060. */
  22061. flipFaces(flipNormals?: boolean): Mesh;
  22062. /**
  22063. * Increase the number of facets and hence vertices in a mesh
  22064. * Vertex normals are interpolated from existing vertex normals
  22065. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  22066. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  22067. */
  22068. increaseVertices(numberPerEdge: number): void;
  22069. /**
  22070. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  22071. * This will undo any application of covertToFlatShadedMesh
  22072. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  22073. */
  22074. forceSharedVertices(): void;
  22075. /** @hidden */
  22076. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  22077. /** @hidden */
  22078. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  22079. /**
  22080. * Creates a new InstancedMesh object from the mesh model.
  22081. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  22082. * @param name defines the name of the new instance
  22083. * @returns a new InstancedMesh
  22084. */
  22085. createInstance(name: string): InstancedMesh;
  22086. /**
  22087. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  22088. * After this call, all the mesh instances have the same submeshes than the current mesh.
  22089. * @returns the current mesh
  22090. */
  22091. synchronizeInstances(): Mesh;
  22092. /**
  22093. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  22094. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  22095. * This should be used together with the simplification to avoid disappearing triangles.
  22096. * @param successCallback an optional success callback to be called after the optimization finished.
  22097. * @returns the current mesh
  22098. */
  22099. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  22100. /**
  22101. * Serialize current mesh
  22102. * @param serializationObject defines the object which will receive the serialization data
  22103. */
  22104. serialize(serializationObject: any): void;
  22105. /** @hidden */
  22106. _syncGeometryWithMorphTargetManager(): void;
  22107. /** @hidden */
  22108. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  22109. /**
  22110. * Returns a new Mesh object parsed from the source provided.
  22111. * @param parsedMesh is the source
  22112. * @param scene defines the hosting scene
  22113. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  22114. * @returns a new Mesh
  22115. */
  22116. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  22117. /**
  22118. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  22119. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  22120. * @param name defines the name of the mesh to create
  22121. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  22122. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  22123. * @param closePath creates a seam between the first and the last points of each path of the path array
  22124. * @param offset is taken in account only if the `pathArray` is containing a single path
  22125. * @param scene defines the hosting scene
  22126. * @param updatable defines if the mesh must be flagged as updatable
  22127. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22128. * @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)
  22129. * @returns a new Mesh
  22130. */
  22131. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  22132. /**
  22133. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  22134. * @param name defines the name of the mesh to create
  22135. * @param radius sets the radius size (float) of the polygon (default 0.5)
  22136. * @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
  22137. * @param scene defines the hosting scene
  22138. * @param updatable defines if the mesh must be flagged as updatable
  22139. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22140. * @returns a new Mesh
  22141. */
  22142. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  22143. /**
  22144. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  22145. * @param name defines the name of the mesh to create
  22146. * @param size sets the size (float) of each box side (default 1)
  22147. * @param scene defines the hosting scene
  22148. * @param updatable defines if the mesh must be flagged as updatable
  22149. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22150. * @returns a new Mesh
  22151. */
  22152. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  22153. /**
  22154. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  22155. * @param name defines the name of the mesh to create
  22156. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  22157. * @param diameter sets the diameter size (float) of the sphere (default 1)
  22158. * @param scene defines the hosting scene
  22159. * @param updatable defines if the mesh must be flagged as updatable
  22160. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22161. * @returns a new Mesh
  22162. */
  22163. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22164. /**
  22165. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  22166. * @param name defines the name of the mesh to create
  22167. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  22168. * @param diameter sets the diameter size (float) of the sphere (default 1)
  22169. * @param scene defines the hosting scene
  22170. * @returns a new Mesh
  22171. */
  22172. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  22173. /**
  22174. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  22175. * @param name defines the name of the mesh to create
  22176. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  22177. * @param diameterTop set the top cap diameter (floats, default 1)
  22178. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  22179. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  22180. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  22181. * @param scene defines the hosting scene
  22182. * @param updatable defines if the mesh must be flagged as updatable
  22183. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22184. * @returns a new Mesh
  22185. */
  22186. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  22187. /**
  22188. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  22189. * @param name defines the name of the mesh to create
  22190. * @param diameter sets the diameter size (float) of the torus (default 1)
  22191. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  22192. * @param tessellation sets the number of torus sides (postive integer, default 16)
  22193. * @param scene defines the hosting scene
  22194. * @param updatable defines if the mesh must be flagged as updatable
  22195. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22196. * @returns a new Mesh
  22197. */
  22198. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22199. /**
  22200. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  22201. * @param name defines the name of the mesh to create
  22202. * @param radius sets the global radius size (float) of the torus knot (default 2)
  22203. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  22204. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  22205. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  22206. * @param p the number of windings on X axis (positive integers, default 2)
  22207. * @param q the number of windings on Y axis (positive integers, default 3)
  22208. * @param scene defines the hosting scene
  22209. * @param updatable defines if the mesh must be flagged as updatable
  22210. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22211. * @returns a new Mesh
  22212. */
  22213. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22214. /**
  22215. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  22216. * @param name defines the name of the mesh to create
  22217. * @param points is an array successive Vector3
  22218. * @param scene defines the hosting scene
  22219. * @param updatable defines if the mesh must be flagged as updatable
  22220. * @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).
  22221. * @returns a new Mesh
  22222. */
  22223. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  22224. /**
  22225. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  22226. * @param name defines the name of the mesh to create
  22227. * @param points is an array successive Vector3
  22228. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  22229. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  22230. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  22231. * @param scene defines the hosting scene
  22232. * @param updatable defines if the mesh must be flagged as updatable
  22233. * @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)
  22234. * @returns a new Mesh
  22235. */
  22236. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  22237. /**
  22238. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  22239. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  22240. * 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.
  22241. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22242. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22243. * Remember you can only change the shape positions, not their number when updating a polygon.
  22244. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  22245. * @param name defines the name of the mesh to create
  22246. * @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
  22247. * @param scene defines the hosting scene
  22248. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  22249. * @param updatable defines if the mesh must be flagged as updatable
  22250. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22251. * @param earcutInjection can be used to inject your own earcut reference
  22252. * @returns a new Mesh
  22253. */
  22254. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  22255. /**
  22256. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  22257. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  22258. * @param name defines the name of the mesh to create
  22259. * @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
  22260. * @param depth defines the height of extrusion
  22261. * @param scene defines the hosting scene
  22262. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  22263. * @param updatable defines if the mesh must be flagged as updatable
  22264. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22265. * @param earcutInjection can be used to inject your own earcut reference
  22266. * @returns a new Mesh
  22267. */
  22268. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  22269. /**
  22270. * Creates an extruded shape mesh.
  22271. * 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
  22272. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  22273. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  22274. * @param name defines the name of the mesh to create
  22275. * @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
  22276. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  22277. * @param scale is the value to scale the shape
  22278. * @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
  22279. * @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
  22280. * @param scene defines the hosting scene
  22281. * @param updatable defines if the mesh must be flagged as updatable
  22282. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22283. * @param 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)
  22284. * @returns a new Mesh
  22285. */
  22286. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  22287. /**
  22288. * Creates an custom extruded shape mesh.
  22289. * The custom extrusion is a parametric shape.
  22290. * It has no predefined shape. Its final shape will depend on the input parameters.
  22291. * Please consider using the same method from the MeshBuilder class instead
  22292. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  22293. * @param name defines the name of the mesh to create
  22294. * @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
  22295. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  22296. * @param scaleFunction is a custom Javascript function called on each path point
  22297. * @param rotationFunction is a custom Javascript function called on each path point
  22298. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  22299. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  22300. * @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
  22301. * @param scene defines the hosting scene
  22302. * @param updatable defines if the mesh must be flagged as updatable
  22303. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22304. * @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)
  22305. * @returns a new Mesh
  22306. */
  22307. 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;
  22308. /**
  22309. * Creates lathe mesh.
  22310. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  22311. * Please consider using the same method from the MeshBuilder class instead
  22312. * @param name defines the name of the mesh to create
  22313. * @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
  22314. * @param radius is the radius value of the lathe
  22315. * @param tessellation is the side number of the lathe.
  22316. * @param scene defines the hosting scene
  22317. * @param updatable defines if the mesh must be flagged as updatable
  22318. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22319. * @returns a new Mesh
  22320. */
  22321. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22322. /**
  22323. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  22324. * @param name defines the name of the mesh to create
  22325. * @param size sets the size (float) of both sides of the plane at once (default 1)
  22326. * @param scene defines the hosting scene
  22327. * @param updatable defines if the mesh must be flagged as updatable
  22328. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22329. * @returns a new Mesh
  22330. */
  22331. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22332. /**
  22333. * Creates a ground mesh.
  22334. * Please consider using the same method from the MeshBuilder class instead
  22335. * @param name defines the name of the mesh to create
  22336. * @param width set the width of the ground
  22337. * @param height set the height of the ground
  22338. * @param subdivisions sets the number of subdivisions per side
  22339. * @param scene defines the hosting scene
  22340. * @param updatable defines if the mesh must be flagged as updatable
  22341. * @returns a new Mesh
  22342. */
  22343. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  22344. /**
  22345. * Creates a tiled ground mesh.
  22346. * Please consider using the same method from the MeshBuilder class instead
  22347. * @param name defines the name of the mesh to create
  22348. * @param xmin set the ground minimum X coordinate
  22349. * @param zmin set the ground minimum Y coordinate
  22350. * @param xmax set the ground maximum X coordinate
  22351. * @param zmax set the ground maximum Z coordinate
  22352. * @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
  22353. * @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
  22354. * @param scene defines the hosting scene
  22355. * @param updatable defines if the mesh must be flagged as updatable
  22356. * @returns a new Mesh
  22357. */
  22358. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  22359. w: number;
  22360. h: number;
  22361. }, precision: {
  22362. w: number;
  22363. h: number;
  22364. }, scene: Scene, updatable?: boolean): Mesh;
  22365. /**
  22366. * Creates a ground mesh from a height map.
  22367. * Please consider using the same method from the MeshBuilder class instead
  22368. * @see http://doc.babylonjs.com/babylon101/height_map
  22369. * @param name defines the name of the mesh to create
  22370. * @param url sets the URL of the height map image resource
  22371. * @param width set the ground width size
  22372. * @param height set the ground height size
  22373. * @param subdivisions sets the number of subdivision per side
  22374. * @param minHeight is the minimum altitude on the ground
  22375. * @param maxHeight is the maximum altitude on the ground
  22376. * @param scene defines the hosting scene
  22377. * @param updatable defines if the mesh must be flagged as updatable
  22378. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  22379. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  22380. * @returns a new Mesh
  22381. */
  22382. 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;
  22383. /**
  22384. * Creates a tube mesh.
  22385. * The tube is a parametric shape.
  22386. * It has no predefined shape. Its final shape will depend on the input parameters.
  22387. * Please consider using the same method from the MeshBuilder class instead
  22388. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  22389. * @param name defines the name of the mesh to create
  22390. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  22391. * @param radius sets the tube radius size
  22392. * @param tessellation is the number of sides on the tubular surface
  22393. * @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
  22394. * @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
  22395. * @param scene defines the hosting scene
  22396. * @param updatable defines if the mesh must be flagged as updatable
  22397. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22398. * @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)
  22399. * @returns a new Mesh
  22400. */
  22401. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  22402. (i: number, distance: number): number;
  22403. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  22404. /**
  22405. * Creates a polyhedron mesh.
  22406. * Please consider using the same method from the MeshBuilder class instead.
  22407. * * 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
  22408. * * The parameter `size` (positive float, default 1) sets the polygon size
  22409. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  22410. * * 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`
  22411. * * 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
  22412. * * 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)`)
  22413. * * 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
  22414. * * 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
  22415. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22416. * * If you create a double-sided mesh, you can choose what parts of 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
  22417. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22418. * @param name defines the name of the mesh to create
  22419. * @param options defines the options used to create the mesh
  22420. * @param scene defines the hosting scene
  22421. * @returns a new Mesh
  22422. */
  22423. static CreatePolyhedron(name: string, options: {
  22424. type?: number;
  22425. size?: number;
  22426. sizeX?: number;
  22427. sizeY?: number;
  22428. sizeZ?: number;
  22429. custom?: any;
  22430. faceUV?: Vector4[];
  22431. faceColors?: Color4[];
  22432. updatable?: boolean;
  22433. sideOrientation?: number;
  22434. }, scene: Scene): Mesh;
  22435. /**
  22436. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  22437. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  22438. * * 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`)
  22439. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  22440. * * 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
  22441. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22442. * * If you create a double-sided mesh, you can choose what parts of 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
  22443. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22444. * @param name defines the name of the mesh
  22445. * @param options defines the options used to create the mesh
  22446. * @param scene defines the hosting scene
  22447. * @returns a new Mesh
  22448. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  22449. */
  22450. static CreateIcoSphere(name: string, options: {
  22451. radius?: number;
  22452. flat?: boolean;
  22453. subdivisions?: number;
  22454. sideOrientation?: number;
  22455. updatable?: boolean;
  22456. }, scene: Scene): Mesh;
  22457. /**
  22458. * Creates a decal mesh.
  22459. * Please consider using the same method from the MeshBuilder class instead.
  22460. * A decal is a mesh usually applied as a model onto the surface of another mesh
  22461. * @param name defines the name of the mesh
  22462. * @param sourceMesh defines the mesh receiving the decal
  22463. * @param position sets the position of the decal in world coordinates
  22464. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  22465. * @param size sets the decal scaling
  22466. * @param angle sets the angle to rotate the decal
  22467. * @returns a new Mesh
  22468. */
  22469. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  22470. /**
  22471. * Prepare internal position array for software CPU skinning
  22472. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  22473. */
  22474. setPositionsForCPUSkinning(): Float32Array;
  22475. /**
  22476. * Prepare internal normal array for software CPU skinning
  22477. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  22478. */
  22479. setNormalsForCPUSkinning(): Float32Array;
  22480. /**
  22481. * Updates the vertex buffer by applying transformation from the bones
  22482. * @param skeleton defines the skeleton to apply to current mesh
  22483. * @returns the current mesh
  22484. */
  22485. applySkeleton(skeleton: Skeleton): Mesh;
  22486. /**
  22487. * 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
  22488. * @param meshes defines the list of meshes to scan
  22489. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  22490. */
  22491. static MinMax(meshes: AbstractMesh[]): {
  22492. min: Vector3;
  22493. max: Vector3;
  22494. };
  22495. /**
  22496. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  22497. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  22498. * @returns a vector3
  22499. */
  22500. static Center(meshesOrMinMaxVector: {
  22501. min: Vector3;
  22502. max: Vector3;
  22503. } | AbstractMesh[]): Vector3;
  22504. /**
  22505. * Merge the array of meshes into a single mesh for performance reasons.
  22506. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  22507. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  22508. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  22509. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  22510. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  22511. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  22512. * @returns a new mesh
  22513. */
  22514. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  22515. /** @hidden */
  22516. addInstance(instance: InstancedMesh): void;
  22517. /** @hidden */
  22518. removeInstance(instance: InstancedMesh): void;
  22519. }
  22520. }
  22521. declare module "babylonjs/Materials/material" {
  22522. import { IAnimatable } from "babylonjs/Misc/tools";
  22523. import { SmartArray } from "babylonjs/Misc/smartArray";
  22524. import { Observable } from "babylonjs/Misc/observable";
  22525. import { Nullable } from "babylonjs/types";
  22526. import { Scene } from "babylonjs/scene";
  22527. import { Matrix } from "babylonjs/Maths/math";
  22528. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  22529. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22530. import { Mesh } from "babylonjs/Meshes/mesh";
  22531. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  22532. import { Effect } from "babylonjs/Materials/effect";
  22533. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22534. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  22535. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22536. import { IInspectable } from "babylonjs/Misc/iInspectable";
  22537. import { Animation } from "babylonjs/Animations/animation";
  22538. /**
  22539. * Base class for the main features of a material in Babylon.js
  22540. */
  22541. export class Material implements IAnimatable {
  22542. /**
  22543. * Returns the triangle fill mode
  22544. */
  22545. static readonly TriangleFillMode: number;
  22546. /**
  22547. * Returns the wireframe mode
  22548. */
  22549. static readonly WireFrameFillMode: number;
  22550. /**
  22551. * Returns the point fill mode
  22552. */
  22553. static readonly PointFillMode: number;
  22554. /**
  22555. * Returns the point list draw mode
  22556. */
  22557. static readonly PointListDrawMode: number;
  22558. /**
  22559. * Returns the line list draw mode
  22560. */
  22561. static readonly LineListDrawMode: number;
  22562. /**
  22563. * Returns the line loop draw mode
  22564. */
  22565. static readonly LineLoopDrawMode: number;
  22566. /**
  22567. * Returns the line strip draw mode
  22568. */
  22569. static readonly LineStripDrawMode: number;
  22570. /**
  22571. * Returns the triangle strip draw mode
  22572. */
  22573. static readonly TriangleStripDrawMode: number;
  22574. /**
  22575. * Returns the triangle fan draw mode
  22576. */
  22577. static readonly TriangleFanDrawMode: number;
  22578. /**
  22579. * Stores the clock-wise side orientation
  22580. */
  22581. static readonly ClockWiseSideOrientation: number;
  22582. /**
  22583. * Stores the counter clock-wise side orientation
  22584. */
  22585. static readonly CounterClockWiseSideOrientation: number;
  22586. /**
  22587. * The dirty texture flag value
  22588. */
  22589. static readonly TextureDirtyFlag: number;
  22590. /**
  22591. * The dirty light flag value
  22592. */
  22593. static readonly LightDirtyFlag: number;
  22594. /**
  22595. * The dirty fresnel flag value
  22596. */
  22597. static readonly FresnelDirtyFlag: number;
  22598. /**
  22599. * The dirty attribute flag value
  22600. */
  22601. static readonly AttributesDirtyFlag: number;
  22602. /**
  22603. * The dirty misc flag value
  22604. */
  22605. static readonly MiscDirtyFlag: number;
  22606. /**
  22607. * The all dirty flag value
  22608. */
  22609. static readonly AllDirtyFlag: number;
  22610. /**
  22611. * The ID of the material
  22612. */
  22613. id: string;
  22614. /**
  22615. * Gets or sets the unique id of the material
  22616. */
  22617. uniqueId: number;
  22618. /**
  22619. * The name of the material
  22620. */
  22621. name: string;
  22622. /**
  22623. * Gets or sets user defined metadata
  22624. */
  22625. metadata: any;
  22626. /**
  22627. * For internal use only. Please do not use.
  22628. */
  22629. reservedDataStore: any;
  22630. /**
  22631. * Specifies if the ready state should be checked on each call
  22632. */
  22633. checkReadyOnEveryCall: boolean;
  22634. /**
  22635. * Specifies if the ready state should be checked once
  22636. */
  22637. checkReadyOnlyOnce: boolean;
  22638. /**
  22639. * The state of the material
  22640. */
  22641. state: string;
  22642. /**
  22643. * The alpha value of the material
  22644. */
  22645. protected _alpha: number;
  22646. /**
  22647. * List of inspectable custom properties (used by the Inspector)
  22648. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22649. */
  22650. inspectableCustomProperties: IInspectable[];
  22651. /**
  22652. * Sets the alpha value of the material
  22653. */
  22654. /**
  22655. * Gets the alpha value of the material
  22656. */
  22657. alpha: number;
  22658. /**
  22659. * Specifies if back face culling is enabled
  22660. */
  22661. protected _backFaceCulling: boolean;
  22662. /**
  22663. * Sets the back-face culling state
  22664. */
  22665. /**
  22666. * Gets the back-face culling state
  22667. */
  22668. backFaceCulling: boolean;
  22669. /**
  22670. * Stores the value for side orientation
  22671. */
  22672. sideOrientation: number;
  22673. /**
  22674. * Callback triggered when the material is compiled
  22675. */
  22676. onCompiled: Nullable<(effect: Effect) => void>;
  22677. /**
  22678. * Callback triggered when an error occurs
  22679. */
  22680. onError: Nullable<(effect: Effect, errors: string) => void>;
  22681. /**
  22682. * Callback triggered to get the render target textures
  22683. */
  22684. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  22685. /**
  22686. * Gets a boolean indicating that current material needs to register RTT
  22687. */
  22688. readonly hasRenderTargetTextures: boolean;
  22689. /**
  22690. * Specifies if the material should be serialized
  22691. */
  22692. doNotSerialize: boolean;
  22693. /**
  22694. * @hidden
  22695. */
  22696. _storeEffectOnSubMeshes: boolean;
  22697. /**
  22698. * Stores the animations for the material
  22699. */
  22700. animations: Nullable<Array<Animation>>;
  22701. /**
  22702. * An event triggered when the material is disposed
  22703. */
  22704. onDisposeObservable: Observable<Material>;
  22705. /**
  22706. * An observer which watches for dispose events
  22707. */
  22708. private _onDisposeObserver;
  22709. private _onUnBindObservable;
  22710. /**
  22711. * Called during a dispose event
  22712. */
  22713. onDispose: () => void;
  22714. private _onBindObservable;
  22715. /**
  22716. * An event triggered when the material is bound
  22717. */
  22718. readonly onBindObservable: Observable<AbstractMesh>;
  22719. /**
  22720. * An observer which watches for bind events
  22721. */
  22722. private _onBindObserver;
  22723. /**
  22724. * Called during a bind event
  22725. */
  22726. onBind: (Mesh: AbstractMesh) => void;
  22727. /**
  22728. * An event triggered when the material is unbound
  22729. */
  22730. readonly onUnBindObservable: Observable<Material>;
  22731. /**
  22732. * Stores the value of the alpha mode
  22733. */
  22734. private _alphaMode;
  22735. /**
  22736. * Sets the value of the alpha mode.
  22737. *
  22738. * | Value | Type | Description |
  22739. * | --- | --- | --- |
  22740. * | 0 | ALPHA_DISABLE | |
  22741. * | 1 | ALPHA_ADD | |
  22742. * | 2 | ALPHA_COMBINE | |
  22743. * | 3 | ALPHA_SUBTRACT | |
  22744. * | 4 | ALPHA_MULTIPLY | |
  22745. * | 5 | ALPHA_MAXIMIZED | |
  22746. * | 6 | ALPHA_ONEONE | |
  22747. * | 7 | ALPHA_PREMULTIPLIED | |
  22748. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  22749. * | 9 | ALPHA_INTERPOLATE | |
  22750. * | 10 | ALPHA_SCREENMODE | |
  22751. *
  22752. */
  22753. /**
  22754. * Gets the value of the alpha mode
  22755. */
  22756. alphaMode: number;
  22757. /**
  22758. * Stores the state of the need depth pre-pass value
  22759. */
  22760. private _needDepthPrePass;
  22761. /**
  22762. * Sets the need depth pre-pass value
  22763. */
  22764. /**
  22765. * Gets the depth pre-pass value
  22766. */
  22767. needDepthPrePass: boolean;
  22768. /**
  22769. * Specifies if depth writing should be disabled
  22770. */
  22771. disableDepthWrite: boolean;
  22772. /**
  22773. * Specifies if depth writing should be forced
  22774. */
  22775. forceDepthWrite: boolean;
  22776. /**
  22777. * Specifies if there should be a separate pass for culling
  22778. */
  22779. separateCullingPass: boolean;
  22780. /**
  22781. * Stores the state specifing if fog should be enabled
  22782. */
  22783. private _fogEnabled;
  22784. /**
  22785. * Sets the state for enabling fog
  22786. */
  22787. /**
  22788. * Gets the value of the fog enabled state
  22789. */
  22790. fogEnabled: boolean;
  22791. /**
  22792. * Stores the size of points
  22793. */
  22794. pointSize: number;
  22795. /**
  22796. * Stores the z offset value
  22797. */
  22798. zOffset: number;
  22799. /**
  22800. * Gets a value specifying if wireframe mode is enabled
  22801. */
  22802. /**
  22803. * Sets the state of wireframe mode
  22804. */
  22805. wireframe: boolean;
  22806. /**
  22807. * Gets the value specifying if point clouds are enabled
  22808. */
  22809. /**
  22810. * Sets the state of point cloud mode
  22811. */
  22812. pointsCloud: boolean;
  22813. /**
  22814. * Gets the material fill mode
  22815. */
  22816. /**
  22817. * Sets the material fill mode
  22818. */
  22819. fillMode: number;
  22820. /**
  22821. * @hidden
  22822. * Stores the effects for the material
  22823. */
  22824. _effect: Nullable<Effect>;
  22825. /**
  22826. * @hidden
  22827. * Specifies if the material was previously ready
  22828. */
  22829. _wasPreviouslyReady: boolean;
  22830. /**
  22831. * Specifies if uniform buffers should be used
  22832. */
  22833. private _useUBO;
  22834. /**
  22835. * Stores a reference to the scene
  22836. */
  22837. private _scene;
  22838. /**
  22839. * Stores the fill mode state
  22840. */
  22841. private _fillMode;
  22842. /**
  22843. * Specifies if the depth write state should be cached
  22844. */
  22845. private _cachedDepthWriteState;
  22846. /**
  22847. * Stores the uniform buffer
  22848. */
  22849. protected _uniformBuffer: UniformBuffer;
  22850. /** @hidden */
  22851. _indexInSceneMaterialArray: number;
  22852. /** @hidden */
  22853. meshMap: Nullable<{
  22854. [id: string]: AbstractMesh | undefined;
  22855. }>;
  22856. /**
  22857. * Creates a material instance
  22858. * @param name defines the name of the material
  22859. * @param scene defines the scene to reference
  22860. * @param doNotAdd specifies if the material should be added to the scene
  22861. */
  22862. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  22863. /**
  22864. * Returns a string representation of the current material
  22865. * @param fullDetails defines a boolean indicating which levels of logging is desired
  22866. * @returns a string with material information
  22867. */
  22868. toString(fullDetails?: boolean): string;
  22869. /**
  22870. * Gets the class name of the material
  22871. * @returns a string with the class name of the material
  22872. */
  22873. getClassName(): string;
  22874. /**
  22875. * Specifies if updates for the material been locked
  22876. */
  22877. readonly isFrozen: boolean;
  22878. /**
  22879. * Locks updates for the material
  22880. */
  22881. freeze(): void;
  22882. /**
  22883. * Unlocks updates for the material
  22884. */
  22885. unfreeze(): void;
  22886. /**
  22887. * Specifies if the material is ready to be used
  22888. * @param mesh defines the mesh to check
  22889. * @param useInstances specifies if instances should be used
  22890. * @returns a boolean indicating if the material is ready to be used
  22891. */
  22892. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22893. /**
  22894. * Specifies that the submesh is ready to be used
  22895. * @param mesh defines the mesh to check
  22896. * @param subMesh defines which submesh to check
  22897. * @param useInstances specifies that instances should be used
  22898. * @returns a boolean indicating that the submesh is ready or not
  22899. */
  22900. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  22901. /**
  22902. * Returns the material effect
  22903. * @returns the effect associated with the material
  22904. */
  22905. getEffect(): Nullable<Effect>;
  22906. /**
  22907. * Returns the current scene
  22908. * @returns a Scene
  22909. */
  22910. getScene(): Scene;
  22911. /**
  22912. * Specifies if the material will require alpha blending
  22913. * @returns a boolean specifying if alpha blending is needed
  22914. */
  22915. needAlphaBlending(): boolean;
  22916. /**
  22917. * Specifies if the mesh will require alpha blending
  22918. * @param mesh defines the mesh to check
  22919. * @returns a boolean specifying if alpha blending is needed for the mesh
  22920. */
  22921. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  22922. /**
  22923. * Specifies if this material should be rendered in alpha test mode
  22924. * @returns a boolean specifying if an alpha test is needed.
  22925. */
  22926. needAlphaTesting(): boolean;
  22927. /**
  22928. * Gets the texture used for the alpha test
  22929. * @returns the texture to use for alpha testing
  22930. */
  22931. getAlphaTestTexture(): Nullable<BaseTexture>;
  22932. /**
  22933. * Marks the material to indicate that it needs to be re-calculated
  22934. */
  22935. markDirty(): void;
  22936. /** @hidden */
  22937. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  22938. /**
  22939. * Binds the material to the mesh
  22940. * @param world defines the world transformation matrix
  22941. * @param mesh defines the mesh to bind the material to
  22942. */
  22943. bind(world: Matrix, mesh?: Mesh): void;
  22944. /**
  22945. * Binds the submesh to the material
  22946. * @param world defines the world transformation matrix
  22947. * @param mesh defines the mesh containing the submesh
  22948. * @param subMesh defines the submesh to bind the material to
  22949. */
  22950. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22951. /**
  22952. * Binds the world matrix to the material
  22953. * @param world defines the world transformation matrix
  22954. */
  22955. bindOnlyWorldMatrix(world: Matrix): void;
  22956. /**
  22957. * Binds the scene's uniform buffer to the effect.
  22958. * @param effect defines the effect to bind to the scene uniform buffer
  22959. * @param sceneUbo defines the uniform buffer storing scene data
  22960. */
  22961. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  22962. /**
  22963. * Binds the view matrix to the effect
  22964. * @param effect defines the effect to bind the view matrix to
  22965. */
  22966. bindView(effect: Effect): void;
  22967. /**
  22968. * Binds the view projection matrix to the effect
  22969. * @param effect defines the effect to bind the view projection matrix to
  22970. */
  22971. bindViewProjection(effect: Effect): void;
  22972. /**
  22973. * Specifies if material alpha testing should be turned on for the mesh
  22974. * @param mesh defines the mesh to check
  22975. */
  22976. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  22977. /**
  22978. * Processes to execute after binding the material to a mesh
  22979. * @param mesh defines the rendered mesh
  22980. */
  22981. protected _afterBind(mesh?: Mesh): void;
  22982. /**
  22983. * Unbinds the material from the mesh
  22984. */
  22985. unbind(): void;
  22986. /**
  22987. * Gets the active textures from the material
  22988. * @returns an array of textures
  22989. */
  22990. getActiveTextures(): BaseTexture[];
  22991. /**
  22992. * Specifies if the material uses a texture
  22993. * @param texture defines the texture to check against the material
  22994. * @returns a boolean specifying if the material uses the texture
  22995. */
  22996. hasTexture(texture: BaseTexture): boolean;
  22997. /**
  22998. * Makes a duplicate of the material, and gives it a new name
  22999. * @param name defines the new name for the duplicated material
  23000. * @returns the cloned material
  23001. */
  23002. clone(name: string): Nullable<Material>;
  23003. /**
  23004. * Gets the meshes bound to the material
  23005. * @returns an array of meshes bound to the material
  23006. */
  23007. getBindedMeshes(): AbstractMesh[];
  23008. /**
  23009. * Force shader compilation
  23010. * @param mesh defines the mesh associated with this material
  23011. * @param onCompiled defines a function to execute once the material is compiled
  23012. * @param options defines the options to configure the compilation
  23013. */
  23014. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  23015. clipPlane: boolean;
  23016. }>): void;
  23017. /**
  23018. * Force shader compilation
  23019. * @param mesh defines the mesh that will use this material
  23020. * @param options defines additional options for compiling the shaders
  23021. * @returns a promise that resolves when the compilation completes
  23022. */
  23023. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  23024. clipPlane: boolean;
  23025. }>): Promise<void>;
  23026. private static readonly _ImageProcessingDirtyCallBack;
  23027. private static readonly _TextureDirtyCallBack;
  23028. private static readonly _FresnelDirtyCallBack;
  23029. private static readonly _MiscDirtyCallBack;
  23030. private static readonly _LightsDirtyCallBack;
  23031. private static readonly _AttributeDirtyCallBack;
  23032. private static _FresnelAndMiscDirtyCallBack;
  23033. private static _TextureAndMiscDirtyCallBack;
  23034. private static readonly _DirtyCallbackArray;
  23035. private static readonly _RunDirtyCallBacks;
  23036. /**
  23037. * Marks a define in the material to indicate that it needs to be re-computed
  23038. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  23039. */
  23040. markAsDirty(flag: number): void;
  23041. /**
  23042. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  23043. * @param func defines a function which checks material defines against the submeshes
  23044. */
  23045. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  23046. /**
  23047. * Indicates that image processing needs to be re-calculated for all submeshes
  23048. */
  23049. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  23050. /**
  23051. * Indicates that textures need to be re-calculated for all submeshes
  23052. */
  23053. protected _markAllSubMeshesAsTexturesDirty(): void;
  23054. /**
  23055. * Indicates that fresnel needs to be re-calculated for all submeshes
  23056. */
  23057. protected _markAllSubMeshesAsFresnelDirty(): void;
  23058. /**
  23059. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  23060. */
  23061. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  23062. /**
  23063. * Indicates that lights need to be re-calculated for all submeshes
  23064. */
  23065. protected _markAllSubMeshesAsLightsDirty(): void;
  23066. /**
  23067. * Indicates that attributes need to be re-calculated for all submeshes
  23068. */
  23069. protected _markAllSubMeshesAsAttributesDirty(): void;
  23070. /**
  23071. * Indicates that misc needs to be re-calculated for all submeshes
  23072. */
  23073. protected _markAllSubMeshesAsMiscDirty(): void;
  23074. /**
  23075. * Indicates that textures and misc need to be re-calculated for all submeshes
  23076. */
  23077. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  23078. /**
  23079. * Disposes the material
  23080. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  23081. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  23082. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  23083. */
  23084. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  23085. /** @hidden */
  23086. private releaseVertexArrayObject;
  23087. /**
  23088. * Serializes this material
  23089. * @returns the serialized material object
  23090. */
  23091. serialize(): any;
  23092. /**
  23093. * Creates a material from parsed material data
  23094. * @param parsedMaterial defines parsed material data
  23095. * @param scene defines the hosting scene
  23096. * @param rootUrl defines the root URL to use to load textures
  23097. * @returns a new material
  23098. */
  23099. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  23100. }
  23101. }
  23102. declare module "babylonjs/Meshes/subMesh" {
  23103. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  23104. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  23105. import { Engine } from "babylonjs/Engines/engine";
  23106. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  23107. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23108. import { Effect } from "babylonjs/Materials/effect";
  23109. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  23110. import { Collider } from "babylonjs/Collisions/collider";
  23111. import { Material } from "babylonjs/Materials/material";
  23112. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  23113. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23114. import { Mesh } from "babylonjs/Meshes/mesh";
  23115. import { Ray } from "babylonjs/Culling/ray";
  23116. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  23117. /**
  23118. * Base class for submeshes
  23119. */
  23120. export class BaseSubMesh {
  23121. /** @hidden */
  23122. _materialDefines: Nullable<MaterialDefines>;
  23123. /** @hidden */
  23124. _materialEffect: Nullable<Effect>;
  23125. /**
  23126. * Gets associated effect
  23127. */
  23128. readonly effect: Nullable<Effect>;
  23129. /**
  23130. * Sets associated effect (effect used to render this submesh)
  23131. * @param effect defines the effect to associate with
  23132. * @param defines defines the set of defines used to compile this effect
  23133. */
  23134. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  23135. }
  23136. /**
  23137. * Defines a subdivision inside a mesh
  23138. */
  23139. export class SubMesh extends BaseSubMesh implements ICullable {
  23140. /** the material index to use */
  23141. materialIndex: number;
  23142. /** vertex index start */
  23143. verticesStart: number;
  23144. /** vertices count */
  23145. verticesCount: number;
  23146. /** index start */
  23147. indexStart: number;
  23148. /** indices count */
  23149. indexCount: number;
  23150. /** @hidden */
  23151. _linesIndexCount: number;
  23152. private _mesh;
  23153. private _renderingMesh;
  23154. private _boundingInfo;
  23155. private _linesIndexBuffer;
  23156. /** @hidden */
  23157. _lastColliderWorldVertices: Nullable<Vector3[]>;
  23158. /** @hidden */
  23159. _trianglePlanes: Plane[];
  23160. /** @hidden */
  23161. _lastColliderTransformMatrix: Nullable<Matrix>;
  23162. /** @hidden */
  23163. _renderId: number;
  23164. /** @hidden */
  23165. _alphaIndex: number;
  23166. /** @hidden */
  23167. _distanceToCamera: number;
  23168. /** @hidden */
  23169. _id: number;
  23170. private _currentMaterial;
  23171. /**
  23172. * Add a new submesh to a mesh
  23173. * @param materialIndex defines the material index to use
  23174. * @param verticesStart defines vertex index start
  23175. * @param verticesCount defines vertices count
  23176. * @param indexStart defines index start
  23177. * @param indexCount defines indices count
  23178. * @param mesh defines the parent mesh
  23179. * @param renderingMesh defines an optional rendering mesh
  23180. * @param createBoundingBox defines if bounding box should be created for this submesh
  23181. * @returns the new submesh
  23182. */
  23183. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  23184. /**
  23185. * Creates a new submesh
  23186. * @param materialIndex defines the material index to use
  23187. * @param verticesStart defines vertex index start
  23188. * @param verticesCount defines vertices count
  23189. * @param indexStart defines index start
  23190. * @param indexCount defines indices count
  23191. * @param mesh defines the parent mesh
  23192. * @param renderingMesh defines an optional rendering mesh
  23193. * @param createBoundingBox defines if bounding box should be created for this submesh
  23194. */
  23195. constructor(
  23196. /** the material index to use */
  23197. materialIndex: number,
  23198. /** vertex index start */
  23199. verticesStart: number,
  23200. /** vertices count */
  23201. verticesCount: number,
  23202. /** index start */
  23203. indexStart: number,
  23204. /** indices count */
  23205. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  23206. /**
  23207. * Returns true if this submesh covers the entire parent mesh
  23208. * @ignorenaming
  23209. */
  23210. readonly IsGlobal: boolean;
  23211. /**
  23212. * Returns the submesh BoudingInfo object
  23213. * @returns current bounding info (or mesh's one if the submesh is global)
  23214. */
  23215. getBoundingInfo(): BoundingInfo;
  23216. /**
  23217. * Sets the submesh BoundingInfo
  23218. * @param boundingInfo defines the new bounding info to use
  23219. * @returns the SubMesh
  23220. */
  23221. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  23222. /**
  23223. * Returns the mesh of the current submesh
  23224. * @return the parent mesh
  23225. */
  23226. getMesh(): AbstractMesh;
  23227. /**
  23228. * Returns the rendering mesh of the submesh
  23229. * @returns the rendering mesh (could be different from parent mesh)
  23230. */
  23231. getRenderingMesh(): Mesh;
  23232. /**
  23233. * Returns the submesh material
  23234. * @returns null or the current material
  23235. */
  23236. getMaterial(): Nullable<Material>;
  23237. /**
  23238. * Sets a new updated BoundingInfo object to the submesh
  23239. * @param data defines an optional position array to use to determine the bounding info
  23240. * @returns the SubMesh
  23241. */
  23242. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  23243. /** @hidden */
  23244. _checkCollision(collider: Collider): boolean;
  23245. /**
  23246. * Updates the submesh BoundingInfo
  23247. * @param world defines the world matrix to use to update the bounding info
  23248. * @returns the submesh
  23249. */
  23250. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  23251. /**
  23252. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  23253. * @param frustumPlanes defines the frustum planes
  23254. * @returns true if the submesh is intersecting with the frustum
  23255. */
  23256. isInFrustum(frustumPlanes: Plane[]): boolean;
  23257. /**
  23258. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  23259. * @param frustumPlanes defines the frustum planes
  23260. * @returns true if the submesh is inside the frustum
  23261. */
  23262. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  23263. /**
  23264. * Renders the submesh
  23265. * @param enableAlphaMode defines if alpha needs to be used
  23266. * @returns the submesh
  23267. */
  23268. render(enableAlphaMode: boolean): SubMesh;
  23269. /**
  23270. * @hidden
  23271. */
  23272. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  23273. /**
  23274. * Checks if the submesh intersects with a ray
  23275. * @param ray defines the ray to test
  23276. * @returns true is the passed ray intersects the submesh bounding box
  23277. */
  23278. canIntersects(ray: Ray): boolean;
  23279. /**
  23280. * Intersects current submesh with a ray
  23281. * @param ray defines the ray to test
  23282. * @param positions defines mesh's positions array
  23283. * @param indices defines mesh's indices array
  23284. * @param fastCheck defines if only bounding info should be used
  23285. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  23286. * @returns intersection info or null if no intersection
  23287. */
  23288. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  23289. /** @hidden */
  23290. private _intersectLines;
  23291. /** @hidden */
  23292. private _intersectUnIndexedLines;
  23293. /** @hidden */
  23294. private _intersectTriangles;
  23295. /** @hidden */
  23296. private _intersectUnIndexedTriangles;
  23297. /** @hidden */
  23298. _rebuild(): void;
  23299. /**
  23300. * Creates a new submesh from the passed mesh
  23301. * @param newMesh defines the new hosting mesh
  23302. * @param newRenderingMesh defines an optional rendering mesh
  23303. * @returns the new submesh
  23304. */
  23305. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  23306. /**
  23307. * Release associated resources
  23308. */
  23309. dispose(): void;
  23310. /**
  23311. * Gets the class name
  23312. * @returns the string "SubMesh".
  23313. */
  23314. getClassName(): string;
  23315. /**
  23316. * Creates a new submesh from indices data
  23317. * @param materialIndex the index of the main mesh material
  23318. * @param startIndex the index where to start the copy in the mesh indices array
  23319. * @param indexCount the number of indices to copy then from the startIndex
  23320. * @param mesh the main mesh to create the submesh from
  23321. * @param renderingMesh the optional rendering mesh
  23322. * @returns a new submesh
  23323. */
  23324. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  23325. }
  23326. }
  23327. declare module "babylonjs/Meshes/geometry" {
  23328. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  23329. import { Scene } from "babylonjs/scene";
  23330. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  23331. import { Engine } from "babylonjs/Engines/engine";
  23332. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  23333. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  23334. import { Effect } from "babylonjs/Materials/effect";
  23335. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23336. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  23337. import { Mesh } from "babylonjs/Meshes/mesh";
  23338. /**
  23339. * Class used to store geometry data (vertex buffers + index buffer)
  23340. */
  23341. export class Geometry implements IGetSetVerticesData {
  23342. /**
  23343. * Gets or sets the ID of the geometry
  23344. */
  23345. id: string;
  23346. /**
  23347. * Gets or sets the unique ID of the geometry
  23348. */
  23349. uniqueId: number;
  23350. /**
  23351. * Gets the delay loading state of the geometry (none by default which means not delayed)
  23352. */
  23353. delayLoadState: number;
  23354. /**
  23355. * Gets the file containing the data to load when running in delay load state
  23356. */
  23357. delayLoadingFile: Nullable<string>;
  23358. /**
  23359. * Callback called when the geometry is updated
  23360. */
  23361. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  23362. private _scene;
  23363. private _engine;
  23364. private _meshes;
  23365. private _totalVertices;
  23366. /** @hidden */
  23367. _indices: IndicesArray;
  23368. /** @hidden */
  23369. _vertexBuffers: {
  23370. [key: string]: VertexBuffer;
  23371. };
  23372. private _isDisposed;
  23373. private _extend;
  23374. private _boundingBias;
  23375. /** @hidden */
  23376. _delayInfo: Array<string>;
  23377. private _indexBuffer;
  23378. private _indexBufferIsUpdatable;
  23379. /** @hidden */
  23380. _boundingInfo: Nullable<BoundingInfo>;
  23381. /** @hidden */
  23382. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  23383. /** @hidden */
  23384. _softwareSkinningFrameId: number;
  23385. private _vertexArrayObjects;
  23386. private _updatable;
  23387. /** @hidden */
  23388. _positions: Nullable<Vector3[]>;
  23389. /**
  23390. * 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
  23391. */
  23392. /**
  23393. * 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
  23394. */
  23395. boundingBias: Vector2;
  23396. /**
  23397. * Static function used to attach a new empty geometry to a mesh
  23398. * @param mesh defines the mesh to attach the geometry to
  23399. * @returns the new Geometry
  23400. */
  23401. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  23402. /**
  23403. * Creates a new geometry
  23404. * @param id defines the unique ID
  23405. * @param scene defines the hosting scene
  23406. * @param vertexData defines the VertexData used to get geometry data
  23407. * @param updatable defines if geometry must be updatable (false by default)
  23408. * @param mesh defines the mesh that will be associated with the geometry
  23409. */
  23410. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  23411. /**
  23412. * Gets the current extend of the geometry
  23413. */
  23414. readonly extend: {
  23415. minimum: Vector3;
  23416. maximum: Vector3;
  23417. };
  23418. /**
  23419. * Gets the hosting scene
  23420. * @returns the hosting Scene
  23421. */
  23422. getScene(): Scene;
  23423. /**
  23424. * Gets the hosting engine
  23425. * @returns the hosting Engine
  23426. */
  23427. getEngine(): Engine;
  23428. /**
  23429. * Defines if the geometry is ready to use
  23430. * @returns true if the geometry is ready to be used
  23431. */
  23432. isReady(): boolean;
  23433. /**
  23434. * Gets a value indicating that the geometry should not be serialized
  23435. */
  23436. readonly doNotSerialize: boolean;
  23437. /** @hidden */
  23438. _rebuild(): void;
  23439. /**
  23440. * Affects all geometry data in one call
  23441. * @param vertexData defines the geometry data
  23442. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  23443. */
  23444. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  23445. /**
  23446. * Set specific vertex data
  23447. * @param kind defines the data kind (Position, normal, etc...)
  23448. * @param data defines the vertex data to use
  23449. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23450. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23451. */
  23452. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  23453. /**
  23454. * Removes a specific vertex data
  23455. * @param kind defines the data kind (Position, normal, etc...)
  23456. */
  23457. removeVerticesData(kind: string): void;
  23458. /**
  23459. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  23460. * @param buffer defines the vertex buffer to use
  23461. * @param totalVertices defines the total number of vertices for position kind (could be null)
  23462. */
  23463. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  23464. /**
  23465. * Update a specific vertex buffer
  23466. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  23467. * It will do nothing if the buffer is not updatable
  23468. * @param kind defines the data kind (Position, normal, etc...)
  23469. * @param data defines the data to use
  23470. * @param offset defines the offset in the target buffer where to store the data
  23471. * @param useBytes set to true if the offset is in bytes
  23472. */
  23473. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  23474. /**
  23475. * Update a specific vertex buffer
  23476. * This function will create a new buffer if the current one is not updatable
  23477. * @param kind defines the data kind (Position, normal, etc...)
  23478. * @param data defines the data to use
  23479. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  23480. */
  23481. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  23482. private _updateBoundingInfo;
  23483. /** @hidden */
  23484. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  23485. /**
  23486. * Gets total number of vertices
  23487. * @returns the total number of vertices
  23488. */
  23489. getTotalVertices(): number;
  23490. /**
  23491. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23492. * @param kind defines the data kind (Position, normal, etc...)
  23493. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23494. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23495. * @returns a float array containing vertex data
  23496. */
  23497. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23498. /**
  23499. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  23500. * @param kind defines the data kind (Position, normal, etc...)
  23501. * @returns true if the vertex buffer with the specified kind is updatable
  23502. */
  23503. isVertexBufferUpdatable(kind: string): boolean;
  23504. /**
  23505. * Gets a specific vertex buffer
  23506. * @param kind defines the data kind (Position, normal, etc...)
  23507. * @returns a VertexBuffer
  23508. */
  23509. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  23510. /**
  23511. * Returns all vertex buffers
  23512. * @return an object holding all vertex buffers indexed by kind
  23513. */
  23514. getVertexBuffers(): Nullable<{
  23515. [key: string]: VertexBuffer;
  23516. }>;
  23517. /**
  23518. * Gets a boolean indicating if specific vertex buffer is present
  23519. * @param kind defines the data kind (Position, normal, etc...)
  23520. * @returns true if data is present
  23521. */
  23522. isVerticesDataPresent(kind: string): boolean;
  23523. /**
  23524. * Gets a list of all attached data kinds (Position, normal, etc...)
  23525. * @returns a list of string containing all kinds
  23526. */
  23527. getVerticesDataKinds(): string[];
  23528. /**
  23529. * Update index buffer
  23530. * @param indices defines the indices to store in the index buffer
  23531. * @param offset defines the offset in the target buffer where to store the data
  23532. * @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)
  23533. */
  23534. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  23535. /**
  23536. * Creates a new index buffer
  23537. * @param indices defines the indices to store in the index buffer
  23538. * @param totalVertices defines the total number of vertices (could be null)
  23539. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23540. */
  23541. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  23542. /**
  23543. * Return the total number of indices
  23544. * @returns the total number of indices
  23545. */
  23546. getTotalIndices(): number;
  23547. /**
  23548. * Gets the index buffer array
  23549. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23550. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23551. * @returns the index buffer array
  23552. */
  23553. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23554. /**
  23555. * Gets the index buffer
  23556. * @return the index buffer
  23557. */
  23558. getIndexBuffer(): Nullable<DataBuffer>;
  23559. /** @hidden */
  23560. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  23561. /**
  23562. * Release the associated resources for a specific mesh
  23563. * @param mesh defines the source mesh
  23564. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  23565. */
  23566. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  23567. /**
  23568. * Apply current geometry to a given mesh
  23569. * @param mesh defines the mesh to apply geometry to
  23570. */
  23571. applyToMesh(mesh: Mesh): void;
  23572. private _updateExtend;
  23573. private _applyToMesh;
  23574. private notifyUpdate;
  23575. /**
  23576. * Load the geometry if it was flagged as delay loaded
  23577. * @param scene defines the hosting scene
  23578. * @param onLoaded defines a callback called when the geometry is loaded
  23579. */
  23580. load(scene: Scene, onLoaded?: () => void): void;
  23581. private _queueLoad;
  23582. /**
  23583. * Invert the geometry to move from a right handed system to a left handed one.
  23584. */
  23585. toLeftHanded(): void;
  23586. /** @hidden */
  23587. _resetPointsArrayCache(): void;
  23588. /** @hidden */
  23589. _generatePointsArray(): boolean;
  23590. /**
  23591. * Gets a value indicating if the geometry is disposed
  23592. * @returns true if the geometry was disposed
  23593. */
  23594. isDisposed(): boolean;
  23595. private _disposeVertexArrayObjects;
  23596. /**
  23597. * Free all associated resources
  23598. */
  23599. dispose(): void;
  23600. /**
  23601. * Clone the current geometry into a new geometry
  23602. * @param id defines the unique ID of the new geometry
  23603. * @returns a new geometry object
  23604. */
  23605. copy(id: string): Geometry;
  23606. /**
  23607. * Serialize the current geometry info (and not the vertices data) into a JSON object
  23608. * @return a JSON representation of the current geometry data (without the vertices data)
  23609. */
  23610. serialize(): any;
  23611. private toNumberArray;
  23612. /**
  23613. * Serialize all vertices data into a JSON oject
  23614. * @returns a JSON representation of the current geometry data
  23615. */
  23616. serializeVerticeData(): any;
  23617. /**
  23618. * Extracts a clone of a mesh geometry
  23619. * @param mesh defines the source mesh
  23620. * @param id defines the unique ID of the new geometry object
  23621. * @returns the new geometry object
  23622. */
  23623. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  23624. /**
  23625. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  23626. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  23627. * Be aware Math.random() could cause collisions, but:
  23628. * "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"
  23629. * @returns a string containing a new GUID
  23630. */
  23631. static RandomId(): string;
  23632. /** @hidden */
  23633. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  23634. private static _CleanMatricesWeights;
  23635. /**
  23636. * Create a new geometry from persisted data (Using .babylon file format)
  23637. * @param parsedVertexData defines the persisted data
  23638. * @param scene defines the hosting scene
  23639. * @param rootUrl defines the root url to use to load assets (like delayed data)
  23640. * @returns the new geometry object
  23641. */
  23642. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  23643. }
  23644. }
  23645. declare module "babylonjs/Meshes/mesh.vertexData" {
  23646. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  23647. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  23648. import { Geometry } from "babylonjs/Meshes/geometry";
  23649. import { Mesh } from "babylonjs/Meshes/mesh";
  23650. /**
  23651. * Define an interface for all classes that will get and set the data on vertices
  23652. */
  23653. export interface IGetSetVerticesData {
  23654. /**
  23655. * Gets a boolean indicating if specific vertex data is present
  23656. * @param kind defines the vertex data kind to use
  23657. * @returns true is data kind is present
  23658. */
  23659. isVerticesDataPresent(kind: string): boolean;
  23660. /**
  23661. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23662. * @param kind defines the data kind (Position, normal, etc...)
  23663. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23664. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23665. * @returns a float array containing vertex data
  23666. */
  23667. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23668. /**
  23669. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  23670. * @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.
  23671. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23672. * @returns the indices array or an empty array if the mesh has no geometry
  23673. */
  23674. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23675. /**
  23676. * Set specific vertex data
  23677. * @param kind defines the data kind (Position, normal, etc...)
  23678. * @param data defines the vertex data to use
  23679. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23680. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23681. */
  23682. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  23683. /**
  23684. * Update a specific associated vertex buffer
  23685. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23686. * - VertexBuffer.PositionKind
  23687. * - VertexBuffer.UVKind
  23688. * - VertexBuffer.UV2Kind
  23689. * - VertexBuffer.UV3Kind
  23690. * - VertexBuffer.UV4Kind
  23691. * - VertexBuffer.UV5Kind
  23692. * - VertexBuffer.UV6Kind
  23693. * - VertexBuffer.ColorKind
  23694. * - VertexBuffer.MatricesIndicesKind
  23695. * - VertexBuffer.MatricesIndicesExtraKind
  23696. * - VertexBuffer.MatricesWeightsKind
  23697. * - VertexBuffer.MatricesWeightsExtraKind
  23698. * @param data defines the data source
  23699. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  23700. * @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)
  23701. */
  23702. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  23703. /**
  23704. * Creates a new index buffer
  23705. * @param indices defines the indices to store in the index buffer
  23706. * @param totalVertices defines the total number of vertices (could be null)
  23707. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23708. */
  23709. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  23710. }
  23711. /**
  23712. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  23713. */
  23714. export class VertexData {
  23715. /**
  23716. * Mesh side orientation : usually the external or front surface
  23717. */
  23718. static readonly FRONTSIDE: number;
  23719. /**
  23720. * Mesh side orientation : usually the internal or back surface
  23721. */
  23722. static readonly BACKSIDE: number;
  23723. /**
  23724. * Mesh side orientation : both internal and external or front and back surfaces
  23725. */
  23726. static readonly DOUBLESIDE: number;
  23727. /**
  23728. * Mesh side orientation : by default, `FRONTSIDE`
  23729. */
  23730. static readonly DEFAULTSIDE: number;
  23731. /**
  23732. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  23733. */
  23734. positions: Nullable<FloatArray>;
  23735. /**
  23736. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  23737. */
  23738. normals: Nullable<FloatArray>;
  23739. /**
  23740. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  23741. */
  23742. tangents: Nullable<FloatArray>;
  23743. /**
  23744. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23745. */
  23746. uvs: Nullable<FloatArray>;
  23747. /**
  23748. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23749. */
  23750. uvs2: Nullable<FloatArray>;
  23751. /**
  23752. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23753. */
  23754. uvs3: Nullable<FloatArray>;
  23755. /**
  23756. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23757. */
  23758. uvs4: Nullable<FloatArray>;
  23759. /**
  23760. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23761. */
  23762. uvs5: Nullable<FloatArray>;
  23763. /**
  23764. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23765. */
  23766. uvs6: Nullable<FloatArray>;
  23767. /**
  23768. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  23769. */
  23770. colors: Nullable<FloatArray>;
  23771. /**
  23772. * 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).
  23773. */
  23774. matricesIndices: Nullable<FloatArray>;
  23775. /**
  23776. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  23777. */
  23778. matricesWeights: Nullable<FloatArray>;
  23779. /**
  23780. * An array extending the number of possible indices
  23781. */
  23782. matricesIndicesExtra: Nullable<FloatArray>;
  23783. /**
  23784. * An array extending the number of possible weights when the number of indices is extended
  23785. */
  23786. matricesWeightsExtra: Nullable<FloatArray>;
  23787. /**
  23788. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  23789. */
  23790. indices: Nullable<IndicesArray>;
  23791. /**
  23792. * Uses the passed data array to set the set the values for the specified kind of data
  23793. * @param data a linear array of floating numbers
  23794. * @param kind the type of data that is being set, eg positions, colors etc
  23795. */
  23796. set(data: FloatArray, kind: string): void;
  23797. /**
  23798. * Associates the vertexData to the passed Mesh.
  23799. * Sets it as updatable or not (default `false`)
  23800. * @param mesh the mesh the vertexData is applied to
  23801. * @param updatable when used and having the value true allows new data to update the vertexData
  23802. * @returns the VertexData
  23803. */
  23804. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  23805. /**
  23806. * Associates the vertexData to the passed Geometry.
  23807. * Sets it as updatable or not (default `false`)
  23808. * @param geometry the geometry the vertexData is applied to
  23809. * @param updatable when used and having the value true allows new data to update the vertexData
  23810. * @returns VertexData
  23811. */
  23812. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  23813. /**
  23814. * Updates the associated mesh
  23815. * @param mesh the mesh to be updated
  23816. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23817. * @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
  23818. * @returns VertexData
  23819. */
  23820. updateMesh(mesh: Mesh): VertexData;
  23821. /**
  23822. * Updates the associated geometry
  23823. * @param geometry the geometry to be updated
  23824. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23825. * @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
  23826. * @returns VertexData.
  23827. */
  23828. updateGeometry(geometry: Geometry): VertexData;
  23829. private _applyTo;
  23830. private _update;
  23831. /**
  23832. * Transforms each position and each normal of the vertexData according to the passed Matrix
  23833. * @param matrix the transforming matrix
  23834. * @returns the VertexData
  23835. */
  23836. transform(matrix: Matrix): VertexData;
  23837. /**
  23838. * Merges the passed VertexData into the current one
  23839. * @param other the VertexData to be merged into the current one
  23840. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  23841. * @returns the modified VertexData
  23842. */
  23843. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  23844. private _mergeElement;
  23845. private _validate;
  23846. /**
  23847. * Serializes the VertexData
  23848. * @returns a serialized object
  23849. */
  23850. serialize(): any;
  23851. /**
  23852. * Extracts the vertexData from a mesh
  23853. * @param mesh the mesh from which to extract the VertexData
  23854. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  23855. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23856. * @returns the object VertexData associated to the passed mesh
  23857. */
  23858. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23859. /**
  23860. * Extracts the vertexData from the geometry
  23861. * @param geometry the geometry from which to extract the VertexData
  23862. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  23863. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23864. * @returns the object VertexData associated to the passed mesh
  23865. */
  23866. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23867. private static _ExtractFrom;
  23868. /**
  23869. * Creates the VertexData for a Ribbon
  23870. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  23871. * * pathArray array of paths, each of which an array of successive Vector3
  23872. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  23873. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  23874. * * 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
  23875. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23876. * * 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)
  23877. * * 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)
  23878. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  23879. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  23880. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  23881. * @returns the VertexData of the ribbon
  23882. */
  23883. static CreateRibbon(options: {
  23884. pathArray: Vector3[][];
  23885. closeArray?: boolean;
  23886. closePath?: boolean;
  23887. offset?: number;
  23888. sideOrientation?: number;
  23889. frontUVs?: Vector4;
  23890. backUVs?: Vector4;
  23891. invertUV?: boolean;
  23892. uvs?: Vector2[];
  23893. colors?: Color4[];
  23894. }): VertexData;
  23895. /**
  23896. * Creates the VertexData for a box
  23897. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23898. * * size sets the width, height and depth of the box to the value of size, optional default 1
  23899. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  23900. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  23901. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  23902. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  23903. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  23904. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23905. * * 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)
  23906. * * 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)
  23907. * @returns the VertexData of the box
  23908. */
  23909. static CreateBox(options: {
  23910. size?: number;
  23911. width?: number;
  23912. height?: number;
  23913. depth?: number;
  23914. faceUV?: Vector4[];
  23915. faceColors?: Color4[];
  23916. sideOrientation?: number;
  23917. frontUVs?: Vector4;
  23918. backUVs?: Vector4;
  23919. }): VertexData;
  23920. /**
  23921. * Creates the VertexData for an ellipsoid, defaults to a sphere
  23922. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23923. * * segments sets the number of horizontal strips optional, default 32
  23924. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  23925. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  23926. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  23927. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  23928. * * 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
  23929. * * 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
  23930. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23931. * * 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)
  23932. * * 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)
  23933. * @returns the VertexData of the ellipsoid
  23934. */
  23935. static CreateSphere(options: {
  23936. segments?: number;
  23937. diameter?: number;
  23938. diameterX?: number;
  23939. diameterY?: number;
  23940. diameterZ?: number;
  23941. arc?: number;
  23942. slice?: number;
  23943. sideOrientation?: number;
  23944. frontUVs?: Vector4;
  23945. backUVs?: Vector4;
  23946. }): VertexData;
  23947. /**
  23948. * Creates the VertexData for a cylinder, cone or prism
  23949. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23950. * * height sets the height (y direction) of the cylinder, optional, default 2
  23951. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  23952. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  23953. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  23954. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23955. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  23956. * * 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
  23957. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23958. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23959. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  23960. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  23961. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23962. * * 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)
  23963. * * 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)
  23964. * @returns the VertexData of the cylinder, cone or prism
  23965. */
  23966. static CreateCylinder(options: {
  23967. height?: number;
  23968. diameterTop?: number;
  23969. diameterBottom?: number;
  23970. diameter?: number;
  23971. tessellation?: number;
  23972. subdivisions?: number;
  23973. arc?: number;
  23974. faceColors?: Color4[];
  23975. faceUV?: Vector4[];
  23976. hasRings?: boolean;
  23977. enclose?: boolean;
  23978. sideOrientation?: number;
  23979. frontUVs?: Vector4;
  23980. backUVs?: Vector4;
  23981. }): VertexData;
  23982. /**
  23983. * Creates the VertexData for a torus
  23984. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23985. * * diameter the diameter of the torus, optional default 1
  23986. * * thickness the diameter of the tube forming the torus, optional default 0.5
  23987. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23988. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23989. * * 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)
  23990. * * 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)
  23991. * @returns the VertexData of the torus
  23992. */
  23993. static CreateTorus(options: {
  23994. diameter?: number;
  23995. thickness?: number;
  23996. tessellation?: number;
  23997. sideOrientation?: number;
  23998. frontUVs?: Vector4;
  23999. backUVs?: Vector4;
  24000. }): VertexData;
  24001. /**
  24002. * Creates the VertexData of the LineSystem
  24003. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  24004. * - lines an array of lines, each line being an array of successive Vector3
  24005. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  24006. * @returns the VertexData of the LineSystem
  24007. */
  24008. static CreateLineSystem(options: {
  24009. lines: Vector3[][];
  24010. colors?: Nullable<Color4[][]>;
  24011. }): VertexData;
  24012. /**
  24013. * Create the VertexData for a DashedLines
  24014. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  24015. * - points an array successive Vector3
  24016. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  24017. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  24018. * - dashNb the intended total number of dashes, optional, default 200
  24019. * @returns the VertexData for the DashedLines
  24020. */
  24021. static CreateDashedLines(options: {
  24022. points: Vector3[];
  24023. dashSize?: number;
  24024. gapSize?: number;
  24025. dashNb?: number;
  24026. }): VertexData;
  24027. /**
  24028. * Creates the VertexData for a Ground
  24029. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  24030. * - width the width (x direction) of the ground, optional, default 1
  24031. * - height the height (z direction) of the ground, optional, default 1
  24032. * - subdivisions the number of subdivisions per side, optional, default 1
  24033. * @returns the VertexData of the Ground
  24034. */
  24035. static CreateGround(options: {
  24036. width?: number;
  24037. height?: number;
  24038. subdivisions?: number;
  24039. subdivisionsX?: number;
  24040. subdivisionsY?: number;
  24041. }): VertexData;
  24042. /**
  24043. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  24044. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  24045. * * xmin the ground minimum X coordinate, optional, default -1
  24046. * * zmin the ground minimum Z coordinate, optional, default -1
  24047. * * xmax the ground maximum X coordinate, optional, default 1
  24048. * * zmax the ground maximum Z coordinate, optional, default 1
  24049. * * 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}
  24050. * * 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}
  24051. * @returns the VertexData of the TiledGround
  24052. */
  24053. static CreateTiledGround(options: {
  24054. xmin: number;
  24055. zmin: number;
  24056. xmax: number;
  24057. zmax: number;
  24058. subdivisions?: {
  24059. w: number;
  24060. h: number;
  24061. };
  24062. precision?: {
  24063. w: number;
  24064. h: number;
  24065. };
  24066. }): VertexData;
  24067. /**
  24068. * Creates the VertexData of the Ground designed from a heightmap
  24069. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  24070. * * width the width (x direction) of the ground
  24071. * * height the height (z direction) of the ground
  24072. * * subdivisions the number of subdivisions per side
  24073. * * minHeight the minimum altitude on the ground, optional, default 0
  24074. * * maxHeight the maximum altitude on the ground, optional default 1
  24075. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  24076. * * buffer the array holding the image color data
  24077. * * bufferWidth the width of image
  24078. * * bufferHeight the height of image
  24079. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  24080. * @returns the VertexData of the Ground designed from a heightmap
  24081. */
  24082. static CreateGroundFromHeightMap(options: {
  24083. width: number;
  24084. height: number;
  24085. subdivisions: number;
  24086. minHeight: number;
  24087. maxHeight: number;
  24088. colorFilter: Color3;
  24089. buffer: Uint8Array;
  24090. bufferWidth: number;
  24091. bufferHeight: number;
  24092. alphaFilter: number;
  24093. }): VertexData;
  24094. /**
  24095. * Creates the VertexData for a Plane
  24096. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  24097. * * size sets the width and height of the plane to the value of size, optional default 1
  24098. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  24099. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  24100. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24101. * * 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)
  24102. * * 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)
  24103. * @returns the VertexData of the box
  24104. */
  24105. static CreatePlane(options: {
  24106. size?: number;
  24107. width?: number;
  24108. height?: number;
  24109. sideOrientation?: number;
  24110. frontUVs?: Vector4;
  24111. backUVs?: Vector4;
  24112. }): VertexData;
  24113. /**
  24114. * Creates the VertexData of the Disc or regular Polygon
  24115. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  24116. * * radius the radius of the disc, optional default 0.5
  24117. * * tessellation the number of polygon sides, optional, default 64
  24118. * * 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
  24119. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24120. * * 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)
  24121. * * 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)
  24122. * @returns the VertexData of the box
  24123. */
  24124. static CreateDisc(options: {
  24125. radius?: number;
  24126. tessellation?: number;
  24127. arc?: number;
  24128. sideOrientation?: number;
  24129. frontUVs?: Vector4;
  24130. backUVs?: Vector4;
  24131. }): VertexData;
  24132. /**
  24133. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  24134. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  24135. * @param polygon a mesh built from polygonTriangulation.build()
  24136. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24137. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  24138. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  24139. * @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)
  24140. * @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)
  24141. * @returns the VertexData of the Polygon
  24142. */
  24143. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  24144. /**
  24145. * Creates the VertexData of the IcoSphere
  24146. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  24147. * * radius the radius of the IcoSphere, optional default 1
  24148. * * radiusX allows stretching in the x direction, optional, default radius
  24149. * * radiusY allows stretching in the y direction, optional, default radius
  24150. * * radiusZ allows stretching in the z direction, optional, default radius
  24151. * * flat when true creates a flat shaded mesh, optional, default true
  24152. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  24153. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24154. * * 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)
  24155. * * 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)
  24156. * @returns the VertexData of the IcoSphere
  24157. */
  24158. static CreateIcoSphere(options: {
  24159. radius?: number;
  24160. radiusX?: number;
  24161. radiusY?: number;
  24162. radiusZ?: number;
  24163. flat?: boolean;
  24164. subdivisions?: number;
  24165. sideOrientation?: number;
  24166. frontUVs?: Vector4;
  24167. backUVs?: Vector4;
  24168. }): VertexData;
  24169. /**
  24170. * Creates the VertexData for a Polyhedron
  24171. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  24172. * * type provided types are:
  24173. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  24174. * * 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)
  24175. * * size the size of the IcoSphere, optional default 1
  24176. * * sizeX allows stretching in the x direction, optional, default size
  24177. * * sizeY allows stretching in the y direction, optional, default size
  24178. * * sizeZ allows stretching in the z direction, optional, default size
  24179. * * 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
  24180. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  24181. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  24182. * * flat when true creates a flat shaded mesh, optional, default true
  24183. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  24184. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24185. * * 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)
  24186. * * 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)
  24187. * @returns the VertexData of the Polyhedron
  24188. */
  24189. static CreatePolyhedron(options: {
  24190. type?: number;
  24191. size?: number;
  24192. sizeX?: number;
  24193. sizeY?: number;
  24194. sizeZ?: number;
  24195. custom?: any;
  24196. faceUV?: Vector4[];
  24197. faceColors?: Color4[];
  24198. flat?: boolean;
  24199. sideOrientation?: number;
  24200. frontUVs?: Vector4;
  24201. backUVs?: Vector4;
  24202. }): VertexData;
  24203. /**
  24204. * Creates the VertexData for a TorusKnot
  24205. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  24206. * * radius the radius of the torus knot, optional, default 2
  24207. * * tube the thickness of the tube, optional, default 0.5
  24208. * * radialSegments the number of sides on each tube segments, optional, default 32
  24209. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  24210. * * p the number of windings around the z axis, optional, default 2
  24211. * * q the number of windings around the x axis, optional, default 3
  24212. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24213. * * 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)
  24214. * * 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)
  24215. * @returns the VertexData of the Torus Knot
  24216. */
  24217. static CreateTorusKnot(options: {
  24218. radius?: number;
  24219. tube?: number;
  24220. radialSegments?: number;
  24221. tubularSegments?: number;
  24222. p?: number;
  24223. q?: number;
  24224. sideOrientation?: number;
  24225. frontUVs?: Vector4;
  24226. backUVs?: Vector4;
  24227. }): VertexData;
  24228. /**
  24229. * Compute normals for given positions and indices
  24230. * @param positions an array of vertex positions, [...., x, y, z, ......]
  24231. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  24232. * @param normals an array of vertex normals, [...., x, y, z, ......]
  24233. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  24234. * * facetNormals : optional array of facet normals (vector3)
  24235. * * facetPositions : optional array of facet positions (vector3)
  24236. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  24237. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  24238. * * bInfo : optional bounding info, required for facetPartitioning computation
  24239. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  24240. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  24241. * * useRightHandedSystem: optional boolean to for right handed system computation
  24242. * * depthSort : optional boolean to enable the facet depth sort computation
  24243. * * distanceTo : optional Vector3 to compute the facet depth from this location
  24244. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  24245. */
  24246. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  24247. facetNormals?: any;
  24248. facetPositions?: any;
  24249. facetPartitioning?: any;
  24250. ratio?: number;
  24251. bInfo?: any;
  24252. bbSize?: Vector3;
  24253. subDiv?: any;
  24254. useRightHandedSystem?: boolean;
  24255. depthSort?: boolean;
  24256. distanceTo?: Vector3;
  24257. depthSortedFacets?: any;
  24258. }): void;
  24259. /** @hidden */
  24260. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  24261. /**
  24262. * Applies VertexData created from the imported parameters to the geometry
  24263. * @param parsedVertexData the parsed data from an imported file
  24264. * @param geometry the geometry to apply the VertexData to
  24265. */
  24266. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  24267. }
  24268. }
  24269. declare module "babylonjs/Meshes/Builders/discBuilder" {
  24270. import { Nullable } from "babylonjs/types";
  24271. import { Scene } from "babylonjs/scene";
  24272. import { Vector4 } from "babylonjs/Maths/math";
  24273. import { Mesh } from "babylonjs/Meshes/mesh";
  24274. /**
  24275. * Class containing static functions to help procedurally build meshes
  24276. */
  24277. export class DiscBuilder {
  24278. /**
  24279. * Creates a plane polygonal mesh. By default, this is a disc
  24280. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  24281. * * 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
  24282. * * 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
  24283. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24284. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  24285. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24286. * @param name defines the name of the mesh
  24287. * @param options defines the options used to create the mesh
  24288. * @param scene defines the hosting scene
  24289. * @returns the plane polygonal mesh
  24290. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  24291. */
  24292. static CreateDisc(name: string, options: {
  24293. radius?: number;
  24294. tessellation?: number;
  24295. arc?: number;
  24296. updatable?: boolean;
  24297. sideOrientation?: number;
  24298. frontUVs?: Vector4;
  24299. backUVs?: Vector4;
  24300. }, scene?: Nullable<Scene>): Mesh;
  24301. }
  24302. }
  24303. declare module "babylonjs/Particles/solidParticleSystem" {
  24304. import { Vector3 } from "babylonjs/Maths/math";
  24305. import { Mesh } from "babylonjs/Meshes/mesh";
  24306. import { Scene, IDisposable } from "babylonjs/scene";
  24307. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  24308. /**
  24309. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  24310. *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.
  24311. * The SPS is also a particle system. It provides some methods to manage the particles.
  24312. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  24313. *
  24314. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  24315. */
  24316. export class SolidParticleSystem implements IDisposable {
  24317. /**
  24318. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  24319. * Example : var p = SPS.particles[i];
  24320. */
  24321. particles: SolidParticle[];
  24322. /**
  24323. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  24324. */
  24325. nbParticles: number;
  24326. /**
  24327. * If the particles must ever face the camera (default false). Useful for planar particles.
  24328. */
  24329. billboard: boolean;
  24330. /**
  24331. * Recompute normals when adding a shape
  24332. */
  24333. recomputeNormals: boolean;
  24334. /**
  24335. * This a counter ofr your own usage. It's not set by any SPS functions.
  24336. */
  24337. counter: number;
  24338. /**
  24339. * The SPS name. This name is also given to the underlying mesh.
  24340. */
  24341. name: string;
  24342. /**
  24343. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  24344. */
  24345. mesh: Mesh;
  24346. /**
  24347. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  24348. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  24349. */
  24350. vars: any;
  24351. /**
  24352. * This array is populated when the SPS is set as 'pickable'.
  24353. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  24354. * Each element of this array is an object `{idx: int, faceId: int}`.
  24355. * `idx` is the picked particle index in the `SPS.particles` array
  24356. * `faceId` is the picked face index counted within this particle.
  24357. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  24358. */
  24359. pickedParticles: {
  24360. idx: number;
  24361. faceId: number;
  24362. }[];
  24363. /**
  24364. * This array is populated when `enableDepthSort` is set to true.
  24365. * Each element of this array is an instance of the class DepthSortedParticle.
  24366. */
  24367. depthSortedParticles: DepthSortedParticle[];
  24368. /**
  24369. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  24370. * @hidden
  24371. */
  24372. _bSphereOnly: boolean;
  24373. /**
  24374. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  24375. * @hidden
  24376. */
  24377. _bSphereRadiusFactor: number;
  24378. private _scene;
  24379. private _positions;
  24380. private _indices;
  24381. private _normals;
  24382. private _colors;
  24383. private _uvs;
  24384. private _indices32;
  24385. private _positions32;
  24386. private _normals32;
  24387. private _fixedNormal32;
  24388. private _colors32;
  24389. private _uvs32;
  24390. private _index;
  24391. private _updatable;
  24392. private _pickable;
  24393. private _isVisibilityBoxLocked;
  24394. private _alwaysVisible;
  24395. private _depthSort;
  24396. private _shapeCounter;
  24397. private _copy;
  24398. private _color;
  24399. private _computeParticleColor;
  24400. private _computeParticleTexture;
  24401. private _computeParticleRotation;
  24402. private _computeParticleVertex;
  24403. private _computeBoundingBox;
  24404. private _depthSortParticles;
  24405. private _camera;
  24406. private _mustUnrotateFixedNormals;
  24407. private _particlesIntersect;
  24408. private _needs32Bits;
  24409. /**
  24410. * Creates a SPS (Solid Particle System) object.
  24411. * @param name (String) is the SPS name, this will be the underlying mesh name.
  24412. * @param scene (Scene) is the scene in which the SPS is added.
  24413. * @param options defines the options of the sps e.g.
  24414. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  24415. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  24416. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  24417. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  24418. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  24419. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  24420. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  24421. */
  24422. constructor(name: string, scene: Scene, options?: {
  24423. updatable?: boolean;
  24424. isPickable?: boolean;
  24425. enableDepthSort?: boolean;
  24426. particleIntersection?: boolean;
  24427. boundingSphereOnly?: boolean;
  24428. bSphereRadiusFactor?: number;
  24429. });
  24430. /**
  24431. * Builds the SPS underlying mesh. Returns a standard Mesh.
  24432. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  24433. * @returns the created mesh
  24434. */
  24435. buildMesh(): Mesh;
  24436. /**
  24437. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  24438. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  24439. * Thus the particles generated from `digest()` have their property `position` set yet.
  24440. * @param mesh ( Mesh ) is the mesh to be digested
  24441. * @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
  24442. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  24443. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  24444. * @returns the current SPS
  24445. */
  24446. digest(mesh: Mesh, options?: {
  24447. facetNb?: number;
  24448. number?: number;
  24449. delta?: number;
  24450. }): SolidParticleSystem;
  24451. private _unrotateFixedNormals;
  24452. private _resetCopy;
  24453. private _meshBuilder;
  24454. private _posToShape;
  24455. private _uvsToShapeUV;
  24456. private _addParticle;
  24457. /**
  24458. * Adds some particles to the SPS from the model shape. Returns the shape id.
  24459. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  24460. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  24461. * @param nb (positive integer) the number of particles to be created from this model
  24462. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  24463. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  24464. * @returns the number of shapes in the system
  24465. */
  24466. addShape(mesh: Mesh, nb: number, options?: {
  24467. positionFunction?: any;
  24468. vertexFunction?: any;
  24469. }): number;
  24470. private _rebuildParticle;
  24471. /**
  24472. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  24473. * @returns the SPS.
  24474. */
  24475. rebuildMesh(): SolidParticleSystem;
  24476. /**
  24477. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  24478. * This method calls `updateParticle()` for each particle of the SPS.
  24479. * For an animated SPS, it is usually called within the render loop.
  24480. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  24481. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  24482. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  24483. * @returns the SPS.
  24484. */
  24485. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  24486. /**
  24487. * Disposes the SPS.
  24488. */
  24489. dispose(): void;
  24490. /**
  24491. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  24492. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24493. * @returns the SPS.
  24494. */
  24495. refreshVisibleSize(): SolidParticleSystem;
  24496. /**
  24497. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  24498. * @param size the size (float) of the visibility box
  24499. * note : this doesn't lock the SPS mesh bounding box.
  24500. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24501. */
  24502. setVisibilityBox(size: number): void;
  24503. /**
  24504. * Gets whether the SPS as always visible or not
  24505. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24506. */
  24507. /**
  24508. * Sets the SPS as always visible or not
  24509. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24510. */
  24511. isAlwaysVisible: boolean;
  24512. /**
  24513. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24514. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24515. */
  24516. /**
  24517. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24518. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24519. */
  24520. isVisibilityBoxLocked: boolean;
  24521. /**
  24522. * Tells to `setParticles()` to compute the particle rotations or not.
  24523. * Default value : true. The SPS is faster when it's set to false.
  24524. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24525. */
  24526. /**
  24527. * Gets if `setParticles()` computes the particle rotations or not.
  24528. * Default value : true. The SPS is faster when it's set to false.
  24529. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24530. */
  24531. computeParticleRotation: boolean;
  24532. /**
  24533. * Tells to `setParticles()` to compute the particle colors or not.
  24534. * Default value : true. The SPS is faster when it's set to false.
  24535. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24536. */
  24537. /**
  24538. * Gets if `setParticles()` computes the particle colors or not.
  24539. * Default value : true. The SPS is faster when it's set to false.
  24540. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24541. */
  24542. computeParticleColor: boolean;
  24543. /**
  24544. * Gets if `setParticles()` computes the particle textures or not.
  24545. * Default value : true. The SPS is faster when it's set to false.
  24546. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  24547. */
  24548. computeParticleTexture: boolean;
  24549. /**
  24550. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  24551. * Default value : false. The SPS is faster when it's set to false.
  24552. * Note : the particle custom vertex positions aren't stored values.
  24553. */
  24554. /**
  24555. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  24556. * Default value : false. The SPS is faster when it's set to false.
  24557. * Note : the particle custom vertex positions aren't stored values.
  24558. */
  24559. computeParticleVertex: boolean;
  24560. /**
  24561. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  24562. */
  24563. /**
  24564. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  24565. */
  24566. computeBoundingBox: boolean;
  24567. /**
  24568. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  24569. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24570. * Default : `true`
  24571. */
  24572. /**
  24573. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  24574. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24575. * Default : `true`
  24576. */
  24577. depthSortParticles: boolean;
  24578. /**
  24579. * This function does nothing. It may be overwritten to set all the particle first values.
  24580. * The SPS doesn't call this function, you may have to call it by your own.
  24581. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24582. */
  24583. initParticles(): void;
  24584. /**
  24585. * This function does nothing. It may be overwritten to recycle a particle.
  24586. * The SPS doesn't call this function, you may have to call it by your own.
  24587. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24588. * @param particle The particle to recycle
  24589. * @returns the recycled particle
  24590. */
  24591. recycleParticle(particle: SolidParticle): SolidParticle;
  24592. /**
  24593. * Updates a particle : this function should be overwritten by the user.
  24594. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  24595. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24596. * @example : just set a particle position or velocity and recycle conditions
  24597. * @param particle The particle to update
  24598. * @returns the updated particle
  24599. */
  24600. updateParticle(particle: SolidParticle): SolidParticle;
  24601. /**
  24602. * Updates a vertex of a particle : it can be overwritten by the user.
  24603. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  24604. * @param particle the current particle
  24605. * @param vertex the current index of the current particle
  24606. * @param pt the index of the current vertex in the particle shape
  24607. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  24608. * @example : just set a vertex particle position
  24609. * @returns the updated vertex
  24610. */
  24611. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  24612. /**
  24613. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  24614. * This does nothing and may be overwritten by the user.
  24615. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24616. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24617. * @param update the boolean update value actually passed to setParticles()
  24618. */
  24619. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24620. /**
  24621. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  24622. * This will be passed three parameters.
  24623. * This does nothing and may be overwritten by the user.
  24624. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24625. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24626. * @param update the boolean update value actually passed to setParticles()
  24627. */
  24628. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24629. }
  24630. }
  24631. declare module "babylonjs/Particles/solidParticle" {
  24632. import { Nullable } from "babylonjs/types";
  24633. import { Color4, Vector3, Matrix, Quaternion, Vector4, Plane } from "babylonjs/Maths/math";
  24634. import { Mesh } from "babylonjs/Meshes/mesh";
  24635. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24636. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  24637. /**
  24638. * Represents one particle of a solid particle system.
  24639. */
  24640. export class SolidParticle {
  24641. /**
  24642. * particle global index
  24643. */
  24644. idx: number;
  24645. /**
  24646. * The color of the particle
  24647. */
  24648. color: Nullable<Color4>;
  24649. /**
  24650. * The world space position of the particle.
  24651. */
  24652. position: Vector3;
  24653. /**
  24654. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  24655. */
  24656. rotation: Vector3;
  24657. /**
  24658. * The world space rotation quaternion of the particle.
  24659. */
  24660. rotationQuaternion: Nullable<Quaternion>;
  24661. /**
  24662. * The scaling of the particle.
  24663. */
  24664. scaling: Vector3;
  24665. /**
  24666. * The uvs of the particle.
  24667. */
  24668. uvs: Vector4;
  24669. /**
  24670. * The current speed of the particle.
  24671. */
  24672. velocity: Vector3;
  24673. /**
  24674. * The pivot point in the particle local space.
  24675. */
  24676. pivot: Vector3;
  24677. /**
  24678. * Must the particle be translated from its pivot point in its local space ?
  24679. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  24680. * Default : false
  24681. */
  24682. translateFromPivot: boolean;
  24683. /**
  24684. * Is the particle active or not ?
  24685. */
  24686. alive: boolean;
  24687. /**
  24688. * Is the particle visible or not ?
  24689. */
  24690. isVisible: boolean;
  24691. /**
  24692. * Index of this particle in the global "positions" array (Internal use)
  24693. * @hidden
  24694. */
  24695. _pos: number;
  24696. /**
  24697. * @hidden Index of this particle in the global "indices" array (Internal use)
  24698. */
  24699. _ind: number;
  24700. /**
  24701. * @hidden ModelShape of this particle (Internal use)
  24702. */
  24703. _model: ModelShape;
  24704. /**
  24705. * ModelShape id of this particle
  24706. */
  24707. shapeId: number;
  24708. /**
  24709. * Index of the particle in its shape id (Internal use)
  24710. */
  24711. idxInShape: number;
  24712. /**
  24713. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  24714. */
  24715. _modelBoundingInfo: BoundingInfo;
  24716. /**
  24717. * @hidden Particle BoundingInfo object (Internal use)
  24718. */
  24719. _boundingInfo: BoundingInfo;
  24720. /**
  24721. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  24722. */
  24723. _sps: SolidParticleSystem;
  24724. /**
  24725. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  24726. */
  24727. _stillInvisible: boolean;
  24728. /**
  24729. * @hidden Last computed particle rotation matrix
  24730. */
  24731. _rotationMatrix: number[];
  24732. /**
  24733. * Parent particle Id, if any.
  24734. * Default null.
  24735. */
  24736. parentId: Nullable<number>;
  24737. /**
  24738. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  24739. * The possible values are :
  24740. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24741. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24742. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24743. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24744. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24745. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  24746. * */
  24747. cullingStrategy: number;
  24748. /**
  24749. * @hidden Internal global position in the SPS.
  24750. */
  24751. _globalPosition: Vector3;
  24752. /**
  24753. * Creates a Solid Particle object.
  24754. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  24755. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  24756. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  24757. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  24758. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  24759. * @param shapeId (integer) is the model shape identifier in the SPS.
  24760. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  24761. * @param sps defines the sps it is associated to
  24762. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  24763. */
  24764. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  24765. /**
  24766. * Legacy support, changed scale to scaling
  24767. */
  24768. /**
  24769. * Legacy support, changed scale to scaling
  24770. */
  24771. scale: Vector3;
  24772. /**
  24773. * Legacy support, changed quaternion to rotationQuaternion
  24774. */
  24775. /**
  24776. * Legacy support, changed quaternion to rotationQuaternion
  24777. */
  24778. quaternion: Nullable<Quaternion>;
  24779. /**
  24780. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  24781. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  24782. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  24783. * @returns true if it intersects
  24784. */
  24785. intersectsMesh(target: Mesh | SolidParticle): boolean;
  24786. /**
  24787. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  24788. * A particle is in the frustum if its bounding box intersects the frustum
  24789. * @param frustumPlanes defines the frustum to test
  24790. * @returns true if the particle is in the frustum planes
  24791. */
  24792. isInFrustum(frustumPlanes: Plane[]): boolean;
  24793. /**
  24794. * get the rotation matrix of the particle
  24795. * @hidden
  24796. */
  24797. getRotationMatrix(m: Matrix): void;
  24798. }
  24799. /**
  24800. * Represents the shape of the model used by one particle of a solid particle system.
  24801. * SPS internal tool, don't use it manually.
  24802. */
  24803. export class ModelShape {
  24804. /**
  24805. * The shape id
  24806. * @hidden
  24807. */
  24808. shapeID: number;
  24809. /**
  24810. * flat array of model positions (internal use)
  24811. * @hidden
  24812. */
  24813. _shape: Vector3[];
  24814. /**
  24815. * flat array of model UVs (internal use)
  24816. * @hidden
  24817. */
  24818. _shapeUV: number[];
  24819. /**
  24820. * length of the shape in the model indices array (internal use)
  24821. * @hidden
  24822. */
  24823. _indicesLength: number;
  24824. /**
  24825. * Custom position function (internal use)
  24826. * @hidden
  24827. */
  24828. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  24829. /**
  24830. * Custom vertex function (internal use)
  24831. * @hidden
  24832. */
  24833. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  24834. /**
  24835. * 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.
  24836. * SPS internal tool, don't use it manually.
  24837. * @hidden
  24838. */
  24839. 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>);
  24840. }
  24841. /**
  24842. * Represents a Depth Sorted Particle in the solid particle system.
  24843. */
  24844. export class DepthSortedParticle {
  24845. /**
  24846. * Index of the particle in the "indices" array
  24847. */
  24848. ind: number;
  24849. /**
  24850. * Length of the particle shape in the "indices" array
  24851. */
  24852. indicesLength: number;
  24853. /**
  24854. * Squared distance from the particle to the camera
  24855. */
  24856. sqDistance: number;
  24857. }
  24858. }
  24859. declare module "babylonjs/Collisions/meshCollisionData" {
  24860. import { Collider } from "babylonjs/Collisions/collider";
  24861. import { Vector3 } from "babylonjs/Maths/math";
  24862. import { Nullable } from "babylonjs/types";
  24863. import { Observer } from "babylonjs/Misc/observable";
  24864. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24865. /**
  24866. * @hidden
  24867. */
  24868. export class _MeshCollisionData {
  24869. _checkCollisions: boolean;
  24870. _collisionMask: number;
  24871. _collisionGroup: number;
  24872. _collider: Nullable<Collider>;
  24873. _oldPositionForCollisions: Vector3;
  24874. _diffPositionForCollisions: Vector3;
  24875. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  24876. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  24877. }
  24878. }
  24879. declare module "babylonjs/Meshes/abstractMesh" {
  24880. import { Observable } from "babylonjs/Misc/observable";
  24881. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  24882. import { Camera } from "babylonjs/Cameras/camera";
  24883. import { Scene, IDisposable } from "babylonjs/scene";
  24884. import { Matrix, Vector3, Color3, Color4, Plane, Vector2 } from "babylonjs/Maths/math";
  24885. import { Node } from "babylonjs/node";
  24886. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  24887. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24888. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24889. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  24890. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24891. import { Material } from "babylonjs/Materials/material";
  24892. import { Light } from "babylonjs/Lights/light";
  24893. import { Skeleton } from "babylonjs/Bones/skeleton";
  24894. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  24895. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  24896. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  24897. import { Ray } from "babylonjs/Culling/ray";
  24898. import { Collider } from "babylonjs/Collisions/collider";
  24899. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  24900. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  24901. /**
  24902. * Class used to store all common mesh properties
  24903. */
  24904. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  24905. /** No occlusion */
  24906. static OCCLUSION_TYPE_NONE: number;
  24907. /** Occlusion set to optimisitic */
  24908. static OCCLUSION_TYPE_OPTIMISTIC: number;
  24909. /** Occlusion set to strict */
  24910. static OCCLUSION_TYPE_STRICT: number;
  24911. /** Use an accurante occlusion algorithm */
  24912. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  24913. /** Use a conservative occlusion algorithm */
  24914. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  24915. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  24916. * Test order :
  24917. * Is the bounding sphere outside the frustum ?
  24918. * If not, are the bounding box vertices outside the frustum ?
  24919. * It not, then the cullable object is in the frustum.
  24920. */
  24921. static readonly CULLINGSTRATEGY_STANDARD: number;
  24922. /** Culling strategy : Bounding Sphere Only.
  24923. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  24924. * It's also less accurate than the standard because some not visible objects can still be selected.
  24925. * Test : is the bounding sphere outside the frustum ?
  24926. * If not, then the cullable object is in the frustum.
  24927. */
  24928. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  24929. /** Culling strategy : Optimistic Inclusion.
  24930. * This in an inclusion test first, then the standard exclusion test.
  24931. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  24932. * 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.
  24933. * Anyway, it's as accurate as the standard strategy.
  24934. * Test :
  24935. * Is the cullable object bounding sphere center in the frustum ?
  24936. * If not, apply the default culling strategy.
  24937. */
  24938. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  24939. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  24940. * This in an inclusion test first, then the bounding sphere only exclusion test.
  24941. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  24942. * 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.
  24943. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  24944. * Test :
  24945. * Is the cullable object bounding sphere center in the frustum ?
  24946. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  24947. */
  24948. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  24949. /**
  24950. * No billboard
  24951. */
  24952. static readonly BILLBOARDMODE_NONE: number;
  24953. /** Billboard on X axis */
  24954. static readonly BILLBOARDMODE_X: number;
  24955. /** Billboard on Y axis */
  24956. static readonly BILLBOARDMODE_Y: number;
  24957. /** Billboard on Z axis */
  24958. static readonly BILLBOARDMODE_Z: number;
  24959. /** Billboard on all axes */
  24960. static readonly BILLBOARDMODE_ALL: number;
  24961. private _internalAbstractMeshDataInfo;
  24962. /**
  24963. * The culling strategy to use to check whether the mesh must be rendered or not.
  24964. * This value can be changed at any time and will be used on the next render mesh selection.
  24965. * The possible values are :
  24966. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24967. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24968. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24969. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24970. * Please read each static variable documentation to get details about the culling process.
  24971. * */
  24972. cullingStrategy: number;
  24973. /**
  24974. * Gets the number of facets in the mesh
  24975. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24976. */
  24977. readonly facetNb: number;
  24978. /**
  24979. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  24980. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24981. */
  24982. partitioningSubdivisions: number;
  24983. /**
  24984. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  24985. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  24986. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24987. */
  24988. partitioningBBoxRatio: number;
  24989. /**
  24990. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  24991. * Works only for updatable meshes.
  24992. * Doesn't work with multi-materials
  24993. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24994. */
  24995. mustDepthSortFacets: boolean;
  24996. /**
  24997. * The location (Vector3) where the facet depth sort must be computed from.
  24998. * By default, the active camera position.
  24999. * Used only when facet depth sort is enabled
  25000. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25001. */
  25002. facetDepthSortFrom: Vector3;
  25003. /**
  25004. * gets a boolean indicating if facetData is enabled
  25005. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25006. */
  25007. readonly isFacetDataEnabled: boolean;
  25008. /** @hidden */
  25009. _updateNonUniformScalingState(value: boolean): boolean;
  25010. /**
  25011. * An event triggered when this mesh collides with another one
  25012. */
  25013. onCollideObservable: Observable<AbstractMesh>;
  25014. /** Set a function to call when this mesh collides with another one */
  25015. onCollide: () => void;
  25016. /**
  25017. * An event triggered when the collision's position changes
  25018. */
  25019. onCollisionPositionChangeObservable: Observable<Vector3>;
  25020. /** Set a function to call when the collision's position changes */
  25021. onCollisionPositionChange: () => void;
  25022. /**
  25023. * An event triggered when material is changed
  25024. */
  25025. onMaterialChangedObservable: Observable<AbstractMesh>;
  25026. /**
  25027. * Gets or sets the orientation for POV movement & rotation
  25028. */
  25029. definedFacingForward: boolean;
  25030. /** @hidden */
  25031. _occlusionQuery: Nullable<WebGLQuery>;
  25032. /** @hidden */
  25033. _isActive: boolean;
  25034. /** @hidden */
  25035. _onlyForInstances: boolean;
  25036. /** @hidden */
  25037. _renderingGroup: Nullable<RenderingGroup>;
  25038. /**
  25039. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25040. */
  25041. /**
  25042. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25043. */
  25044. visibility: number;
  25045. /** Gets or sets the alpha index used to sort transparent meshes
  25046. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  25047. */
  25048. alphaIndex: number;
  25049. /**
  25050. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  25051. */
  25052. isVisible: boolean;
  25053. /**
  25054. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  25055. */
  25056. isPickable: boolean;
  25057. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  25058. showSubMeshesBoundingBox: boolean;
  25059. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  25060. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  25061. */
  25062. isBlocker: boolean;
  25063. /**
  25064. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  25065. */
  25066. enablePointerMoveEvents: boolean;
  25067. /**
  25068. * Specifies the rendering group id for this mesh (0 by default)
  25069. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  25070. */
  25071. renderingGroupId: number;
  25072. private _material;
  25073. /** Gets or sets current material */
  25074. material: Nullable<Material>;
  25075. /**
  25076. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  25077. * @see http://doc.babylonjs.com/babylon101/shadows
  25078. */
  25079. receiveShadows: boolean;
  25080. /** Defines color to use when rendering outline */
  25081. outlineColor: Color3;
  25082. /** Define width to use when rendering outline */
  25083. outlineWidth: number;
  25084. /** Defines color to use when rendering overlay */
  25085. overlayColor: Color3;
  25086. /** Defines alpha to use when rendering overlay */
  25087. overlayAlpha: number;
  25088. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  25089. hasVertexAlpha: boolean;
  25090. /** Gets or sets a boolean indicating that this mesh needs to use vertex color data to render (if this kind of vertex data is available in the geometry) */
  25091. useVertexColors: boolean;
  25092. /**
  25093. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  25094. */
  25095. computeBonesUsingShaders: boolean;
  25096. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  25097. numBoneInfluencers: number;
  25098. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  25099. applyFog: boolean;
  25100. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  25101. useOctreeForRenderingSelection: boolean;
  25102. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  25103. useOctreeForPicking: boolean;
  25104. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  25105. useOctreeForCollisions: boolean;
  25106. /**
  25107. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  25108. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  25109. */
  25110. layerMask: number;
  25111. /**
  25112. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  25113. */
  25114. alwaysSelectAsActiveMesh: boolean;
  25115. /**
  25116. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  25117. */
  25118. doNotSyncBoundingInfo: boolean;
  25119. /**
  25120. * Gets or sets the current action manager
  25121. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25122. */
  25123. actionManager: Nullable<AbstractActionManager>;
  25124. private _meshCollisionData;
  25125. /**
  25126. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  25127. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25128. */
  25129. ellipsoid: Vector3;
  25130. /**
  25131. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  25132. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25133. */
  25134. ellipsoidOffset: Vector3;
  25135. /**
  25136. * Gets or sets a collision mask used to mask collisions (default is -1).
  25137. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25138. */
  25139. collisionMask: number;
  25140. /**
  25141. * Gets or sets the current collision group mask (-1 by default).
  25142. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25143. */
  25144. collisionGroup: number;
  25145. /**
  25146. * Defines edge width used when edgesRenderer is enabled
  25147. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25148. */
  25149. edgesWidth: number;
  25150. /**
  25151. * Defines edge color used when edgesRenderer is enabled
  25152. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25153. */
  25154. edgesColor: Color4;
  25155. /** @hidden */
  25156. _edgesRenderer: Nullable<IEdgesRenderer>;
  25157. /** @hidden */
  25158. _masterMesh: Nullable<AbstractMesh>;
  25159. /** @hidden */
  25160. _boundingInfo: Nullable<BoundingInfo>;
  25161. /** @hidden */
  25162. _renderId: number;
  25163. /**
  25164. * Gets or sets the list of subMeshes
  25165. * @see http://doc.babylonjs.com/how_to/multi_materials
  25166. */
  25167. subMeshes: SubMesh[];
  25168. /** @hidden */
  25169. _intersectionsInProgress: AbstractMesh[];
  25170. /** @hidden */
  25171. _unIndexed: boolean;
  25172. /** @hidden */
  25173. _lightSources: Light[];
  25174. /** Gets the list of lights affecting that mesh */
  25175. readonly lightSources: Light[];
  25176. /** @hidden */
  25177. readonly _positions: Nullable<Vector3[]>;
  25178. /** @hidden */
  25179. _waitingData: {
  25180. lods: Nullable<any>;
  25181. actions: Nullable<any>;
  25182. freezeWorldMatrix: Nullable<boolean>;
  25183. };
  25184. /** @hidden */
  25185. _bonesTransformMatrices: Nullable<Float32Array>;
  25186. /**
  25187. * Gets or sets a skeleton to apply skining transformations
  25188. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  25189. */
  25190. skeleton: Nullable<Skeleton>;
  25191. /**
  25192. * An event triggered when the mesh is rebuilt.
  25193. */
  25194. onRebuildObservable: Observable<AbstractMesh>;
  25195. /**
  25196. * Creates a new AbstractMesh
  25197. * @param name defines the name of the mesh
  25198. * @param scene defines the hosting scene
  25199. */
  25200. constructor(name: string, scene?: Nullable<Scene>);
  25201. /**
  25202. * Returns the string "AbstractMesh"
  25203. * @returns "AbstractMesh"
  25204. */
  25205. getClassName(): string;
  25206. /**
  25207. * Gets a string representation of the current mesh
  25208. * @param fullDetails defines a boolean indicating if full details must be included
  25209. * @returns a string representation of the current mesh
  25210. */
  25211. toString(fullDetails?: boolean): string;
  25212. /**
  25213. * @hidden
  25214. */
  25215. protected _getEffectiveParent(): Nullable<Node>;
  25216. /** @hidden */
  25217. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  25218. /** @hidden */
  25219. _rebuild(): void;
  25220. /** @hidden */
  25221. _resyncLightSources(): void;
  25222. /** @hidden */
  25223. _resyncLighSource(light: Light): void;
  25224. /** @hidden */
  25225. _unBindEffect(): void;
  25226. /** @hidden */
  25227. _removeLightSource(light: Light): void;
  25228. private _markSubMeshesAsDirty;
  25229. /** @hidden */
  25230. _markSubMeshesAsLightDirty(): void;
  25231. /** @hidden */
  25232. _markSubMeshesAsAttributesDirty(): void;
  25233. /** @hidden */
  25234. _markSubMeshesAsMiscDirty(): void;
  25235. /**
  25236. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  25237. */
  25238. scaling: Vector3;
  25239. /**
  25240. * Returns true if the mesh is blocked. Implemented by child classes
  25241. */
  25242. readonly isBlocked: boolean;
  25243. /**
  25244. * Returns the mesh itself by default. Implemented by child classes
  25245. * @param camera defines the camera to use to pick the right LOD level
  25246. * @returns the currentAbstractMesh
  25247. */
  25248. getLOD(camera: Camera): Nullable<AbstractMesh>;
  25249. /**
  25250. * Returns 0 by default. Implemented by child classes
  25251. * @returns an integer
  25252. */
  25253. getTotalVertices(): number;
  25254. /**
  25255. * Returns a positive integer : the total number of indices in this mesh geometry.
  25256. * @returns the numner of indices or zero if the mesh has no geometry.
  25257. */
  25258. getTotalIndices(): number;
  25259. /**
  25260. * Returns null by default. Implemented by child classes
  25261. * @returns null
  25262. */
  25263. getIndices(): Nullable<IndicesArray>;
  25264. /**
  25265. * Returns the array of the requested vertex data kind. Implemented by child classes
  25266. * @param kind defines the vertex data kind to use
  25267. * @returns null
  25268. */
  25269. getVerticesData(kind: string): Nullable<FloatArray>;
  25270. /**
  25271. * Sets the vertex data of the mesh geometry for the requested `kind`.
  25272. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  25273. * Note that a new underlying VertexBuffer object is created each call.
  25274. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  25275. * @param kind defines vertex data kind:
  25276. * * VertexBuffer.PositionKind
  25277. * * VertexBuffer.UVKind
  25278. * * VertexBuffer.UV2Kind
  25279. * * VertexBuffer.UV3Kind
  25280. * * VertexBuffer.UV4Kind
  25281. * * VertexBuffer.UV5Kind
  25282. * * VertexBuffer.UV6Kind
  25283. * * VertexBuffer.ColorKind
  25284. * * VertexBuffer.MatricesIndicesKind
  25285. * * VertexBuffer.MatricesIndicesExtraKind
  25286. * * VertexBuffer.MatricesWeightsKind
  25287. * * VertexBuffer.MatricesWeightsExtraKind
  25288. * @param data defines the data source
  25289. * @param updatable defines if the data must be flagged as updatable (or static)
  25290. * @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
  25291. * @returns the current mesh
  25292. */
  25293. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25294. /**
  25295. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  25296. * If the mesh has no geometry, it is simply returned as it is.
  25297. * @param kind defines vertex data kind:
  25298. * * VertexBuffer.PositionKind
  25299. * * VertexBuffer.UVKind
  25300. * * VertexBuffer.UV2Kind
  25301. * * VertexBuffer.UV3Kind
  25302. * * VertexBuffer.UV4Kind
  25303. * * VertexBuffer.UV5Kind
  25304. * * VertexBuffer.UV6Kind
  25305. * * VertexBuffer.ColorKind
  25306. * * VertexBuffer.MatricesIndicesKind
  25307. * * VertexBuffer.MatricesIndicesExtraKind
  25308. * * VertexBuffer.MatricesWeightsKind
  25309. * * VertexBuffer.MatricesWeightsExtraKind
  25310. * @param data defines the data source
  25311. * @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
  25312. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  25313. * @returns the current mesh
  25314. */
  25315. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25316. /**
  25317. * Sets the mesh indices,
  25318. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  25319. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  25320. * @param totalVertices Defines the total number of vertices
  25321. * @returns the current mesh
  25322. */
  25323. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  25324. /**
  25325. * Gets a boolean indicating if specific vertex data is present
  25326. * @param kind defines the vertex data kind to use
  25327. * @returns true is data kind is present
  25328. */
  25329. isVerticesDataPresent(kind: string): boolean;
  25330. /**
  25331. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  25332. * @returns a BoundingInfo
  25333. */
  25334. getBoundingInfo(): BoundingInfo;
  25335. /**
  25336. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  25337. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  25338. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  25339. * @returns the current mesh
  25340. */
  25341. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean): AbstractMesh;
  25342. /**
  25343. * Overwrite the current bounding info
  25344. * @param boundingInfo defines the new bounding info
  25345. * @returns the current mesh
  25346. */
  25347. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  25348. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  25349. readonly useBones: boolean;
  25350. /** @hidden */
  25351. _preActivate(): void;
  25352. /** @hidden */
  25353. _preActivateForIntermediateRendering(renderId: number): void;
  25354. /** @hidden */
  25355. _activate(renderId: number): boolean;
  25356. /** @hidden */
  25357. _postActivate(): void;
  25358. /** @hidden */
  25359. _freeze(): void;
  25360. /** @hidden */
  25361. _unFreeze(): void;
  25362. /**
  25363. * Gets the current world matrix
  25364. * @returns a Matrix
  25365. */
  25366. getWorldMatrix(): Matrix;
  25367. /** @hidden */
  25368. _getWorldMatrixDeterminant(): number;
  25369. /**
  25370. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  25371. */
  25372. readonly isAnInstance: boolean;
  25373. /**
  25374. * Perform relative position change from the point of view of behind the front of the mesh.
  25375. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25376. * Supports definition of mesh facing forward or backward
  25377. * @param amountRight defines the distance on the right axis
  25378. * @param amountUp defines the distance on the up axis
  25379. * @param amountForward defines the distance on the forward axis
  25380. * @returns the current mesh
  25381. */
  25382. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  25383. /**
  25384. * Calculate relative position change from the point of view of behind the front of the mesh.
  25385. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25386. * Supports definition of mesh facing forward or backward
  25387. * @param amountRight defines the distance on the right axis
  25388. * @param amountUp defines the distance on the up axis
  25389. * @param amountForward defines the distance on the forward axis
  25390. * @returns the new displacement vector
  25391. */
  25392. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  25393. /**
  25394. * Perform relative rotation change from the point of view of behind the front of the mesh.
  25395. * Supports definition of mesh facing forward or backward
  25396. * @param flipBack defines the flip
  25397. * @param twirlClockwise defines the twirl
  25398. * @param tiltRight defines the tilt
  25399. * @returns the current mesh
  25400. */
  25401. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  25402. /**
  25403. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  25404. * Supports definition of mesh facing forward or backward.
  25405. * @param flipBack defines the flip
  25406. * @param twirlClockwise defines the twirl
  25407. * @param tiltRight defines the tilt
  25408. * @returns the new rotation vector
  25409. */
  25410. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  25411. /**
  25412. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  25413. * This means the mesh underlying bounding box and sphere are recomputed.
  25414. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  25415. * @returns the current mesh
  25416. */
  25417. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  25418. /** @hidden */
  25419. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  25420. /** @hidden */
  25421. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  25422. /** @hidden */
  25423. _updateBoundingInfo(): AbstractMesh;
  25424. /** @hidden */
  25425. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  25426. /** @hidden */
  25427. protected _afterComputeWorldMatrix(): void;
  25428. /** @hidden */
  25429. readonly _effectiveMesh: AbstractMesh;
  25430. /**
  25431. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25432. * A mesh is in the frustum if its bounding box intersects the frustum
  25433. * @param frustumPlanes defines the frustum to test
  25434. * @returns true if the mesh is in the frustum planes
  25435. */
  25436. isInFrustum(frustumPlanes: Plane[]): boolean;
  25437. /**
  25438. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  25439. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  25440. * @param frustumPlanes defines the frustum to test
  25441. * @returns true if the mesh is completely in the frustum planes
  25442. */
  25443. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  25444. /**
  25445. * True if the mesh intersects another mesh or a SolidParticle object
  25446. * @param mesh defines a target mesh or SolidParticle to test
  25447. * @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)
  25448. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  25449. * @returns true if there is an intersection
  25450. */
  25451. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  25452. /**
  25453. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  25454. * @param point defines the point to test
  25455. * @returns true if there is an intersection
  25456. */
  25457. intersectsPoint(point: Vector3): boolean;
  25458. /**
  25459. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  25460. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25461. */
  25462. checkCollisions: boolean;
  25463. /**
  25464. * Gets Collider object used to compute collisions (not physics)
  25465. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25466. */
  25467. readonly collider: Nullable<Collider>;
  25468. /**
  25469. * Move the mesh using collision engine
  25470. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25471. * @param displacement defines the requested displacement vector
  25472. * @returns the current mesh
  25473. */
  25474. moveWithCollisions(displacement: Vector3): AbstractMesh;
  25475. private _onCollisionPositionChange;
  25476. /** @hidden */
  25477. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  25478. /** @hidden */
  25479. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  25480. /** @hidden */
  25481. _checkCollision(collider: Collider): AbstractMesh;
  25482. /** @hidden */
  25483. _generatePointsArray(): boolean;
  25484. /**
  25485. * Checks if the passed Ray intersects with the mesh
  25486. * @param ray defines the ray to use
  25487. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  25488. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  25489. * @returns the picking info
  25490. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  25491. */
  25492. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  25493. /**
  25494. * Clones the current mesh
  25495. * @param name defines the mesh name
  25496. * @param newParent defines the new mesh parent
  25497. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  25498. * @returns the new mesh
  25499. */
  25500. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  25501. /**
  25502. * Disposes all the submeshes of the current meshnp
  25503. * @returns the current mesh
  25504. */
  25505. releaseSubMeshes(): AbstractMesh;
  25506. /**
  25507. * Releases resources associated with this abstract mesh.
  25508. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25509. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25510. */
  25511. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25512. /**
  25513. * Adds the passed mesh as a child to the current mesh
  25514. * @param mesh defines the child mesh
  25515. * @returns the current mesh
  25516. */
  25517. addChild(mesh: AbstractMesh): AbstractMesh;
  25518. /**
  25519. * Removes the passed mesh from the current mesh children list
  25520. * @param mesh defines the child mesh
  25521. * @returns the current mesh
  25522. */
  25523. removeChild(mesh: AbstractMesh): AbstractMesh;
  25524. /** @hidden */
  25525. private _initFacetData;
  25526. /**
  25527. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  25528. * This method can be called within the render loop.
  25529. * 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
  25530. * @returns the current mesh
  25531. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25532. */
  25533. updateFacetData(): AbstractMesh;
  25534. /**
  25535. * Returns the facetLocalNormals array.
  25536. * The normals are expressed in the mesh local spac
  25537. * @returns an array of Vector3
  25538. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25539. */
  25540. getFacetLocalNormals(): Vector3[];
  25541. /**
  25542. * Returns the facetLocalPositions array.
  25543. * The facet positions are expressed in the mesh local space
  25544. * @returns an array of Vector3
  25545. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25546. */
  25547. getFacetLocalPositions(): Vector3[];
  25548. /**
  25549. * Returns the facetLocalPartioning array
  25550. * @returns an array of array of numbers
  25551. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25552. */
  25553. getFacetLocalPartitioning(): number[][];
  25554. /**
  25555. * Returns the i-th facet position in the world system.
  25556. * This method allocates a new Vector3 per call
  25557. * @param i defines the facet index
  25558. * @returns a new Vector3
  25559. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25560. */
  25561. getFacetPosition(i: number): Vector3;
  25562. /**
  25563. * Sets the reference Vector3 with the i-th facet position in the world system
  25564. * @param i defines the facet index
  25565. * @param ref defines the target vector
  25566. * @returns the current mesh
  25567. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25568. */
  25569. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  25570. /**
  25571. * Returns the i-th facet normal in the world system.
  25572. * This method allocates a new Vector3 per call
  25573. * @param i defines the facet index
  25574. * @returns a new Vector3
  25575. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25576. */
  25577. getFacetNormal(i: number): Vector3;
  25578. /**
  25579. * Sets the reference Vector3 with the i-th facet normal in the world system
  25580. * @param i defines the facet index
  25581. * @param ref defines the target vector
  25582. * @returns the current mesh
  25583. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25584. */
  25585. getFacetNormalToRef(i: number, ref: Vector3): this;
  25586. /**
  25587. * 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)
  25588. * @param x defines x coordinate
  25589. * @param y defines y coordinate
  25590. * @param z defines z coordinate
  25591. * @returns the array of facet indexes
  25592. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25593. */
  25594. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  25595. /**
  25596. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  25597. * @param projected sets as the (x,y,z) world projection on the facet
  25598. * @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
  25599. * @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
  25600. * @param x defines x coordinate
  25601. * @param y defines y coordinate
  25602. * @param z defines z coordinate
  25603. * @returns the face index if found (or null instead)
  25604. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25605. */
  25606. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25607. /**
  25608. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  25609. * @param projected sets as the (x,y,z) local projection on the facet
  25610. * @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
  25611. * @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
  25612. * @param x defines x coordinate
  25613. * @param y defines y coordinate
  25614. * @param z defines z coordinate
  25615. * @returns the face index if found (or null instead)
  25616. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25617. */
  25618. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25619. /**
  25620. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  25621. * @returns the parameters
  25622. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25623. */
  25624. getFacetDataParameters(): any;
  25625. /**
  25626. * Disables the feature FacetData and frees the related memory
  25627. * @returns the current mesh
  25628. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25629. */
  25630. disableFacetData(): AbstractMesh;
  25631. /**
  25632. * Updates the AbstractMesh indices array
  25633. * @param indices defines the data source
  25634. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25635. * @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)
  25636. * @returns the current mesh
  25637. */
  25638. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25639. /**
  25640. * Creates new normals data for the mesh
  25641. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  25642. * @returns the current mesh
  25643. */
  25644. createNormals(updatable: boolean): AbstractMesh;
  25645. /**
  25646. * Align the mesh with a normal
  25647. * @param normal defines the normal to use
  25648. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  25649. * @returns the current mesh
  25650. */
  25651. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  25652. /** @hidden */
  25653. _checkOcclusionQuery(): boolean;
  25654. /**
  25655. * Disables the mesh edge rendering mode
  25656. * @returns the currentAbstractMesh
  25657. */
  25658. disableEdgesRendering(): AbstractMesh;
  25659. /**
  25660. * Enables the edge rendering mode on the mesh.
  25661. * This mode makes the mesh edges visible
  25662. * @param epsilon defines the maximal distance between two angles to detect a face
  25663. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  25664. * @returns the currentAbstractMesh
  25665. * @see https://www.babylonjs-playground.com/#19O9TU#0
  25666. */
  25667. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  25668. }
  25669. }
  25670. declare module "babylonjs/Actions/actionEvent" {
  25671. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25672. import { Nullable } from "babylonjs/types";
  25673. import { Sprite } from "babylonjs/Sprites/sprite";
  25674. import { Scene } from "babylonjs/scene";
  25675. import { Vector2 } from "babylonjs/Maths/math";
  25676. /**
  25677. * Interface used to define ActionEvent
  25678. */
  25679. export interface IActionEvent {
  25680. /** The mesh or sprite that triggered the action */
  25681. source: any;
  25682. /** The X mouse cursor position at the time of the event */
  25683. pointerX: number;
  25684. /** The Y mouse cursor position at the time of the event */
  25685. pointerY: number;
  25686. /** The mesh that is currently pointed at (can be null) */
  25687. meshUnderPointer: Nullable<AbstractMesh>;
  25688. /** the original (browser) event that triggered the ActionEvent */
  25689. sourceEvent?: any;
  25690. /** additional data for the event */
  25691. additionalData?: any;
  25692. }
  25693. /**
  25694. * ActionEvent is the event being sent when an action is triggered.
  25695. */
  25696. export class ActionEvent implements IActionEvent {
  25697. /** The mesh or sprite that triggered the action */
  25698. source: any;
  25699. /** The X mouse cursor position at the time of the event */
  25700. pointerX: number;
  25701. /** The Y mouse cursor position at the time of the event */
  25702. pointerY: number;
  25703. /** The mesh that is currently pointed at (can be null) */
  25704. meshUnderPointer: Nullable<AbstractMesh>;
  25705. /** the original (browser) event that triggered the ActionEvent */
  25706. sourceEvent?: any;
  25707. /** additional data for the event */
  25708. additionalData?: any;
  25709. /**
  25710. * Creates a new ActionEvent
  25711. * @param source The mesh or sprite that triggered the action
  25712. * @param pointerX The X mouse cursor position at the time of the event
  25713. * @param pointerY The Y mouse cursor position at the time of the event
  25714. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  25715. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  25716. * @param additionalData additional data for the event
  25717. */
  25718. constructor(
  25719. /** The mesh or sprite that triggered the action */
  25720. source: any,
  25721. /** The X mouse cursor position at the time of the event */
  25722. pointerX: number,
  25723. /** The Y mouse cursor position at the time of the event */
  25724. pointerY: number,
  25725. /** The mesh that is currently pointed at (can be null) */
  25726. meshUnderPointer: Nullable<AbstractMesh>,
  25727. /** the original (browser) event that triggered the ActionEvent */
  25728. sourceEvent?: any,
  25729. /** additional data for the event */
  25730. additionalData?: any);
  25731. /**
  25732. * Helper function to auto-create an ActionEvent from a source mesh.
  25733. * @param source The source mesh that triggered the event
  25734. * @param evt The original (browser) event
  25735. * @param additionalData additional data for the event
  25736. * @returns the new ActionEvent
  25737. */
  25738. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  25739. /**
  25740. * Helper function to auto-create an ActionEvent from a source sprite
  25741. * @param source The source sprite that triggered the event
  25742. * @param scene Scene associated with the sprite
  25743. * @param evt The original (browser) event
  25744. * @param additionalData additional data for the event
  25745. * @returns the new ActionEvent
  25746. */
  25747. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  25748. /**
  25749. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  25750. * @param scene the scene where the event occurred
  25751. * @param evt The original (browser) event
  25752. * @returns the new ActionEvent
  25753. */
  25754. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  25755. /**
  25756. * Helper function to auto-create an ActionEvent from a primitive
  25757. * @param prim defines the target primitive
  25758. * @param pointerPos defines the pointer position
  25759. * @param evt The original (browser) event
  25760. * @param additionalData additional data for the event
  25761. * @returns the new ActionEvent
  25762. */
  25763. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  25764. }
  25765. }
  25766. declare module "babylonjs/Actions/abstractActionManager" {
  25767. import { IDisposable } from "babylonjs/scene";
  25768. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  25769. import { IAction } from "babylonjs/Actions/action";
  25770. import { Nullable } from "babylonjs/types";
  25771. /**
  25772. * Abstract class used to decouple action Manager from scene and meshes.
  25773. * Do not instantiate.
  25774. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25775. */
  25776. export abstract class AbstractActionManager implements IDisposable {
  25777. /** Gets the list of active triggers */
  25778. static Triggers: {
  25779. [key: string]: number;
  25780. };
  25781. /** Gets the cursor to use when hovering items */
  25782. hoverCursor: string;
  25783. /** Gets the list of actions */
  25784. actions: IAction[];
  25785. /**
  25786. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  25787. */
  25788. isRecursive: boolean;
  25789. /**
  25790. * Releases all associated resources
  25791. */
  25792. abstract dispose(): void;
  25793. /**
  25794. * Does this action manager has pointer triggers
  25795. */
  25796. abstract readonly hasPointerTriggers: boolean;
  25797. /**
  25798. * Does this action manager has pick triggers
  25799. */
  25800. abstract readonly hasPickTriggers: boolean;
  25801. /**
  25802. * Process a specific trigger
  25803. * @param trigger defines the trigger to process
  25804. * @param evt defines the event details to be processed
  25805. */
  25806. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  25807. /**
  25808. * Does this action manager handles actions of any of the given triggers
  25809. * @param triggers defines the triggers to be tested
  25810. * @return a boolean indicating whether one (or more) of the triggers is handled
  25811. */
  25812. abstract hasSpecificTriggers(triggers: number[]): boolean;
  25813. /**
  25814. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  25815. * speed.
  25816. * @param triggerA defines the trigger to be tested
  25817. * @param triggerB defines the trigger to be tested
  25818. * @return a boolean indicating whether one (or more) of the triggers is handled
  25819. */
  25820. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  25821. /**
  25822. * Does this action manager handles actions of a given trigger
  25823. * @param trigger defines the trigger to be tested
  25824. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  25825. * @return whether the trigger is handled
  25826. */
  25827. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  25828. /**
  25829. * Serialize this manager to a JSON object
  25830. * @param name defines the property name to store this manager
  25831. * @returns a JSON representation of this manager
  25832. */
  25833. abstract serialize(name: string): any;
  25834. /**
  25835. * Registers an action to this action manager
  25836. * @param action defines the action to be registered
  25837. * @return the action amended (prepared) after registration
  25838. */
  25839. abstract registerAction(action: IAction): Nullable<IAction>;
  25840. /**
  25841. * Unregisters an action to this action manager
  25842. * @param action defines the action to be unregistered
  25843. * @return a boolean indicating whether the action has been unregistered
  25844. */
  25845. abstract unregisterAction(action: IAction): Boolean;
  25846. /**
  25847. * Does exist one action manager with at least one trigger
  25848. **/
  25849. static readonly HasTriggers: boolean;
  25850. /**
  25851. * Does exist one action manager with at least one pick trigger
  25852. **/
  25853. static readonly HasPickTriggers: boolean;
  25854. /**
  25855. * Does exist one action manager that handles actions of a given trigger
  25856. * @param trigger defines the trigger to be tested
  25857. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  25858. **/
  25859. static HasSpecificTrigger(trigger: number): boolean;
  25860. }
  25861. }
  25862. declare module "babylonjs/node" {
  25863. import { Scene } from "babylonjs/scene";
  25864. import { Nullable } from "babylonjs/types";
  25865. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  25866. import { Engine } from "babylonjs/Engines/engine";
  25867. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  25868. import { Observable } from "babylonjs/Misc/observable";
  25869. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  25870. import { IInspectable } from "babylonjs/Misc/iInspectable";
  25871. import { Animatable } from "babylonjs/Animations/animatable";
  25872. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  25873. import { Animation } from "babylonjs/Animations/animation";
  25874. import { AnimationRange } from "babylonjs/Animations/animationRange";
  25875. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25876. /**
  25877. * Defines how a node can be built from a string name.
  25878. */
  25879. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  25880. /**
  25881. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  25882. */
  25883. export class Node implements IBehaviorAware<Node> {
  25884. /** @hidden */
  25885. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  25886. private static _NodeConstructors;
  25887. /**
  25888. * Add a new node constructor
  25889. * @param type defines the type name of the node to construct
  25890. * @param constructorFunc defines the constructor function
  25891. */
  25892. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  25893. /**
  25894. * Returns a node constructor based on type name
  25895. * @param type defines the type name
  25896. * @param name defines the new node name
  25897. * @param scene defines the hosting scene
  25898. * @param options defines optional options to transmit to constructors
  25899. * @returns the new constructor or null
  25900. */
  25901. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  25902. /**
  25903. * Gets or sets the name of the node
  25904. */
  25905. name: string;
  25906. /**
  25907. * Gets or sets the id of the node
  25908. */
  25909. id: string;
  25910. /**
  25911. * Gets or sets the unique id of the node
  25912. */
  25913. uniqueId: number;
  25914. /**
  25915. * Gets or sets a string used to store user defined state for the node
  25916. */
  25917. state: string;
  25918. /**
  25919. * Gets or sets an object used to store user defined information for the node
  25920. */
  25921. metadata: any;
  25922. /**
  25923. * For internal use only. Please do not use.
  25924. */
  25925. reservedDataStore: any;
  25926. /**
  25927. * List of inspectable custom properties (used by the Inspector)
  25928. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  25929. */
  25930. inspectableCustomProperties: IInspectable[];
  25931. /**
  25932. * Gets or sets a boolean used to define if the node must be serialized
  25933. */
  25934. doNotSerialize: boolean;
  25935. /** @hidden */
  25936. _isDisposed: boolean;
  25937. /**
  25938. * Gets a list of Animations associated with the node
  25939. */
  25940. animations: import("babylonjs/Animations/animation").Animation[];
  25941. protected _ranges: {
  25942. [name: string]: Nullable<AnimationRange>;
  25943. };
  25944. /**
  25945. * Callback raised when the node is ready to be used
  25946. */
  25947. onReady: Nullable<(node: Node) => void>;
  25948. private _isEnabled;
  25949. private _isParentEnabled;
  25950. private _isReady;
  25951. /** @hidden */
  25952. _currentRenderId: number;
  25953. private _parentUpdateId;
  25954. /** @hidden */
  25955. _childUpdateId: number;
  25956. /** @hidden */
  25957. _waitingParentId: Nullable<string>;
  25958. /** @hidden */
  25959. _scene: Scene;
  25960. /** @hidden */
  25961. _cache: any;
  25962. private _parentNode;
  25963. private _children;
  25964. /** @hidden */
  25965. _worldMatrix: Matrix;
  25966. /** @hidden */
  25967. _worldMatrixDeterminant: number;
  25968. /** @hidden */
  25969. _worldMatrixDeterminantIsDirty: boolean;
  25970. /** @hidden */
  25971. private _sceneRootNodesIndex;
  25972. /**
  25973. * Gets a boolean indicating if the node has been disposed
  25974. * @returns true if the node was disposed
  25975. */
  25976. isDisposed(): boolean;
  25977. /**
  25978. * Gets or sets the parent of the node (without keeping the current position in the scene)
  25979. * @see https://doc.babylonjs.com/how_to/parenting
  25980. */
  25981. parent: Nullable<Node>;
  25982. private addToSceneRootNodes;
  25983. private removeFromSceneRootNodes;
  25984. private _animationPropertiesOverride;
  25985. /**
  25986. * Gets or sets the animation properties override
  25987. */
  25988. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  25989. /**
  25990. * Gets a string idenfifying the name of the class
  25991. * @returns "Node" string
  25992. */
  25993. getClassName(): string;
  25994. /** @hidden */
  25995. readonly _isNode: boolean;
  25996. /**
  25997. * An event triggered when the mesh is disposed
  25998. */
  25999. onDisposeObservable: Observable<Node>;
  26000. private _onDisposeObserver;
  26001. /**
  26002. * Sets a callback that will be raised when the node will be disposed
  26003. */
  26004. onDispose: () => void;
  26005. /**
  26006. * Creates a new Node
  26007. * @param name the name and id to be given to this node
  26008. * @param scene the scene this node will be added to
  26009. * @param addToRootNodes the node will be added to scene.rootNodes
  26010. */
  26011. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  26012. /**
  26013. * Gets the scene of the node
  26014. * @returns a scene
  26015. */
  26016. getScene(): Scene;
  26017. /**
  26018. * Gets the engine of the node
  26019. * @returns a Engine
  26020. */
  26021. getEngine(): Engine;
  26022. private _behaviors;
  26023. /**
  26024. * Attach a behavior to the node
  26025. * @see http://doc.babylonjs.com/features/behaviour
  26026. * @param behavior defines the behavior to attach
  26027. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  26028. * @returns the current Node
  26029. */
  26030. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  26031. /**
  26032. * Remove an attached behavior
  26033. * @see http://doc.babylonjs.com/features/behaviour
  26034. * @param behavior defines the behavior to attach
  26035. * @returns the current Node
  26036. */
  26037. removeBehavior(behavior: Behavior<Node>): Node;
  26038. /**
  26039. * Gets the list of attached behaviors
  26040. * @see http://doc.babylonjs.com/features/behaviour
  26041. */
  26042. readonly behaviors: Behavior<Node>[];
  26043. /**
  26044. * Gets an attached behavior by name
  26045. * @param name defines the name of the behavior to look for
  26046. * @see http://doc.babylonjs.com/features/behaviour
  26047. * @returns null if behavior was not found else the requested behavior
  26048. */
  26049. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  26050. /**
  26051. * Returns the latest update of the World matrix
  26052. * @returns a Matrix
  26053. */
  26054. getWorldMatrix(): Matrix;
  26055. /** @hidden */
  26056. _getWorldMatrixDeterminant(): number;
  26057. /**
  26058. * Returns directly the latest state of the mesh World matrix.
  26059. * A Matrix is returned.
  26060. */
  26061. readonly worldMatrixFromCache: Matrix;
  26062. /** @hidden */
  26063. _initCache(): void;
  26064. /** @hidden */
  26065. updateCache(force?: boolean): void;
  26066. /** @hidden */
  26067. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26068. /** @hidden */
  26069. _updateCache(ignoreParentClass?: boolean): void;
  26070. /** @hidden */
  26071. _isSynchronized(): boolean;
  26072. /** @hidden */
  26073. _markSyncedWithParent(): void;
  26074. /** @hidden */
  26075. isSynchronizedWithParent(): boolean;
  26076. /** @hidden */
  26077. isSynchronized(): boolean;
  26078. /**
  26079. * Is this node ready to be used/rendered
  26080. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  26081. * @return true if the node is ready
  26082. */
  26083. isReady(completeCheck?: boolean): boolean;
  26084. /**
  26085. * Is this node enabled?
  26086. * 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
  26087. * @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
  26088. * @return whether this node (and its parent) is enabled
  26089. */
  26090. isEnabled(checkAncestors?: boolean): boolean;
  26091. /** @hidden */
  26092. protected _syncParentEnabledState(): void;
  26093. /**
  26094. * Set the enabled state of this node
  26095. * @param value defines the new enabled state
  26096. */
  26097. setEnabled(value: boolean): void;
  26098. /**
  26099. * Is this node a descendant of the given node?
  26100. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  26101. * @param ancestor defines the parent node to inspect
  26102. * @returns a boolean indicating if this node is a descendant of the given node
  26103. */
  26104. isDescendantOf(ancestor: Node): boolean;
  26105. /** @hidden */
  26106. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  26107. /**
  26108. * Will return all nodes that have this node as ascendant
  26109. * @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
  26110. * @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
  26111. * @return all children nodes of all types
  26112. */
  26113. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  26114. /**
  26115. * Get all child-meshes of this node
  26116. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered (Default: false)
  26117. * @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
  26118. * @returns an array of AbstractMesh
  26119. */
  26120. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  26121. /**
  26122. * Get all direct children of this node
  26123. * @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
  26124. * @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)
  26125. * @returns an array of Node
  26126. */
  26127. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  26128. /** @hidden */
  26129. _setReady(state: boolean): void;
  26130. /**
  26131. * Get an animation by name
  26132. * @param name defines the name of the animation to look for
  26133. * @returns null if not found else the requested animation
  26134. */
  26135. getAnimationByName(name: string): Nullable<Animation>;
  26136. /**
  26137. * Creates an animation range for this node
  26138. * @param name defines the name of the range
  26139. * @param from defines the starting key
  26140. * @param to defines the end key
  26141. */
  26142. createAnimationRange(name: string, from: number, to: number): void;
  26143. /**
  26144. * Delete a specific animation range
  26145. * @param name defines the name of the range to delete
  26146. * @param deleteFrames defines if animation frames from the range must be deleted as well
  26147. */
  26148. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  26149. /**
  26150. * Get an animation range by name
  26151. * @param name defines the name of the animation range to look for
  26152. * @returns null if not found else the requested animation range
  26153. */
  26154. getAnimationRange(name: string): Nullable<AnimationRange>;
  26155. /**
  26156. * Gets the list of all animation ranges defined on this node
  26157. * @returns an array
  26158. */
  26159. getAnimationRanges(): Nullable<AnimationRange>[];
  26160. /**
  26161. * Will start the animation sequence
  26162. * @param name defines the range frames for animation sequence
  26163. * @param loop defines if the animation should loop (false by default)
  26164. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  26165. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  26166. * @returns the object created for this animation. If range does not exist, it will return null
  26167. */
  26168. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  26169. /**
  26170. * Serialize animation ranges into a JSON compatible object
  26171. * @returns serialization object
  26172. */
  26173. serializeAnimationRanges(): any;
  26174. /**
  26175. * Computes the world matrix of the node
  26176. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  26177. * @returns the world matrix
  26178. */
  26179. computeWorldMatrix(force?: boolean): Matrix;
  26180. /**
  26181. * Releases resources associated with this node.
  26182. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26183. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26184. */
  26185. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26186. /**
  26187. * Parse animation range data from a serialization object and store them into a given node
  26188. * @param node defines where to store the animation ranges
  26189. * @param parsedNode defines the serialization object to read data from
  26190. * @param scene defines the hosting scene
  26191. */
  26192. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  26193. /**
  26194. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  26195. * @param includeDescendants Include bounding info from descendants as well (true by default)
  26196. * @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
  26197. * @returns the new bounding vectors
  26198. */
  26199. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  26200. min: Vector3;
  26201. max: Vector3;
  26202. };
  26203. }
  26204. }
  26205. declare module "babylonjs/Animations/animation" {
  26206. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  26207. import { Vector3, Quaternion, Vector2, Color3, Size, Matrix } from "babylonjs/Maths/math";
  26208. import { Nullable } from "babylonjs/types";
  26209. import { Scene } from "babylonjs/scene";
  26210. import { IAnimatable } from "babylonjs/Misc/tools";
  26211. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  26212. import { AnimationRange } from "babylonjs/Animations/animationRange";
  26213. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  26214. import { Node } from "babylonjs/node";
  26215. import { Animatable } from "babylonjs/Animations/animatable";
  26216. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  26217. /**
  26218. * @hidden
  26219. */
  26220. export class _IAnimationState {
  26221. key: number;
  26222. repeatCount: number;
  26223. workValue?: any;
  26224. loopMode?: number;
  26225. offsetValue?: any;
  26226. highLimitValue?: any;
  26227. }
  26228. /**
  26229. * Class used to store any kind of animation
  26230. */
  26231. export class Animation {
  26232. /**Name of the animation */
  26233. name: string;
  26234. /**Property to animate */
  26235. targetProperty: string;
  26236. /**The frames per second of the animation */
  26237. framePerSecond: number;
  26238. /**The data type of the animation */
  26239. dataType: number;
  26240. /**The loop mode of the animation */
  26241. loopMode?: number | undefined;
  26242. /**Specifies if blending should be enabled */
  26243. enableBlending?: boolean | undefined;
  26244. /**
  26245. * Use matrix interpolation instead of using direct key value when animating matrices
  26246. */
  26247. static AllowMatricesInterpolation: boolean;
  26248. /**
  26249. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  26250. */
  26251. static AllowMatrixDecomposeForInterpolation: boolean;
  26252. /**
  26253. * Stores the key frames of the animation
  26254. */
  26255. private _keys;
  26256. /**
  26257. * Stores the easing function of the animation
  26258. */
  26259. private _easingFunction;
  26260. /**
  26261. * @hidden Internal use only
  26262. */
  26263. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  26264. /**
  26265. * The set of event that will be linked to this animation
  26266. */
  26267. private _events;
  26268. /**
  26269. * Stores an array of target property paths
  26270. */
  26271. targetPropertyPath: string[];
  26272. /**
  26273. * Stores the blending speed of the animation
  26274. */
  26275. blendingSpeed: number;
  26276. /**
  26277. * Stores the animation ranges for the animation
  26278. */
  26279. private _ranges;
  26280. /**
  26281. * @hidden Internal use
  26282. */
  26283. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  26284. /**
  26285. * Sets up an animation
  26286. * @param property The property to animate
  26287. * @param animationType The animation type to apply
  26288. * @param framePerSecond The frames per second of the animation
  26289. * @param easingFunction The easing function used in the animation
  26290. * @returns The created animation
  26291. */
  26292. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  26293. /**
  26294. * Create and start an animation on a node
  26295. * @param name defines the name of the global animation that will be run on all nodes
  26296. * @param node defines the root node where the animation will take place
  26297. * @param targetProperty defines property to animate
  26298. * @param framePerSecond defines the number of frame per second yo use
  26299. * @param totalFrame defines the number of frames in total
  26300. * @param from defines the initial value
  26301. * @param to defines the final value
  26302. * @param loopMode defines which loop mode you want to use (off by default)
  26303. * @param easingFunction defines the easing function to use (linear by default)
  26304. * @param onAnimationEnd defines the callback to call when animation end
  26305. * @returns the animatable created for this animation
  26306. */
  26307. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26308. /**
  26309. * Create and start an animation on a node and its descendants
  26310. * @param name defines the name of the global animation that will be run on all nodes
  26311. * @param node defines the root node where the animation will take place
  26312. * @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
  26313. * @param targetProperty defines property to animate
  26314. * @param framePerSecond defines the number of frame per second to use
  26315. * @param totalFrame defines the number of frames in total
  26316. * @param from defines the initial value
  26317. * @param to defines the final value
  26318. * @param loopMode defines which loop mode you want to use (off by default)
  26319. * @param easingFunction defines the easing function to use (linear by default)
  26320. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  26321. * @returns the list of animatables created for all nodes
  26322. * @example https://www.babylonjs-playground.com/#MH0VLI
  26323. */
  26324. 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[]>;
  26325. /**
  26326. * Creates a new animation, merges it with the existing animations and starts it
  26327. * @param name Name of the animation
  26328. * @param node Node which contains the scene that begins the animations
  26329. * @param targetProperty Specifies which property to animate
  26330. * @param framePerSecond The frames per second of the animation
  26331. * @param totalFrame The total number of frames
  26332. * @param from The frame at the beginning of the animation
  26333. * @param to The frame at the end of the animation
  26334. * @param loopMode Specifies the loop mode of the animation
  26335. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  26336. * @param onAnimationEnd Callback to run once the animation is complete
  26337. * @returns Nullable animation
  26338. */
  26339. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26340. /**
  26341. * Transition property of an host to the target Value
  26342. * @param property The property to transition
  26343. * @param targetValue The target Value of the property
  26344. * @param host The object where the property to animate belongs
  26345. * @param scene Scene used to run the animation
  26346. * @param frameRate Framerate (in frame/s) to use
  26347. * @param transition The transition type we want to use
  26348. * @param duration The duration of the animation, in milliseconds
  26349. * @param onAnimationEnd Callback trigger at the end of the animation
  26350. * @returns Nullable animation
  26351. */
  26352. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  26353. /**
  26354. * Return the array of runtime animations currently using this animation
  26355. */
  26356. readonly runtimeAnimations: RuntimeAnimation[];
  26357. /**
  26358. * Specifies if any of the runtime animations are currently running
  26359. */
  26360. readonly hasRunningRuntimeAnimations: boolean;
  26361. /**
  26362. * Initializes the animation
  26363. * @param name Name of the animation
  26364. * @param targetProperty Property to animate
  26365. * @param framePerSecond The frames per second of the animation
  26366. * @param dataType The data type of the animation
  26367. * @param loopMode The loop mode of the animation
  26368. * @param enableBlending Specifies if blending should be enabled
  26369. */
  26370. constructor(
  26371. /**Name of the animation */
  26372. name: string,
  26373. /**Property to animate */
  26374. targetProperty: string,
  26375. /**The frames per second of the animation */
  26376. framePerSecond: number,
  26377. /**The data type of the animation */
  26378. dataType: number,
  26379. /**The loop mode of the animation */
  26380. loopMode?: number | undefined,
  26381. /**Specifies if blending should be enabled */
  26382. enableBlending?: boolean | undefined);
  26383. /**
  26384. * Converts the animation to a string
  26385. * @param fullDetails support for multiple levels of logging within scene loading
  26386. * @returns String form of the animation
  26387. */
  26388. toString(fullDetails?: boolean): string;
  26389. /**
  26390. * Add an event to this animation
  26391. * @param event Event to add
  26392. */
  26393. addEvent(event: AnimationEvent): void;
  26394. /**
  26395. * Remove all events found at the given frame
  26396. * @param frame The frame to remove events from
  26397. */
  26398. removeEvents(frame: number): void;
  26399. /**
  26400. * Retrieves all the events from the animation
  26401. * @returns Events from the animation
  26402. */
  26403. getEvents(): AnimationEvent[];
  26404. /**
  26405. * Creates an animation range
  26406. * @param name Name of the animation range
  26407. * @param from Starting frame of the animation range
  26408. * @param to Ending frame of the animation
  26409. */
  26410. createRange(name: string, from: number, to: number): void;
  26411. /**
  26412. * Deletes an animation range by name
  26413. * @param name Name of the animation range to delete
  26414. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  26415. */
  26416. deleteRange(name: string, deleteFrames?: boolean): void;
  26417. /**
  26418. * Gets the animation range by name, or null if not defined
  26419. * @param name Name of the animation range
  26420. * @returns Nullable animation range
  26421. */
  26422. getRange(name: string): Nullable<AnimationRange>;
  26423. /**
  26424. * Gets the key frames from the animation
  26425. * @returns The key frames of the animation
  26426. */
  26427. getKeys(): Array<IAnimationKey>;
  26428. /**
  26429. * Gets the highest frame rate of the animation
  26430. * @returns Highest frame rate of the animation
  26431. */
  26432. getHighestFrame(): number;
  26433. /**
  26434. * Gets the easing function of the animation
  26435. * @returns Easing function of the animation
  26436. */
  26437. getEasingFunction(): IEasingFunction;
  26438. /**
  26439. * Sets the easing function of the animation
  26440. * @param easingFunction A custom mathematical formula for animation
  26441. */
  26442. setEasingFunction(easingFunction: EasingFunction): void;
  26443. /**
  26444. * Interpolates a scalar linearly
  26445. * @param startValue Start value of the animation curve
  26446. * @param endValue End value of the animation curve
  26447. * @param gradient Scalar amount to interpolate
  26448. * @returns Interpolated scalar value
  26449. */
  26450. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  26451. /**
  26452. * Interpolates a scalar cubically
  26453. * @param startValue Start value of the animation curve
  26454. * @param outTangent End tangent of the animation
  26455. * @param endValue End value of the animation curve
  26456. * @param inTangent Start tangent of the animation curve
  26457. * @param gradient Scalar amount to interpolate
  26458. * @returns Interpolated scalar value
  26459. */
  26460. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  26461. /**
  26462. * Interpolates a quaternion using a spherical linear interpolation
  26463. * @param startValue Start value of the animation curve
  26464. * @param endValue End value of the animation curve
  26465. * @param gradient Scalar amount to interpolate
  26466. * @returns Interpolated quaternion value
  26467. */
  26468. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  26469. /**
  26470. * Interpolates a quaternion cubically
  26471. * @param startValue Start value of the animation curve
  26472. * @param outTangent End tangent of the animation curve
  26473. * @param endValue End value of the animation curve
  26474. * @param inTangent Start tangent of the animation curve
  26475. * @param gradient Scalar amount to interpolate
  26476. * @returns Interpolated quaternion value
  26477. */
  26478. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  26479. /**
  26480. * Interpolates a Vector3 linearl
  26481. * @param startValue Start value of the animation curve
  26482. * @param endValue End value of the animation curve
  26483. * @param gradient Scalar amount to interpolate
  26484. * @returns Interpolated scalar value
  26485. */
  26486. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  26487. /**
  26488. * Interpolates a Vector3 cubically
  26489. * @param startValue Start value of the animation curve
  26490. * @param outTangent End tangent of the animation
  26491. * @param endValue End value of the animation curve
  26492. * @param inTangent Start tangent of the animation curve
  26493. * @param gradient Scalar amount to interpolate
  26494. * @returns InterpolatedVector3 value
  26495. */
  26496. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  26497. /**
  26498. * Interpolates a Vector2 linearly
  26499. * @param startValue Start value of the animation curve
  26500. * @param endValue End value of the animation curve
  26501. * @param gradient Scalar amount to interpolate
  26502. * @returns Interpolated Vector2 value
  26503. */
  26504. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  26505. /**
  26506. * Interpolates a Vector2 cubically
  26507. * @param startValue Start value of the animation curve
  26508. * @param outTangent End tangent of the animation
  26509. * @param endValue End value of the animation curve
  26510. * @param inTangent Start tangent of the animation curve
  26511. * @param gradient Scalar amount to interpolate
  26512. * @returns Interpolated Vector2 value
  26513. */
  26514. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  26515. /**
  26516. * Interpolates a size linearly
  26517. * @param startValue Start value of the animation curve
  26518. * @param endValue End value of the animation curve
  26519. * @param gradient Scalar amount to interpolate
  26520. * @returns Interpolated Size value
  26521. */
  26522. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  26523. /**
  26524. * Interpolates a Color3 linearly
  26525. * @param startValue Start value of the animation curve
  26526. * @param endValue End value of the animation curve
  26527. * @param gradient Scalar amount to interpolate
  26528. * @returns Interpolated Color3 value
  26529. */
  26530. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  26531. /**
  26532. * @hidden Internal use only
  26533. */
  26534. _getKeyValue(value: any): any;
  26535. /**
  26536. * @hidden Internal use only
  26537. */
  26538. _interpolate(currentFrame: number, state: _IAnimationState): any;
  26539. /**
  26540. * Defines the function to use to interpolate matrices
  26541. * @param startValue defines the start matrix
  26542. * @param endValue defines the end matrix
  26543. * @param gradient defines the gradient between both matrices
  26544. * @param result defines an optional target matrix where to store the interpolation
  26545. * @returns the interpolated matrix
  26546. */
  26547. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  26548. /**
  26549. * Makes a copy of the animation
  26550. * @returns Cloned animation
  26551. */
  26552. clone(): Animation;
  26553. /**
  26554. * Sets the key frames of the animation
  26555. * @param values The animation key frames to set
  26556. */
  26557. setKeys(values: Array<IAnimationKey>): void;
  26558. /**
  26559. * Serializes the animation to an object
  26560. * @returns Serialized object
  26561. */
  26562. serialize(): any;
  26563. /**
  26564. * Float animation type
  26565. */
  26566. private static _ANIMATIONTYPE_FLOAT;
  26567. /**
  26568. * Vector3 animation type
  26569. */
  26570. private static _ANIMATIONTYPE_VECTOR3;
  26571. /**
  26572. * Quaternion animation type
  26573. */
  26574. private static _ANIMATIONTYPE_QUATERNION;
  26575. /**
  26576. * Matrix animation type
  26577. */
  26578. private static _ANIMATIONTYPE_MATRIX;
  26579. /**
  26580. * Color3 animation type
  26581. */
  26582. private static _ANIMATIONTYPE_COLOR3;
  26583. /**
  26584. * Vector2 animation type
  26585. */
  26586. private static _ANIMATIONTYPE_VECTOR2;
  26587. /**
  26588. * Size animation type
  26589. */
  26590. private static _ANIMATIONTYPE_SIZE;
  26591. /**
  26592. * Relative Loop Mode
  26593. */
  26594. private static _ANIMATIONLOOPMODE_RELATIVE;
  26595. /**
  26596. * Cycle Loop Mode
  26597. */
  26598. private static _ANIMATIONLOOPMODE_CYCLE;
  26599. /**
  26600. * Constant Loop Mode
  26601. */
  26602. private static _ANIMATIONLOOPMODE_CONSTANT;
  26603. /**
  26604. * Get the float animation type
  26605. */
  26606. static readonly ANIMATIONTYPE_FLOAT: number;
  26607. /**
  26608. * Get the Vector3 animation type
  26609. */
  26610. static readonly ANIMATIONTYPE_VECTOR3: number;
  26611. /**
  26612. * Get the Vector2 animation type
  26613. */
  26614. static readonly ANIMATIONTYPE_VECTOR2: number;
  26615. /**
  26616. * Get the Size animation type
  26617. */
  26618. static readonly ANIMATIONTYPE_SIZE: number;
  26619. /**
  26620. * Get the Quaternion animation type
  26621. */
  26622. static readonly ANIMATIONTYPE_QUATERNION: number;
  26623. /**
  26624. * Get the Matrix animation type
  26625. */
  26626. static readonly ANIMATIONTYPE_MATRIX: number;
  26627. /**
  26628. * Get the Color3 animation type
  26629. */
  26630. static readonly ANIMATIONTYPE_COLOR3: number;
  26631. /**
  26632. * Get the Relative Loop Mode
  26633. */
  26634. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  26635. /**
  26636. * Get the Cycle Loop Mode
  26637. */
  26638. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  26639. /**
  26640. * Get the Constant Loop Mode
  26641. */
  26642. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  26643. /** @hidden */
  26644. static _UniversalLerp(left: any, right: any, amount: number): any;
  26645. /**
  26646. * Parses an animation object and creates an animation
  26647. * @param parsedAnimation Parsed animation object
  26648. * @returns Animation object
  26649. */
  26650. static Parse(parsedAnimation: any): Animation;
  26651. /**
  26652. * Appends the serialized animations from the source animations
  26653. * @param source Source containing the animations
  26654. * @param destination Target to store the animations
  26655. */
  26656. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  26657. }
  26658. }
  26659. declare module "babylonjs/Materials/Textures/baseTexture" {
  26660. import { Observable } from "babylonjs/Misc/observable";
  26661. import { IAnimatable } from "babylonjs/Misc/tools";
  26662. import { Nullable } from "babylonjs/types";
  26663. import { Scene } from "babylonjs/scene";
  26664. import { Matrix, ISize } from "babylonjs/Maths/math";
  26665. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  26666. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  26667. /**
  26668. * Base class of all the textures in babylon.
  26669. * It groups all the common properties the materials, post process, lights... might need
  26670. * in order to make a correct use of the texture.
  26671. */
  26672. export class BaseTexture implements IAnimatable {
  26673. /**
  26674. * Default anisotropic filtering level for the application.
  26675. * It is set to 4 as a good tradeoff between perf and quality.
  26676. */
  26677. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  26678. /**
  26679. * Gets or sets the unique id of the texture
  26680. */
  26681. uniqueId: number;
  26682. /**
  26683. * Define the name of the texture.
  26684. */
  26685. name: string;
  26686. /**
  26687. * Gets or sets an object used to store user defined information.
  26688. */
  26689. metadata: any;
  26690. /**
  26691. * For internal use only. Please do not use.
  26692. */
  26693. reservedDataStore: any;
  26694. private _hasAlpha;
  26695. /**
  26696. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  26697. */
  26698. hasAlpha: boolean;
  26699. /**
  26700. * Defines if the alpha value should be determined via the rgb values.
  26701. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  26702. */
  26703. getAlphaFromRGB: boolean;
  26704. /**
  26705. * Intensity or strength of the texture.
  26706. * It is commonly used by materials to fine tune the intensity of the texture
  26707. */
  26708. level: number;
  26709. /**
  26710. * Define the UV chanel to use starting from 0 and defaulting to 0.
  26711. * This is part of the texture as textures usually maps to one uv set.
  26712. */
  26713. coordinatesIndex: number;
  26714. private _coordinatesMode;
  26715. /**
  26716. * How a texture is mapped.
  26717. *
  26718. * | Value | Type | Description |
  26719. * | ----- | ----------------------------------- | ----------- |
  26720. * | 0 | EXPLICIT_MODE | |
  26721. * | 1 | SPHERICAL_MODE | |
  26722. * | 2 | PLANAR_MODE | |
  26723. * | 3 | CUBIC_MODE | |
  26724. * | 4 | PROJECTION_MODE | |
  26725. * | 5 | SKYBOX_MODE | |
  26726. * | 6 | INVCUBIC_MODE | |
  26727. * | 7 | EQUIRECTANGULAR_MODE | |
  26728. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  26729. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  26730. */
  26731. coordinatesMode: number;
  26732. /**
  26733. * | Value | Type | Description |
  26734. * | ----- | ------------------ | ----------- |
  26735. * | 0 | CLAMP_ADDRESSMODE | |
  26736. * | 1 | WRAP_ADDRESSMODE | |
  26737. * | 2 | MIRROR_ADDRESSMODE | |
  26738. */
  26739. wrapU: number;
  26740. /**
  26741. * | Value | Type | Description |
  26742. * | ----- | ------------------ | ----------- |
  26743. * | 0 | CLAMP_ADDRESSMODE | |
  26744. * | 1 | WRAP_ADDRESSMODE | |
  26745. * | 2 | MIRROR_ADDRESSMODE | |
  26746. */
  26747. wrapV: number;
  26748. /**
  26749. * | Value | Type | Description |
  26750. * | ----- | ------------------ | ----------- |
  26751. * | 0 | CLAMP_ADDRESSMODE | |
  26752. * | 1 | WRAP_ADDRESSMODE | |
  26753. * | 2 | MIRROR_ADDRESSMODE | |
  26754. */
  26755. wrapR: number;
  26756. /**
  26757. * With compliant hardware and browser (supporting anisotropic filtering)
  26758. * this defines the level of anisotropic filtering in the texture.
  26759. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  26760. */
  26761. anisotropicFilteringLevel: number;
  26762. /**
  26763. * Define if the texture is a cube texture or if false a 2d texture.
  26764. */
  26765. isCube: boolean;
  26766. /**
  26767. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  26768. */
  26769. is3D: boolean;
  26770. /**
  26771. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  26772. * HDR texture are usually stored in linear space.
  26773. * This only impacts the PBR and Background materials
  26774. */
  26775. gammaSpace: boolean;
  26776. /**
  26777. * Gets whether or not the texture contains RGBD data.
  26778. */
  26779. readonly isRGBD: boolean;
  26780. /**
  26781. * Is Z inverted in the texture (useful in a cube texture).
  26782. */
  26783. invertZ: boolean;
  26784. /**
  26785. * Are mip maps generated for this texture or not.
  26786. */
  26787. readonly noMipmap: boolean;
  26788. /**
  26789. * @hidden
  26790. */
  26791. lodLevelInAlpha: boolean;
  26792. /**
  26793. * With prefiltered texture, defined the offset used during the prefiltering steps.
  26794. */
  26795. lodGenerationOffset: number;
  26796. /**
  26797. * With prefiltered texture, defined the scale used during the prefiltering steps.
  26798. */
  26799. lodGenerationScale: number;
  26800. /**
  26801. * Define if the texture is a render target.
  26802. */
  26803. isRenderTarget: boolean;
  26804. /**
  26805. * Define the unique id of the texture in the scene.
  26806. */
  26807. readonly uid: string;
  26808. /**
  26809. * Return a string representation of the texture.
  26810. * @returns the texture as a string
  26811. */
  26812. toString(): string;
  26813. /**
  26814. * Get the class name of the texture.
  26815. * @returns "BaseTexture"
  26816. */
  26817. getClassName(): string;
  26818. /**
  26819. * Define the list of animation attached to the texture.
  26820. */
  26821. animations: import("babylonjs/Animations/animation").Animation[];
  26822. /**
  26823. * An event triggered when the texture is disposed.
  26824. */
  26825. onDisposeObservable: Observable<BaseTexture>;
  26826. private _onDisposeObserver;
  26827. /**
  26828. * Callback triggered when the texture has been disposed.
  26829. * Kept for back compatibility, you can use the onDisposeObservable instead.
  26830. */
  26831. onDispose: () => void;
  26832. /**
  26833. * Define the current state of the loading sequence when in delayed load mode.
  26834. */
  26835. delayLoadState: number;
  26836. private _scene;
  26837. /** @hidden */
  26838. _texture: Nullable<InternalTexture>;
  26839. private _uid;
  26840. /**
  26841. * Define if the texture is preventinga material to render or not.
  26842. * If not and the texture is not ready, the engine will use a default black texture instead.
  26843. */
  26844. readonly isBlocking: boolean;
  26845. /**
  26846. * Instantiates a new BaseTexture.
  26847. * Base class of all the textures in babylon.
  26848. * It groups all the common properties the materials, post process, lights... might need
  26849. * in order to make a correct use of the texture.
  26850. * @param scene Define the scene the texture blongs to
  26851. */
  26852. constructor(scene: Nullable<Scene>);
  26853. /**
  26854. * Get the scene the texture belongs to.
  26855. * @returns the scene or null if undefined
  26856. */
  26857. getScene(): Nullable<Scene>;
  26858. /**
  26859. * Get the texture transform matrix used to offset tile the texture for istance.
  26860. * @returns the transformation matrix
  26861. */
  26862. getTextureMatrix(): Matrix;
  26863. /**
  26864. * Get the texture reflection matrix used to rotate/transform the reflection.
  26865. * @returns the reflection matrix
  26866. */
  26867. getReflectionTextureMatrix(): Matrix;
  26868. /**
  26869. * Get the underlying lower level texture from Babylon.
  26870. * @returns the insternal texture
  26871. */
  26872. getInternalTexture(): Nullable<InternalTexture>;
  26873. /**
  26874. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  26875. * @returns true if ready or not blocking
  26876. */
  26877. isReadyOrNotBlocking(): boolean;
  26878. /**
  26879. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  26880. * @returns true if fully ready
  26881. */
  26882. isReady(): boolean;
  26883. private _cachedSize;
  26884. /**
  26885. * Get the size of the texture.
  26886. * @returns the texture size.
  26887. */
  26888. getSize(): ISize;
  26889. /**
  26890. * Get the base size of the texture.
  26891. * It can be different from the size if the texture has been resized for POT for instance
  26892. * @returns the base size
  26893. */
  26894. getBaseSize(): ISize;
  26895. /**
  26896. * Update the sampling mode of the texture.
  26897. * Default is Trilinear mode.
  26898. *
  26899. * | Value | Type | Description |
  26900. * | ----- | ------------------ | ----------- |
  26901. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  26902. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  26903. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  26904. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  26905. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  26906. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  26907. * | 7 | NEAREST_LINEAR | |
  26908. * | 8 | NEAREST_NEAREST | |
  26909. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  26910. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  26911. * | 11 | LINEAR_LINEAR | |
  26912. * | 12 | LINEAR_NEAREST | |
  26913. *
  26914. * > _mag_: magnification filter (close to the viewer)
  26915. * > _min_: minification filter (far from the viewer)
  26916. * > _mip_: filter used between mip map levels
  26917. *@param samplingMode Define the new sampling mode of the texture
  26918. */
  26919. updateSamplingMode(samplingMode: number): void;
  26920. /**
  26921. * Scales the texture if is `canRescale()`
  26922. * @param ratio the resize factor we want to use to rescale
  26923. */
  26924. scale(ratio: number): void;
  26925. /**
  26926. * Get if the texture can rescale.
  26927. */
  26928. readonly canRescale: boolean;
  26929. /** @hidden */
  26930. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  26931. /** @hidden */
  26932. _rebuild(): void;
  26933. /**
  26934. * Triggers the load sequence in delayed load mode.
  26935. */
  26936. delayLoad(): void;
  26937. /**
  26938. * Clones the texture.
  26939. * @returns the cloned texture
  26940. */
  26941. clone(): Nullable<BaseTexture>;
  26942. /**
  26943. * Get the texture underlying type (INT, FLOAT...)
  26944. */
  26945. readonly textureType: number;
  26946. /**
  26947. * Get the texture underlying format (RGB, RGBA...)
  26948. */
  26949. readonly textureFormat: number;
  26950. /**
  26951. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  26952. * This will returns an RGBA array buffer containing either in values (0-255) or
  26953. * float values (0-1) depending of the underlying buffer type.
  26954. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  26955. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  26956. * @param buffer defines a user defined buffer to fill with data (can be null)
  26957. * @returns The Array buffer containing the pixels data.
  26958. */
  26959. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  26960. /**
  26961. * Release and destroy the underlying lower level texture aka internalTexture.
  26962. */
  26963. releaseInternalTexture(): void;
  26964. /**
  26965. * Get the polynomial representation of the texture data.
  26966. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  26967. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  26968. */
  26969. sphericalPolynomial: Nullable<SphericalPolynomial>;
  26970. /** @hidden */
  26971. readonly _lodTextureHigh: Nullable<BaseTexture>;
  26972. /** @hidden */
  26973. readonly _lodTextureMid: Nullable<BaseTexture>;
  26974. /** @hidden */
  26975. readonly _lodTextureLow: Nullable<BaseTexture>;
  26976. /**
  26977. * Dispose the texture and release its associated resources.
  26978. */
  26979. dispose(): void;
  26980. /**
  26981. * Serialize the texture into a JSON representation that can be parsed later on.
  26982. * @returns the JSON representation of the texture
  26983. */
  26984. serialize(): any;
  26985. /**
  26986. * Helper function to be called back once a list of texture contains only ready textures.
  26987. * @param textures Define the list of textures to wait for
  26988. * @param callback Define the callback triggered once the entire list will be ready
  26989. */
  26990. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  26991. }
  26992. }
  26993. declare module "babylonjs/Materials/uniformBuffer" {
  26994. import { Nullable, FloatArray } from "babylonjs/types";
  26995. import { Matrix, Vector3, Color3, Vector4 } from "babylonjs/Maths/math";
  26996. import { Engine } from "babylonjs/Engines/engine";
  26997. import { Effect } from "babylonjs/Materials/effect";
  26998. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26999. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  27000. /**
  27001. * Uniform buffer objects.
  27002. *
  27003. * Handles blocks of uniform on the GPU.
  27004. *
  27005. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  27006. *
  27007. * For more information, please refer to :
  27008. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  27009. */
  27010. export class UniformBuffer {
  27011. private _engine;
  27012. private _buffer;
  27013. private _data;
  27014. private _bufferData;
  27015. private _dynamic?;
  27016. private _uniformLocations;
  27017. private _uniformSizes;
  27018. private _uniformLocationPointer;
  27019. private _needSync;
  27020. private _noUBO;
  27021. private _currentEffect;
  27022. private static _MAX_UNIFORM_SIZE;
  27023. private static _tempBuffer;
  27024. /**
  27025. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  27026. * This is dynamic to allow compat with webgl 1 and 2.
  27027. * You will need to pass the name of the uniform as well as the value.
  27028. */
  27029. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  27030. /**
  27031. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  27032. * This is dynamic to allow compat with webgl 1 and 2.
  27033. * You will need to pass the name of the uniform as well as the value.
  27034. */
  27035. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  27036. /**
  27037. * Lambda to Update a single float in a uniform buffer.
  27038. * This is dynamic to allow compat with webgl 1 and 2.
  27039. * You will need to pass the name of the uniform as well as the value.
  27040. */
  27041. updateFloat: (name: string, x: number) => void;
  27042. /**
  27043. * Lambda to Update a vec2 of float in a uniform buffer.
  27044. * This is dynamic to allow compat with webgl 1 and 2.
  27045. * You will need to pass the name of the uniform as well as the value.
  27046. */
  27047. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  27048. /**
  27049. * Lambda to Update a vec3 of float in a uniform buffer.
  27050. * This is dynamic to allow compat with webgl 1 and 2.
  27051. * You will need to pass the name of the uniform as well as the value.
  27052. */
  27053. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  27054. /**
  27055. * Lambda to Update a vec4 of float in a uniform buffer.
  27056. * This is dynamic to allow compat with webgl 1 and 2.
  27057. * You will need to pass the name of the uniform as well as the value.
  27058. */
  27059. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  27060. /**
  27061. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  27062. * This is dynamic to allow compat with webgl 1 and 2.
  27063. * You will need to pass the name of the uniform as well as the value.
  27064. */
  27065. updateMatrix: (name: string, mat: Matrix) => void;
  27066. /**
  27067. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  27068. * This is dynamic to allow compat with webgl 1 and 2.
  27069. * You will need to pass the name of the uniform as well as the value.
  27070. */
  27071. updateVector3: (name: string, vector: Vector3) => void;
  27072. /**
  27073. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  27074. * This is dynamic to allow compat with webgl 1 and 2.
  27075. * You will need to pass the name of the uniform as well as the value.
  27076. */
  27077. updateVector4: (name: string, vector: Vector4) => void;
  27078. /**
  27079. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  27080. * This is dynamic to allow compat with webgl 1 and 2.
  27081. * You will need to pass the name of the uniform as well as the value.
  27082. */
  27083. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  27084. /**
  27085. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  27086. * This is dynamic to allow compat with webgl 1 and 2.
  27087. * You will need to pass the name of the uniform as well as the value.
  27088. */
  27089. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  27090. /**
  27091. * Instantiates a new Uniform buffer objects.
  27092. *
  27093. * Handles blocks of uniform on the GPU.
  27094. *
  27095. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  27096. *
  27097. * For more information, please refer to :
  27098. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  27099. * @param engine Define the engine the buffer is associated with
  27100. * @param data Define the data contained in the buffer
  27101. * @param dynamic Define if the buffer is updatable
  27102. */
  27103. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  27104. /**
  27105. * Indicates if the buffer is using the WebGL2 UBO implementation,
  27106. * or just falling back on setUniformXXX calls.
  27107. */
  27108. readonly useUbo: boolean;
  27109. /**
  27110. * Indicates if the WebGL underlying uniform buffer is in sync
  27111. * with the javascript cache data.
  27112. */
  27113. readonly isSync: boolean;
  27114. /**
  27115. * Indicates if the WebGL underlying uniform buffer is dynamic.
  27116. * Also, a dynamic UniformBuffer will disable cache verification and always
  27117. * update the underlying WebGL uniform buffer to the GPU.
  27118. * @returns if Dynamic, otherwise false
  27119. */
  27120. isDynamic(): boolean;
  27121. /**
  27122. * The data cache on JS side.
  27123. * @returns the underlying data as a float array
  27124. */
  27125. getData(): Float32Array;
  27126. /**
  27127. * The underlying WebGL Uniform buffer.
  27128. * @returns the webgl buffer
  27129. */
  27130. getBuffer(): Nullable<DataBuffer>;
  27131. /**
  27132. * std140 layout specifies how to align data within an UBO structure.
  27133. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  27134. * for specs.
  27135. */
  27136. private _fillAlignment;
  27137. /**
  27138. * Adds an uniform in the buffer.
  27139. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  27140. * for the layout to be correct !
  27141. * @param name Name of the uniform, as used in the uniform block in the shader.
  27142. * @param size Data size, or data directly.
  27143. */
  27144. addUniform(name: string, size: number | number[]): void;
  27145. /**
  27146. * Adds a Matrix 4x4 to the uniform buffer.
  27147. * @param name Name of the uniform, as used in the uniform block in the shader.
  27148. * @param mat A 4x4 matrix.
  27149. */
  27150. addMatrix(name: string, mat: Matrix): void;
  27151. /**
  27152. * Adds a vec2 to the uniform buffer.
  27153. * @param name Name of the uniform, as used in the uniform block in the shader.
  27154. * @param x Define the x component value of the vec2
  27155. * @param y Define the y component value of the vec2
  27156. */
  27157. addFloat2(name: string, x: number, y: number): void;
  27158. /**
  27159. * Adds a vec3 to the uniform buffer.
  27160. * @param name Name of the uniform, as used in the uniform block in the shader.
  27161. * @param x Define the x component value of the vec3
  27162. * @param y Define the y component value of the vec3
  27163. * @param z Define the z component value of the vec3
  27164. */
  27165. addFloat3(name: string, x: number, y: number, z: number): void;
  27166. /**
  27167. * Adds a vec3 to the uniform buffer.
  27168. * @param name Name of the uniform, as used in the uniform block in the shader.
  27169. * @param color Define the vec3 from a Color
  27170. */
  27171. addColor3(name: string, color: Color3): void;
  27172. /**
  27173. * Adds a vec4 to the uniform buffer.
  27174. * @param name Name of the uniform, as used in the uniform block in the shader.
  27175. * @param color Define the rgb components from a Color
  27176. * @param alpha Define the a component of the vec4
  27177. */
  27178. addColor4(name: string, color: Color3, alpha: number): void;
  27179. /**
  27180. * Adds a vec3 to the uniform buffer.
  27181. * @param name Name of the uniform, as used in the uniform block in the shader.
  27182. * @param vector Define the vec3 components from a Vector
  27183. */
  27184. addVector3(name: string, vector: Vector3): void;
  27185. /**
  27186. * Adds a Matrix 3x3 to the uniform buffer.
  27187. * @param name Name of the uniform, as used in the uniform block in the shader.
  27188. */
  27189. addMatrix3x3(name: string): void;
  27190. /**
  27191. * Adds a Matrix 2x2 to the uniform buffer.
  27192. * @param name Name of the uniform, as used in the uniform block in the shader.
  27193. */
  27194. addMatrix2x2(name: string): void;
  27195. /**
  27196. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  27197. */
  27198. create(): void;
  27199. /** @hidden */
  27200. _rebuild(): void;
  27201. /**
  27202. * Updates the WebGL Uniform Buffer on the GPU.
  27203. * If the `dynamic` flag is set to true, no cache comparison is done.
  27204. * Otherwise, the buffer will be updated only if the cache differs.
  27205. */
  27206. update(): void;
  27207. /**
  27208. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  27209. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  27210. * @param data Define the flattened data
  27211. * @param size Define the size of the data.
  27212. */
  27213. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  27214. private _updateMatrix3x3ForUniform;
  27215. private _updateMatrix3x3ForEffect;
  27216. private _updateMatrix2x2ForEffect;
  27217. private _updateMatrix2x2ForUniform;
  27218. private _updateFloatForEffect;
  27219. private _updateFloatForUniform;
  27220. private _updateFloat2ForEffect;
  27221. private _updateFloat2ForUniform;
  27222. private _updateFloat3ForEffect;
  27223. private _updateFloat3ForUniform;
  27224. private _updateFloat4ForEffect;
  27225. private _updateFloat4ForUniform;
  27226. private _updateMatrixForEffect;
  27227. private _updateMatrixForUniform;
  27228. private _updateVector3ForEffect;
  27229. private _updateVector3ForUniform;
  27230. private _updateVector4ForEffect;
  27231. private _updateVector4ForUniform;
  27232. private _updateColor3ForEffect;
  27233. private _updateColor3ForUniform;
  27234. private _updateColor4ForEffect;
  27235. private _updateColor4ForUniform;
  27236. /**
  27237. * Sets a sampler uniform on the effect.
  27238. * @param name Define the name of the sampler.
  27239. * @param texture Define the texture to set in the sampler
  27240. */
  27241. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  27242. /**
  27243. * Directly updates the value of the uniform in the cache AND on the GPU.
  27244. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  27245. * @param data Define the flattened data
  27246. */
  27247. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  27248. /**
  27249. * Binds this uniform buffer to an effect.
  27250. * @param effect Define the effect to bind the buffer to
  27251. * @param name Name of the uniform block in the shader.
  27252. */
  27253. bindToEffect(effect: Effect, name: string): void;
  27254. /**
  27255. * Disposes the uniform buffer.
  27256. */
  27257. dispose(): void;
  27258. }
  27259. }
  27260. declare module "babylonjs/Audio/analyser" {
  27261. import { Scene } from "babylonjs/scene";
  27262. /**
  27263. * Class used to work with sound analyzer using fast fourier transform (FFT)
  27264. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27265. */
  27266. export class Analyser {
  27267. /**
  27268. * Gets or sets the smoothing
  27269. * @ignorenaming
  27270. */
  27271. SMOOTHING: number;
  27272. /**
  27273. * Gets or sets the FFT table size
  27274. * @ignorenaming
  27275. */
  27276. FFT_SIZE: number;
  27277. /**
  27278. * Gets or sets the bar graph amplitude
  27279. * @ignorenaming
  27280. */
  27281. BARGRAPHAMPLITUDE: number;
  27282. /**
  27283. * Gets or sets the position of the debug canvas
  27284. * @ignorenaming
  27285. */
  27286. DEBUGCANVASPOS: {
  27287. x: number;
  27288. y: number;
  27289. };
  27290. /**
  27291. * Gets or sets the debug canvas size
  27292. * @ignorenaming
  27293. */
  27294. DEBUGCANVASSIZE: {
  27295. width: number;
  27296. height: number;
  27297. };
  27298. private _byteFreqs;
  27299. private _byteTime;
  27300. private _floatFreqs;
  27301. private _webAudioAnalyser;
  27302. private _debugCanvas;
  27303. private _debugCanvasContext;
  27304. private _scene;
  27305. private _registerFunc;
  27306. private _audioEngine;
  27307. /**
  27308. * Creates a new analyser
  27309. * @param scene defines hosting scene
  27310. */
  27311. constructor(scene: Scene);
  27312. /**
  27313. * Get the number of data values you will have to play with for the visualization
  27314. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  27315. * @returns a number
  27316. */
  27317. getFrequencyBinCount(): number;
  27318. /**
  27319. * Gets the current frequency data as a byte array
  27320. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  27321. * @returns a Uint8Array
  27322. */
  27323. getByteFrequencyData(): Uint8Array;
  27324. /**
  27325. * Gets the current waveform as a byte array
  27326. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  27327. * @returns a Uint8Array
  27328. */
  27329. getByteTimeDomainData(): Uint8Array;
  27330. /**
  27331. * Gets the current frequency data as a float array
  27332. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  27333. * @returns a Float32Array
  27334. */
  27335. getFloatFrequencyData(): Float32Array;
  27336. /**
  27337. * Renders the debug canvas
  27338. */
  27339. drawDebugCanvas(): void;
  27340. /**
  27341. * Stops rendering the debug canvas and removes it
  27342. */
  27343. stopDebugCanvas(): void;
  27344. /**
  27345. * Connects two audio nodes
  27346. * @param inputAudioNode defines first node to connect
  27347. * @param outputAudioNode defines second node to connect
  27348. */
  27349. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  27350. /**
  27351. * Releases all associated resources
  27352. */
  27353. dispose(): void;
  27354. }
  27355. }
  27356. declare module "babylonjs/Audio/audioEngine" {
  27357. import { IDisposable } from "babylonjs/scene";
  27358. import { Analyser } from "babylonjs/Audio/analyser";
  27359. import { Nullable } from "babylonjs/types";
  27360. import { Observable } from "babylonjs/Misc/observable";
  27361. /**
  27362. * This represents an audio engine and it is responsible
  27363. * to play, synchronize and analyse sounds throughout the application.
  27364. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27365. */
  27366. export interface IAudioEngine extends IDisposable {
  27367. /**
  27368. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  27369. */
  27370. readonly canUseWebAudio: boolean;
  27371. /**
  27372. * Gets the current AudioContext if available.
  27373. */
  27374. readonly audioContext: Nullable<AudioContext>;
  27375. /**
  27376. * The master gain node defines the global audio volume of your audio engine.
  27377. */
  27378. readonly masterGain: GainNode;
  27379. /**
  27380. * Gets whether or not mp3 are supported by your browser.
  27381. */
  27382. readonly isMP3supported: boolean;
  27383. /**
  27384. * Gets whether or not ogg are supported by your browser.
  27385. */
  27386. readonly isOGGsupported: boolean;
  27387. /**
  27388. * Defines if Babylon should emit a warning if WebAudio is not supported.
  27389. * @ignoreNaming
  27390. */
  27391. WarnedWebAudioUnsupported: boolean;
  27392. /**
  27393. * Defines if the audio engine relies on a custom unlocked button.
  27394. * In this case, the embedded button will not be displayed.
  27395. */
  27396. useCustomUnlockedButton: boolean;
  27397. /**
  27398. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  27399. */
  27400. readonly unlocked: boolean;
  27401. /**
  27402. * Event raised when audio has been unlocked on the browser.
  27403. */
  27404. onAudioUnlockedObservable: Observable<AudioEngine>;
  27405. /**
  27406. * Event raised when audio has been locked on the browser.
  27407. */
  27408. onAudioLockedObservable: Observable<AudioEngine>;
  27409. /**
  27410. * Flags the audio engine in Locked state.
  27411. * This happens due to new browser policies preventing audio to autoplay.
  27412. */
  27413. lock(): void;
  27414. /**
  27415. * Unlocks the audio engine once a user action has been done on the dom.
  27416. * This is helpful to resume play once browser policies have been satisfied.
  27417. */
  27418. unlock(): void;
  27419. }
  27420. /**
  27421. * This represents the default audio engine used in babylon.
  27422. * It is responsible to play, synchronize and analyse sounds throughout the application.
  27423. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27424. */
  27425. export class AudioEngine implements IAudioEngine {
  27426. private _audioContext;
  27427. private _audioContextInitialized;
  27428. private _muteButton;
  27429. private _hostElement;
  27430. /**
  27431. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  27432. */
  27433. canUseWebAudio: boolean;
  27434. /**
  27435. * The master gain node defines the global audio volume of your audio engine.
  27436. */
  27437. masterGain: GainNode;
  27438. /**
  27439. * Defines if Babylon should emit a warning if WebAudio is not supported.
  27440. * @ignoreNaming
  27441. */
  27442. WarnedWebAudioUnsupported: boolean;
  27443. /**
  27444. * Gets whether or not mp3 are supported by your browser.
  27445. */
  27446. isMP3supported: boolean;
  27447. /**
  27448. * Gets whether or not ogg are supported by your browser.
  27449. */
  27450. isOGGsupported: boolean;
  27451. /**
  27452. * Gets whether audio has been unlocked on the device.
  27453. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  27454. * a user interaction has happened.
  27455. */
  27456. unlocked: boolean;
  27457. /**
  27458. * Defines if the audio engine relies on a custom unlocked button.
  27459. * In this case, the embedded button will not be displayed.
  27460. */
  27461. useCustomUnlockedButton: boolean;
  27462. /**
  27463. * Event raised when audio has been unlocked on the browser.
  27464. */
  27465. onAudioUnlockedObservable: Observable<AudioEngine>;
  27466. /**
  27467. * Event raised when audio has been locked on the browser.
  27468. */
  27469. onAudioLockedObservable: Observable<AudioEngine>;
  27470. /**
  27471. * Gets the current AudioContext if available.
  27472. */
  27473. readonly audioContext: Nullable<AudioContext>;
  27474. private _connectedAnalyser;
  27475. /**
  27476. * Instantiates a new audio engine.
  27477. *
  27478. * There should be only one per page as some browsers restrict the number
  27479. * of audio contexts you can create.
  27480. * @param hostElement defines the host element where to display the mute icon if necessary
  27481. */
  27482. constructor(hostElement?: Nullable<HTMLElement>);
  27483. /**
  27484. * Flags the audio engine in Locked state.
  27485. * This happens due to new browser policies preventing audio to autoplay.
  27486. */
  27487. lock(): void;
  27488. /**
  27489. * Unlocks the audio engine once a user action has been done on the dom.
  27490. * This is helpful to resume play once browser policies have been satisfied.
  27491. */
  27492. unlock(): void;
  27493. private _resumeAudioContext;
  27494. private _initializeAudioContext;
  27495. private _tryToRun;
  27496. private _triggerRunningState;
  27497. private _triggerSuspendedState;
  27498. private _displayMuteButton;
  27499. private _moveButtonToTopLeft;
  27500. private _onResize;
  27501. private _hideMuteButton;
  27502. /**
  27503. * Destroy and release the resources associated with the audio ccontext.
  27504. */
  27505. dispose(): void;
  27506. /**
  27507. * Gets the global volume sets on the master gain.
  27508. * @returns the global volume if set or -1 otherwise
  27509. */
  27510. getGlobalVolume(): number;
  27511. /**
  27512. * Sets the global volume of your experience (sets on the master gain).
  27513. * @param newVolume Defines the new global volume of the application
  27514. */
  27515. setGlobalVolume(newVolume: number): void;
  27516. /**
  27517. * Connect the audio engine to an audio analyser allowing some amazing
  27518. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  27519. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  27520. * @param analyser The analyser to connect to the engine
  27521. */
  27522. connectToAnalyser(analyser: Analyser): void;
  27523. }
  27524. }
  27525. declare module "babylonjs/Loading/loadingScreen" {
  27526. /**
  27527. * Interface used to present a loading screen while loading a scene
  27528. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27529. */
  27530. export interface ILoadingScreen {
  27531. /**
  27532. * Function called to display the loading screen
  27533. */
  27534. displayLoadingUI: () => void;
  27535. /**
  27536. * Function called to hide the loading screen
  27537. */
  27538. hideLoadingUI: () => void;
  27539. /**
  27540. * Gets or sets the color to use for the background
  27541. */
  27542. loadingUIBackgroundColor: string;
  27543. /**
  27544. * Gets or sets the text to display while loading
  27545. */
  27546. loadingUIText: string;
  27547. }
  27548. /**
  27549. * Class used for the default loading screen
  27550. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27551. */
  27552. export class DefaultLoadingScreen implements ILoadingScreen {
  27553. private _renderingCanvas;
  27554. private _loadingText;
  27555. private _loadingDivBackgroundColor;
  27556. private _loadingDiv;
  27557. private _loadingTextDiv;
  27558. /**
  27559. * Creates a new default loading screen
  27560. * @param _renderingCanvas defines the canvas used to render the scene
  27561. * @param _loadingText defines the default text to display
  27562. * @param _loadingDivBackgroundColor defines the default background color
  27563. */
  27564. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  27565. /**
  27566. * Function called to display the loading screen
  27567. */
  27568. displayLoadingUI(): void;
  27569. /**
  27570. * Function called to hide the loading screen
  27571. */
  27572. hideLoadingUI(): void;
  27573. /**
  27574. * Gets or sets the text to display while loading
  27575. */
  27576. loadingUIText: string;
  27577. /**
  27578. * Gets or sets the color to use for the background
  27579. */
  27580. loadingUIBackgroundColor: string;
  27581. private _resizeLoadingUI;
  27582. }
  27583. }
  27584. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  27585. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  27586. import { Engine } from "babylonjs/Engines/engine";
  27587. import { Nullable } from "babylonjs/types";
  27588. /** @hidden */
  27589. export class WebGLPipelineContext implements IPipelineContext {
  27590. engine: Engine;
  27591. program: Nullable<WebGLProgram>;
  27592. context?: WebGLRenderingContext;
  27593. vertexShader?: WebGLShader;
  27594. fragmentShader?: WebGLShader;
  27595. isParallelCompiled: boolean;
  27596. onCompiled?: () => void;
  27597. transformFeedback?: WebGLTransformFeedback | null;
  27598. readonly isAsync: boolean;
  27599. readonly isReady: boolean;
  27600. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  27601. }
  27602. }
  27603. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  27604. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  27605. /** @hidden */
  27606. export class WebGLDataBuffer extends DataBuffer {
  27607. private _buffer;
  27608. constructor(resource: WebGLBuffer);
  27609. readonly underlyingResource: any;
  27610. }
  27611. }
  27612. declare module "babylonjs/Materials/Textures/videoTexture" {
  27613. import { Observable } from "babylonjs/Misc/observable";
  27614. import { Nullable } from "babylonjs/types";
  27615. import { Scene } from "babylonjs/scene";
  27616. import { Texture } from "babylonjs/Materials/Textures/texture";
  27617. /**
  27618. * Settings for finer control over video usage
  27619. */
  27620. export interface VideoTextureSettings {
  27621. /**
  27622. * Applies `autoplay` to video, if specified
  27623. */
  27624. autoPlay?: boolean;
  27625. /**
  27626. * Applies `loop` to video, if specified
  27627. */
  27628. loop?: boolean;
  27629. /**
  27630. * Automatically updates internal texture from video at every frame in the render loop
  27631. */
  27632. autoUpdateTexture: boolean;
  27633. /**
  27634. * Image src displayed during the video loading or until the user interacts with the video.
  27635. */
  27636. poster?: string;
  27637. }
  27638. /**
  27639. * If you want to display a video in your scene, this is the special texture for that.
  27640. * This special texture works similar to other textures, with the exception of a few parameters.
  27641. * @see https://doc.babylonjs.com/how_to/video_texture
  27642. */
  27643. export class VideoTexture extends Texture {
  27644. /**
  27645. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  27646. */
  27647. readonly autoUpdateTexture: boolean;
  27648. /**
  27649. * The video instance used by the texture internally
  27650. */
  27651. readonly video: HTMLVideoElement;
  27652. private _onUserActionRequestedObservable;
  27653. /**
  27654. * Event triggerd when a dom action is required by the user to play the video.
  27655. * This happens due to recent changes in browser policies preventing video to auto start.
  27656. */
  27657. readonly onUserActionRequestedObservable: Observable<Texture>;
  27658. private _generateMipMaps;
  27659. private _engine;
  27660. private _stillImageCaptured;
  27661. private _displayingPosterTexture;
  27662. private _settings;
  27663. private _createInternalTextureOnEvent;
  27664. /**
  27665. * Creates a video texture.
  27666. * If you want to display a video in your scene, this is the special texture for that.
  27667. * This special texture works similar to other textures, with the exception of a few parameters.
  27668. * @see https://doc.babylonjs.com/how_to/video_texture
  27669. * @param name optional name, will detect from video source, if not defined
  27670. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  27671. * @param scene is obviously the current scene.
  27672. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  27673. * @param invertY is false by default but can be used to invert video on Y axis
  27674. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  27675. * @param settings allows finer control over video usage
  27676. */
  27677. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  27678. private _getName;
  27679. private _getVideo;
  27680. private _createInternalTexture;
  27681. private reset;
  27682. /**
  27683. * @hidden Internal method to initiate `update`.
  27684. */
  27685. _rebuild(): void;
  27686. /**
  27687. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  27688. */
  27689. update(): void;
  27690. /**
  27691. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  27692. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  27693. */
  27694. updateTexture(isVisible: boolean): void;
  27695. protected _updateInternalTexture: () => void;
  27696. /**
  27697. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  27698. * @param url New url.
  27699. */
  27700. updateURL(url: string): void;
  27701. /**
  27702. * Dispose the texture and release its associated resources.
  27703. */
  27704. dispose(): void;
  27705. /**
  27706. * Creates a video texture straight from a stream.
  27707. * @param scene Define the scene the texture should be created in
  27708. * @param stream Define the stream the texture should be created from
  27709. * @returns The created video texture as a promise
  27710. */
  27711. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  27712. /**
  27713. * Creates a video texture straight from your WebCam video feed.
  27714. * @param scene Define the scene the texture should be created in
  27715. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  27716. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  27717. * @returns The created video texture as a promise
  27718. */
  27719. static CreateFromWebCamAsync(scene: Scene, constraints: {
  27720. minWidth: number;
  27721. maxWidth: number;
  27722. minHeight: number;
  27723. maxHeight: number;
  27724. deviceId: string;
  27725. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  27726. /**
  27727. * Creates a video texture straight from your WebCam video feed.
  27728. * @param scene Define the scene the texture should be created in
  27729. * @param onReady Define a callback to triggered once the texture will be ready
  27730. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  27731. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  27732. */
  27733. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  27734. minWidth: number;
  27735. maxWidth: number;
  27736. minHeight: number;
  27737. maxHeight: number;
  27738. deviceId: string;
  27739. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  27740. }
  27741. }
  27742. declare module "babylonjs/Engines/engine" {
  27743. import { Observable } from "babylonjs/Misc/observable";
  27744. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  27745. import { ICustomAnimationFrameRequester, PerfCounter, IFileRequest } from "babylonjs/Misc/tools";
  27746. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  27747. import { Camera } from "babylonjs/Cameras/camera";
  27748. import { Scene } from "babylonjs/scene";
  27749. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  27750. import { IDisplayChangedEventArgs } from "babylonjs/Engines/engine";
  27751. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  27752. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  27753. import { Effect, EffectCreationOptions, EffectFallbacks } from "babylonjs/Materials/effect";
  27754. import { Material } from "babylonjs/Materials/material";
  27755. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  27756. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  27757. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  27758. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  27759. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  27760. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  27761. import { _DepthCullingState, _StencilState, _AlphaState } from "babylonjs/States/index";
  27762. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  27763. import { WebRequest } from "babylonjs/Misc/webRequest";
  27764. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  27765. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  27766. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  27767. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  27768. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  27769. /**
  27770. * Interface for attribute information associated with buffer instanciation
  27771. */
  27772. export class InstancingAttributeInfo {
  27773. /**
  27774. * Index/offset of the attribute in the vertex shader
  27775. */
  27776. index: number;
  27777. /**
  27778. * size of the attribute, 1, 2, 3 or 4
  27779. */
  27780. attributeSize: number;
  27781. /**
  27782. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  27783. * default is FLOAT
  27784. */
  27785. attribyteType: number;
  27786. /**
  27787. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  27788. */
  27789. normalized: boolean;
  27790. /**
  27791. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  27792. */
  27793. offset: number;
  27794. /**
  27795. * Name of the GLSL attribute, for debugging purpose only
  27796. */
  27797. attributeName: string;
  27798. }
  27799. /**
  27800. * Define options used to create a depth texture
  27801. */
  27802. export class DepthTextureCreationOptions {
  27803. /** Specifies whether or not a stencil should be allocated in the texture */
  27804. generateStencil?: boolean;
  27805. /** Specifies whether or not bilinear filtering is enable on the texture */
  27806. bilinearFiltering?: boolean;
  27807. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  27808. comparisonFunction?: number;
  27809. /** Specifies if the created texture is a cube texture */
  27810. isCube?: boolean;
  27811. }
  27812. /**
  27813. * Class used to describe the capabilities of the engine relatively to the current browser
  27814. */
  27815. export class EngineCapabilities {
  27816. /** Maximum textures units per fragment shader */
  27817. maxTexturesImageUnits: number;
  27818. /** Maximum texture units per vertex shader */
  27819. maxVertexTextureImageUnits: number;
  27820. /** Maximum textures units in the entire pipeline */
  27821. maxCombinedTexturesImageUnits: number;
  27822. /** Maximum texture size */
  27823. maxTextureSize: number;
  27824. /** Maximum cube texture size */
  27825. maxCubemapTextureSize: number;
  27826. /** Maximum render texture size */
  27827. maxRenderTextureSize: number;
  27828. /** Maximum number of vertex attributes */
  27829. maxVertexAttribs: number;
  27830. /** Maximum number of varyings */
  27831. maxVaryingVectors: number;
  27832. /** Maximum number of uniforms per vertex shader */
  27833. maxVertexUniformVectors: number;
  27834. /** Maximum number of uniforms per fragment shader */
  27835. maxFragmentUniformVectors: number;
  27836. /** Defines if standard derivates (dx/dy) are supported */
  27837. standardDerivatives: boolean;
  27838. /** Defines if s3tc texture compression is supported */
  27839. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  27840. /** Defines if pvrtc texture compression is supported */
  27841. pvrtc: any;
  27842. /** Defines if etc1 texture compression is supported */
  27843. etc1: any;
  27844. /** Defines if etc2 texture compression is supported */
  27845. etc2: any;
  27846. /** Defines if astc texture compression is supported */
  27847. astc: any;
  27848. /** Defines if float textures are supported */
  27849. textureFloat: boolean;
  27850. /** Defines if vertex array objects are supported */
  27851. vertexArrayObject: boolean;
  27852. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  27853. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  27854. /** Gets the maximum level of anisotropy supported */
  27855. maxAnisotropy: number;
  27856. /** Defines if instancing is supported */
  27857. instancedArrays: boolean;
  27858. /** Defines if 32 bits indices are supported */
  27859. uintIndices: boolean;
  27860. /** Defines if high precision shaders are supported */
  27861. highPrecisionShaderSupported: boolean;
  27862. /** Defines if depth reading in the fragment shader is supported */
  27863. fragmentDepthSupported: boolean;
  27864. /** Defines if float texture linear filtering is supported*/
  27865. textureFloatLinearFiltering: boolean;
  27866. /** Defines if rendering to float textures is supported */
  27867. textureFloatRender: boolean;
  27868. /** Defines if half float textures are supported*/
  27869. textureHalfFloat: boolean;
  27870. /** Defines if half float texture linear filtering is supported*/
  27871. textureHalfFloatLinearFiltering: boolean;
  27872. /** Defines if rendering to half float textures is supported */
  27873. textureHalfFloatRender: boolean;
  27874. /** Defines if textureLOD shader command is supported */
  27875. textureLOD: boolean;
  27876. /** Defines if draw buffers extension is supported */
  27877. drawBuffersExtension: boolean;
  27878. /** Defines if depth textures are supported */
  27879. depthTextureExtension: boolean;
  27880. /** Defines if float color buffer are supported */
  27881. colorBufferFloat: boolean;
  27882. /** Gets disjoint timer query extension (null if not supported) */
  27883. timerQuery: EXT_disjoint_timer_query;
  27884. /** Defines if timestamp can be used with timer query */
  27885. canUseTimestampForTimerQuery: boolean;
  27886. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  27887. multiview: any;
  27888. /** Function used to let the system compiles shaders in background */
  27889. parallelShaderCompile: {
  27890. COMPLETION_STATUS_KHR: number;
  27891. };
  27892. }
  27893. /** Interface defining initialization parameters for Engine class */
  27894. export interface EngineOptions extends WebGLContextAttributes {
  27895. /**
  27896. * Defines if the engine should no exceed a specified device ratio
  27897. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  27898. */
  27899. limitDeviceRatio?: number;
  27900. /**
  27901. * Defines if webvr should be enabled automatically
  27902. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27903. */
  27904. autoEnableWebVR?: boolean;
  27905. /**
  27906. * Defines if webgl2 should be turned off even if supported
  27907. * @see http://doc.babylonjs.com/features/webgl2
  27908. */
  27909. disableWebGL2Support?: boolean;
  27910. /**
  27911. * Defines if webaudio should be initialized as well
  27912. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27913. */
  27914. audioEngine?: boolean;
  27915. /**
  27916. * Defines if animations should run using a deterministic lock step
  27917. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27918. */
  27919. deterministicLockstep?: boolean;
  27920. /** Defines the maximum steps to use with deterministic lock step mode */
  27921. lockstepMaxSteps?: number;
  27922. /**
  27923. * Defines that engine should ignore context lost events
  27924. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  27925. */
  27926. doNotHandleContextLost?: boolean;
  27927. /**
  27928. * Defines that engine should ignore modifying touch action attribute and style
  27929. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  27930. */
  27931. doNotHandleTouchAction?: boolean;
  27932. /**
  27933. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  27934. */
  27935. useHighPrecisionFloats?: boolean;
  27936. }
  27937. /**
  27938. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  27939. */
  27940. export class Engine {
  27941. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  27942. static ExceptionList: ({
  27943. key: string;
  27944. capture: string;
  27945. captureConstraint: number;
  27946. targets: string[];
  27947. } | {
  27948. key: string;
  27949. capture: null;
  27950. captureConstraint: null;
  27951. targets: string[];
  27952. })[];
  27953. /** Gets the list of created engines */
  27954. static readonly Instances: Engine[];
  27955. /**
  27956. * Gets the latest created engine
  27957. */
  27958. static readonly LastCreatedEngine: Nullable<Engine>;
  27959. /**
  27960. * Gets the latest created scene
  27961. */
  27962. static readonly LastCreatedScene: Nullable<Scene>;
  27963. /**
  27964. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  27965. * @param flag defines which part of the materials must be marked as dirty
  27966. * @param predicate defines a predicate used to filter which materials should be affected
  27967. */
  27968. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  27969. /**
  27970. * Hidden
  27971. */
  27972. static _TextureLoaders: IInternalTextureLoader[];
  27973. /** Defines that alpha blending is disabled */
  27974. static readonly ALPHA_DISABLE: number;
  27975. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  27976. static readonly ALPHA_ADD: number;
  27977. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  27978. static readonly ALPHA_COMBINE: number;
  27979. /** Defines that alpha blending to DEST - SRC * DEST */
  27980. static readonly ALPHA_SUBTRACT: number;
  27981. /** Defines that alpha blending to SRC * DEST */
  27982. static readonly ALPHA_MULTIPLY: number;
  27983. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  27984. static readonly ALPHA_MAXIMIZED: number;
  27985. /** Defines that alpha blending to SRC + DEST */
  27986. static readonly ALPHA_ONEONE: number;
  27987. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  27988. static readonly ALPHA_PREMULTIPLIED: number;
  27989. /**
  27990. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  27991. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  27992. */
  27993. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  27994. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  27995. static readonly ALPHA_INTERPOLATE: number;
  27996. /**
  27997. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  27998. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  27999. */
  28000. static readonly ALPHA_SCREENMODE: number;
  28001. /** Defines that the ressource is not delayed*/
  28002. static readonly DELAYLOADSTATE_NONE: number;
  28003. /** Defines that the ressource was successfully delay loaded */
  28004. static readonly DELAYLOADSTATE_LOADED: number;
  28005. /** Defines that the ressource is currently delay loading */
  28006. static readonly DELAYLOADSTATE_LOADING: number;
  28007. /** Defines that the ressource is delayed and has not started loading */
  28008. static readonly DELAYLOADSTATE_NOTLOADED: number;
  28009. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  28010. static readonly NEVER: number;
  28011. /** 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 */
  28012. static readonly ALWAYS: number;
  28013. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  28014. static readonly LESS: number;
  28015. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  28016. static readonly EQUAL: number;
  28017. /** 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 */
  28018. static readonly LEQUAL: number;
  28019. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  28020. static readonly GREATER: number;
  28021. /** 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 */
  28022. static readonly GEQUAL: number;
  28023. /** 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 */
  28024. static readonly NOTEQUAL: number;
  28025. /** Passed to stencilOperation to specify that stencil value must be kept */
  28026. static readonly KEEP: number;
  28027. /** Passed to stencilOperation to specify that stencil value must be replaced */
  28028. static readonly REPLACE: number;
  28029. /** Passed to stencilOperation to specify that stencil value must be incremented */
  28030. static readonly INCR: number;
  28031. /** Passed to stencilOperation to specify that stencil value must be decremented */
  28032. static readonly DECR: number;
  28033. /** Passed to stencilOperation to specify that stencil value must be inverted */
  28034. static readonly INVERT: number;
  28035. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  28036. static readonly INCR_WRAP: number;
  28037. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  28038. static readonly DECR_WRAP: number;
  28039. /** Texture is not repeating outside of 0..1 UVs */
  28040. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  28041. /** Texture is repeating outside of 0..1 UVs */
  28042. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  28043. /** Texture is repeating and mirrored */
  28044. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  28045. /** ALPHA */
  28046. static readonly TEXTUREFORMAT_ALPHA: number;
  28047. /** LUMINANCE */
  28048. static readonly TEXTUREFORMAT_LUMINANCE: number;
  28049. /** LUMINANCE_ALPHA */
  28050. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  28051. /** RGB */
  28052. static readonly TEXTUREFORMAT_RGB: number;
  28053. /** RGBA */
  28054. static readonly TEXTUREFORMAT_RGBA: number;
  28055. /** RED */
  28056. static readonly TEXTUREFORMAT_RED: number;
  28057. /** RED (2nd reference) */
  28058. static readonly TEXTUREFORMAT_R: number;
  28059. /** RG */
  28060. static readonly TEXTUREFORMAT_RG: number;
  28061. /** RED_INTEGER */
  28062. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  28063. /** RED_INTEGER (2nd reference) */
  28064. static readonly TEXTUREFORMAT_R_INTEGER: number;
  28065. /** RG_INTEGER */
  28066. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  28067. /** RGB_INTEGER */
  28068. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  28069. /** RGBA_INTEGER */
  28070. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  28071. /** UNSIGNED_BYTE */
  28072. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  28073. /** UNSIGNED_BYTE (2nd reference) */
  28074. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  28075. /** FLOAT */
  28076. static readonly TEXTURETYPE_FLOAT: number;
  28077. /** HALF_FLOAT */
  28078. static readonly TEXTURETYPE_HALF_FLOAT: number;
  28079. /** BYTE */
  28080. static readonly TEXTURETYPE_BYTE: number;
  28081. /** SHORT */
  28082. static readonly TEXTURETYPE_SHORT: number;
  28083. /** UNSIGNED_SHORT */
  28084. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  28085. /** INT */
  28086. static readonly TEXTURETYPE_INT: number;
  28087. /** UNSIGNED_INT */
  28088. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  28089. /** UNSIGNED_SHORT_4_4_4_4 */
  28090. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  28091. /** UNSIGNED_SHORT_5_5_5_1 */
  28092. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  28093. /** UNSIGNED_SHORT_5_6_5 */
  28094. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  28095. /** UNSIGNED_INT_2_10_10_10_REV */
  28096. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  28097. /** UNSIGNED_INT_24_8 */
  28098. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  28099. /** UNSIGNED_INT_10F_11F_11F_REV */
  28100. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  28101. /** UNSIGNED_INT_5_9_9_9_REV */
  28102. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  28103. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  28104. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  28105. /** nearest is mag = nearest and min = nearest and mip = linear */
  28106. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  28107. /** Bilinear is mag = linear and min = linear and mip = nearest */
  28108. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  28109. /** Trilinear is mag = linear and min = linear and mip = linear */
  28110. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  28111. /** nearest is mag = nearest and min = nearest and mip = linear */
  28112. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  28113. /** Bilinear is mag = linear and min = linear and mip = nearest */
  28114. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  28115. /** Trilinear is mag = linear and min = linear and mip = linear */
  28116. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  28117. /** mag = nearest and min = nearest and mip = nearest */
  28118. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  28119. /** mag = nearest and min = linear and mip = nearest */
  28120. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  28121. /** mag = nearest and min = linear and mip = linear */
  28122. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  28123. /** mag = nearest and min = linear and mip = none */
  28124. static readonly TEXTURE_NEAREST_LINEAR: number;
  28125. /** mag = nearest and min = nearest and mip = none */
  28126. static readonly TEXTURE_NEAREST_NEAREST: number;
  28127. /** mag = linear and min = nearest and mip = nearest */
  28128. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  28129. /** mag = linear and min = nearest and mip = linear */
  28130. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  28131. /** mag = linear and min = linear and mip = none */
  28132. static readonly TEXTURE_LINEAR_LINEAR: number;
  28133. /** mag = linear and min = nearest and mip = none */
  28134. static readonly TEXTURE_LINEAR_NEAREST: number;
  28135. /** Explicit coordinates mode */
  28136. static readonly TEXTURE_EXPLICIT_MODE: number;
  28137. /** Spherical coordinates mode */
  28138. static readonly TEXTURE_SPHERICAL_MODE: number;
  28139. /** Planar coordinates mode */
  28140. static readonly TEXTURE_PLANAR_MODE: number;
  28141. /** Cubic coordinates mode */
  28142. static readonly TEXTURE_CUBIC_MODE: number;
  28143. /** Projection coordinates mode */
  28144. static readonly TEXTURE_PROJECTION_MODE: number;
  28145. /** Skybox coordinates mode */
  28146. static readonly TEXTURE_SKYBOX_MODE: number;
  28147. /** Inverse Cubic coordinates mode */
  28148. static readonly TEXTURE_INVCUBIC_MODE: number;
  28149. /** Equirectangular coordinates mode */
  28150. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  28151. /** Equirectangular Fixed coordinates mode */
  28152. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  28153. /** Equirectangular Fixed Mirrored coordinates mode */
  28154. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  28155. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  28156. static readonly SCALEMODE_FLOOR: number;
  28157. /** Defines that texture rescaling will look for the nearest power of 2 size */
  28158. static readonly SCALEMODE_NEAREST: number;
  28159. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  28160. static readonly SCALEMODE_CEILING: number;
  28161. /**
  28162. * Returns the current npm package of the sdk
  28163. */
  28164. static readonly NpmPackage: string;
  28165. /**
  28166. * Returns the current version of the framework
  28167. */
  28168. static readonly Version: string;
  28169. /**
  28170. * Returns a string describing the current engine
  28171. */
  28172. readonly description: string;
  28173. /**
  28174. * Gets or sets the epsilon value used by collision engine
  28175. */
  28176. static CollisionsEpsilon: number;
  28177. /**
  28178. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28179. */
  28180. static ShadersRepository: string;
  28181. /**
  28182. * Method called to create the default loading screen.
  28183. * This can be overriden in your own app.
  28184. * @param canvas The rendering canvas element
  28185. * @returns The loading screen
  28186. */
  28187. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  28188. /**
  28189. * Method called to create the default rescale post process on each engine.
  28190. */
  28191. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  28192. /**
  28193. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  28194. */
  28195. forcePOTTextures: boolean;
  28196. /**
  28197. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  28198. */
  28199. isFullscreen: boolean;
  28200. /**
  28201. * Gets a boolean indicating if the pointer is currently locked
  28202. */
  28203. isPointerLock: boolean;
  28204. /**
  28205. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  28206. */
  28207. cullBackFaces: boolean;
  28208. /**
  28209. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  28210. */
  28211. renderEvenInBackground: boolean;
  28212. /**
  28213. * Gets or sets a boolean indicating that cache can be kept between frames
  28214. */
  28215. preventCacheWipeBetweenFrames: boolean;
  28216. /**
  28217. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  28218. **/
  28219. enableOfflineSupport: boolean;
  28220. /**
  28221. * 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)
  28222. **/
  28223. disableManifestCheck: boolean;
  28224. /**
  28225. * Gets the list of created scenes
  28226. */
  28227. scenes: Scene[];
  28228. /**
  28229. * Event raised when a new scene is created
  28230. */
  28231. onNewSceneAddedObservable: Observable<Scene>;
  28232. /**
  28233. * Gets the list of created postprocesses
  28234. */
  28235. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  28236. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  28237. validateShaderPrograms: boolean;
  28238. /**
  28239. * Observable event triggered each time the rendering canvas is resized
  28240. */
  28241. onResizeObservable: Observable<Engine>;
  28242. /**
  28243. * Observable event triggered each time the canvas loses focus
  28244. */
  28245. onCanvasBlurObservable: Observable<Engine>;
  28246. /**
  28247. * Observable event triggered each time the canvas gains focus
  28248. */
  28249. onCanvasFocusObservable: Observable<Engine>;
  28250. /**
  28251. * Observable event triggered each time the canvas receives pointerout event
  28252. */
  28253. onCanvasPointerOutObservable: Observable<PointerEvent>;
  28254. /**
  28255. * Observable event triggered before each texture is initialized
  28256. */
  28257. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  28258. /**
  28259. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  28260. */
  28261. disableUniformBuffers: boolean;
  28262. /** @hidden */
  28263. _uniformBuffers: UniformBuffer[];
  28264. /**
  28265. * Gets a boolean indicating that the engine supports uniform buffers
  28266. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28267. */
  28268. readonly supportsUniformBuffers: boolean;
  28269. /**
  28270. * Observable raised when the engine begins a new frame
  28271. */
  28272. onBeginFrameObservable: Observable<Engine>;
  28273. /**
  28274. * If set, will be used to request the next animation frame for the render loop
  28275. */
  28276. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  28277. /**
  28278. * Observable raised when the engine ends the current frame
  28279. */
  28280. onEndFrameObservable: Observable<Engine>;
  28281. /**
  28282. * Observable raised when the engine is about to compile a shader
  28283. */
  28284. onBeforeShaderCompilationObservable: Observable<Engine>;
  28285. /**
  28286. * Observable raised when the engine has jsut compiled a shader
  28287. */
  28288. onAfterShaderCompilationObservable: Observable<Engine>;
  28289. /** @hidden */
  28290. _gl: WebGLRenderingContext;
  28291. private _renderingCanvas;
  28292. private _windowIsBackground;
  28293. private _webGLVersion;
  28294. protected _highPrecisionShadersAllowed: boolean;
  28295. /** @hidden */
  28296. readonly _shouldUseHighPrecisionShader: boolean;
  28297. /**
  28298. * Gets a boolean indicating that only power of 2 textures are supported
  28299. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  28300. */
  28301. readonly needPOTTextures: boolean;
  28302. /** @hidden */
  28303. _badOS: boolean;
  28304. /** @hidden */
  28305. _badDesktopOS: boolean;
  28306. /**
  28307. * Gets the audio engine
  28308. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  28309. * @ignorenaming
  28310. */
  28311. static audioEngine: IAudioEngine;
  28312. /**
  28313. * Default AudioEngine factory responsible of creating the Audio Engine.
  28314. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  28315. */
  28316. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  28317. /**
  28318. * Default offline support factory responsible of creating a tool used to store data locally.
  28319. * By default, this will create a Database object if the workload has been embedded.
  28320. */
  28321. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  28322. private _onFocus;
  28323. private _onBlur;
  28324. private _onCanvasPointerOut;
  28325. private _onCanvasBlur;
  28326. private _onCanvasFocus;
  28327. private _onFullscreenChange;
  28328. private _onPointerLockChange;
  28329. private _hardwareScalingLevel;
  28330. /** @hidden */
  28331. _caps: EngineCapabilities;
  28332. private _pointerLockRequested;
  28333. private _isStencilEnable;
  28334. private _colorWrite;
  28335. private _loadingScreen;
  28336. /** @hidden */
  28337. _drawCalls: PerfCounter;
  28338. private _glVersion;
  28339. private _glRenderer;
  28340. private _glVendor;
  28341. private _videoTextureSupported;
  28342. private _renderingQueueLaunched;
  28343. private _activeRenderLoops;
  28344. private _deterministicLockstep;
  28345. private _lockstepMaxSteps;
  28346. /**
  28347. * Observable signaled when a context lost event is raised
  28348. */
  28349. onContextLostObservable: Observable<Engine>;
  28350. /**
  28351. * Observable signaled when a context restored event is raised
  28352. */
  28353. onContextRestoredObservable: Observable<Engine>;
  28354. private _onContextLost;
  28355. private _onContextRestored;
  28356. private _contextWasLost;
  28357. /** @hidden */
  28358. _doNotHandleContextLost: boolean;
  28359. /**
  28360. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  28361. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  28362. */
  28363. doNotHandleContextLost: boolean;
  28364. private _performanceMonitor;
  28365. private _fps;
  28366. private _deltaTime;
  28367. /**
  28368. * Turn this value on if you want to pause FPS computation when in background
  28369. */
  28370. disablePerformanceMonitorInBackground: boolean;
  28371. /**
  28372. * Gets the performance monitor attached to this engine
  28373. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  28374. */
  28375. readonly performanceMonitor: PerformanceMonitor;
  28376. /**
  28377. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  28378. */
  28379. disableVertexArrayObjects: boolean;
  28380. /** @hidden */
  28381. protected _depthCullingState: _DepthCullingState;
  28382. /** @hidden */
  28383. protected _stencilState: _StencilState;
  28384. /** @hidden */
  28385. protected _alphaState: _AlphaState;
  28386. /** @hidden */
  28387. protected _alphaMode: number;
  28388. /** @hidden */
  28389. _internalTexturesCache: InternalTexture[];
  28390. /** @hidden */
  28391. protected _activeChannel: number;
  28392. private _currentTextureChannel;
  28393. /** @hidden */
  28394. protected _boundTexturesCache: {
  28395. [key: string]: Nullable<InternalTexture>;
  28396. };
  28397. /** @hidden */
  28398. protected _currentEffect: Nullable<Effect>;
  28399. /** @hidden */
  28400. protected _currentProgram: Nullable<WebGLProgram>;
  28401. private _compiledEffects;
  28402. private _vertexAttribArraysEnabled;
  28403. /** @hidden */
  28404. protected _cachedViewport: Nullable<Viewport>;
  28405. private _cachedVertexArrayObject;
  28406. /** @hidden */
  28407. protected _cachedVertexBuffers: any;
  28408. /** @hidden */
  28409. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  28410. /** @hidden */
  28411. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  28412. /** @hidden */
  28413. _currentRenderTarget: Nullable<InternalTexture>;
  28414. private _uintIndicesCurrentlySet;
  28415. private _currentBoundBuffer;
  28416. /** @hidden */
  28417. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  28418. private _currentBufferPointers;
  28419. private _currentInstanceLocations;
  28420. private _currentInstanceBuffers;
  28421. private _textureUnits;
  28422. /** @hidden */
  28423. _workingCanvas: Nullable<HTMLCanvasElement>;
  28424. /** @hidden */
  28425. _workingContext: Nullable<CanvasRenderingContext2D>;
  28426. private _rescalePostProcess;
  28427. private _dummyFramebuffer;
  28428. private _externalData;
  28429. /** @hidden */
  28430. _bindedRenderFunction: any;
  28431. private _vaoRecordInProgress;
  28432. private _mustWipeVertexAttributes;
  28433. private _emptyTexture;
  28434. private _emptyCubeTexture;
  28435. private _emptyTexture3D;
  28436. /** @hidden */
  28437. _frameHandler: number;
  28438. private _nextFreeTextureSlots;
  28439. private _maxSimultaneousTextures;
  28440. private _activeRequests;
  28441. private _texturesSupported;
  28442. /** @hidden */
  28443. _textureFormatInUse: Nullable<string>;
  28444. /**
  28445. * Gets the list of texture formats supported
  28446. */
  28447. readonly texturesSupported: Array<string>;
  28448. /**
  28449. * Gets the list of texture formats in use
  28450. */
  28451. readonly textureFormatInUse: Nullable<string>;
  28452. /**
  28453. * Gets the current viewport
  28454. */
  28455. readonly currentViewport: Nullable<Viewport>;
  28456. /**
  28457. * Gets the default empty texture
  28458. */
  28459. readonly emptyTexture: InternalTexture;
  28460. /**
  28461. * Gets the default empty 3D texture
  28462. */
  28463. readonly emptyTexture3D: InternalTexture;
  28464. /**
  28465. * Gets the default empty cube texture
  28466. */
  28467. readonly emptyCubeTexture: InternalTexture;
  28468. /**
  28469. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  28470. */
  28471. readonly premultipliedAlpha: boolean;
  28472. /**
  28473. * Creates a new engine
  28474. * @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
  28475. * @param antialias defines enable antialiasing (default: false)
  28476. * @param options defines further options to be sent to the getContext() function
  28477. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  28478. */
  28479. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  28480. /**
  28481. * Initializes a webVR display and starts listening to display change events
  28482. * The onVRDisplayChangedObservable will be notified upon these changes
  28483. * @returns The onVRDisplayChangedObservable
  28484. */
  28485. initWebVR(): Observable<IDisplayChangedEventArgs>;
  28486. /** @hidden */
  28487. _prepareVRComponent(): void;
  28488. /** @hidden */
  28489. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  28490. /** @hidden */
  28491. _submitVRFrame(): void;
  28492. /**
  28493. * Call this function to leave webVR mode
  28494. * Will do nothing if webVR is not supported or if there is no webVR device
  28495. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28496. */
  28497. disableVR(): void;
  28498. /**
  28499. * Gets a boolean indicating that the system is in VR mode and is presenting
  28500. * @returns true if VR mode is engaged
  28501. */
  28502. isVRPresenting(): boolean;
  28503. /** @hidden */
  28504. _requestVRFrame(): void;
  28505. private _disableTouchAction;
  28506. private _rebuildInternalTextures;
  28507. private _rebuildEffects;
  28508. /**
  28509. * Gets a boolean indicating if all created effects are ready
  28510. * @returns true if all effects are ready
  28511. */
  28512. areAllEffectsReady(): boolean;
  28513. private _rebuildBuffers;
  28514. private _initGLContext;
  28515. /**
  28516. * Gets version of the current webGL context
  28517. */
  28518. readonly webGLVersion: number;
  28519. /**
  28520. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  28521. */
  28522. readonly isStencilEnable: boolean;
  28523. /** @hidden */
  28524. _prepareWorkingCanvas(): void;
  28525. /**
  28526. * Reset the texture cache to empty state
  28527. */
  28528. resetTextureCache(): void;
  28529. /**
  28530. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  28531. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28532. * @returns true if engine is in deterministic lock step mode
  28533. */
  28534. isDeterministicLockStep(): boolean;
  28535. /**
  28536. * Gets the max steps when engine is running in deterministic lock step
  28537. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28538. * @returns the max steps
  28539. */
  28540. getLockstepMaxSteps(): number;
  28541. /**
  28542. * Gets an object containing information about the current webGL context
  28543. * @returns an object containing the vender, the renderer and the version of the current webGL context
  28544. */
  28545. getGlInfo(): {
  28546. vendor: string;
  28547. renderer: string;
  28548. version: string;
  28549. };
  28550. /**
  28551. * Gets current aspect ratio
  28552. * @param camera defines the camera to use to get the aspect ratio
  28553. * @param useScreen defines if screen size must be used (or the current render target if any)
  28554. * @returns a number defining the aspect ratio
  28555. */
  28556. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  28557. /**
  28558. * Gets current screen aspect ratio
  28559. * @returns a number defining the aspect ratio
  28560. */
  28561. getScreenAspectRatio(): number;
  28562. /**
  28563. * Gets the current render width
  28564. * @param useScreen defines if screen size must be used (or the current render target if any)
  28565. * @returns a number defining the current render width
  28566. */
  28567. getRenderWidth(useScreen?: boolean): number;
  28568. /**
  28569. * Gets the current render height
  28570. * @param useScreen defines if screen size must be used (or the current render target if any)
  28571. * @returns a number defining the current render height
  28572. */
  28573. getRenderHeight(useScreen?: boolean): number;
  28574. /**
  28575. * Gets the HTML canvas attached with the current webGL context
  28576. * @returns a HTML canvas
  28577. */
  28578. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  28579. /**
  28580. * Gets the client rect of the HTML canvas attached with the current webGL context
  28581. * @returns a client rectanglee
  28582. */
  28583. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  28584. /**
  28585. * Defines the hardware scaling level.
  28586. * By default the hardware scaling level is computed from the window device ratio.
  28587. * 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.
  28588. * @param level defines the level to use
  28589. */
  28590. setHardwareScalingLevel(level: number): void;
  28591. /**
  28592. * Gets the current hardware scaling level.
  28593. * By default the hardware scaling level is computed from the window device ratio.
  28594. * 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.
  28595. * @returns a number indicating the current hardware scaling level
  28596. */
  28597. getHardwareScalingLevel(): number;
  28598. /**
  28599. * Gets the list of loaded textures
  28600. * @returns an array containing all loaded textures
  28601. */
  28602. getLoadedTexturesCache(): InternalTexture[];
  28603. /**
  28604. * Gets the object containing all engine capabilities
  28605. * @returns the EngineCapabilities object
  28606. */
  28607. getCaps(): EngineCapabilities;
  28608. /**
  28609. * Gets the current depth function
  28610. * @returns a number defining the depth function
  28611. */
  28612. getDepthFunction(): Nullable<number>;
  28613. /**
  28614. * Sets the current depth function
  28615. * @param depthFunc defines the function to use
  28616. */
  28617. setDepthFunction(depthFunc: number): void;
  28618. /**
  28619. * Sets the current depth function to GREATER
  28620. */
  28621. setDepthFunctionToGreater(): void;
  28622. /**
  28623. * Sets the current depth function to GEQUAL
  28624. */
  28625. setDepthFunctionToGreaterOrEqual(): void;
  28626. /**
  28627. * Sets the current depth function to LESS
  28628. */
  28629. setDepthFunctionToLess(): void;
  28630. private _cachedStencilBuffer;
  28631. private _cachedStencilFunction;
  28632. private _cachedStencilMask;
  28633. private _cachedStencilOperationPass;
  28634. private _cachedStencilOperationFail;
  28635. private _cachedStencilOperationDepthFail;
  28636. private _cachedStencilReference;
  28637. /**
  28638. * Caches the the state of the stencil buffer
  28639. */
  28640. cacheStencilState(): void;
  28641. /**
  28642. * Restores the state of the stencil buffer
  28643. */
  28644. restoreStencilState(): void;
  28645. /**
  28646. * Sets the current depth function to LEQUAL
  28647. */
  28648. setDepthFunctionToLessOrEqual(): void;
  28649. /**
  28650. * Gets a boolean indicating if stencil buffer is enabled
  28651. * @returns the current stencil buffer state
  28652. */
  28653. getStencilBuffer(): boolean;
  28654. /**
  28655. * Enable or disable the stencil buffer
  28656. * @param enable defines if the stencil buffer must be enabled or disabled
  28657. */
  28658. setStencilBuffer(enable: boolean): void;
  28659. /**
  28660. * Gets the current stencil mask
  28661. * @returns a number defining the new stencil mask to use
  28662. */
  28663. getStencilMask(): number;
  28664. /**
  28665. * Sets the current stencil mask
  28666. * @param mask defines the new stencil mask to use
  28667. */
  28668. setStencilMask(mask: number): void;
  28669. /**
  28670. * Gets the current stencil function
  28671. * @returns a number defining the stencil function to use
  28672. */
  28673. getStencilFunction(): number;
  28674. /**
  28675. * Gets the current stencil reference value
  28676. * @returns a number defining the stencil reference value to use
  28677. */
  28678. getStencilFunctionReference(): number;
  28679. /**
  28680. * Gets the current stencil mask
  28681. * @returns a number defining the stencil mask to use
  28682. */
  28683. getStencilFunctionMask(): number;
  28684. /**
  28685. * Sets the current stencil function
  28686. * @param stencilFunc defines the new stencil function to use
  28687. */
  28688. setStencilFunction(stencilFunc: number): void;
  28689. /**
  28690. * Sets the current stencil reference
  28691. * @param reference defines the new stencil reference to use
  28692. */
  28693. setStencilFunctionReference(reference: number): void;
  28694. /**
  28695. * Sets the current stencil mask
  28696. * @param mask defines the new stencil mask to use
  28697. */
  28698. setStencilFunctionMask(mask: number): void;
  28699. /**
  28700. * Gets the current stencil operation when stencil fails
  28701. * @returns a number defining stencil operation to use when stencil fails
  28702. */
  28703. getStencilOperationFail(): number;
  28704. /**
  28705. * Gets the current stencil operation when depth fails
  28706. * @returns a number defining stencil operation to use when depth fails
  28707. */
  28708. getStencilOperationDepthFail(): number;
  28709. /**
  28710. * Gets the current stencil operation when stencil passes
  28711. * @returns a number defining stencil operation to use when stencil passes
  28712. */
  28713. getStencilOperationPass(): number;
  28714. /**
  28715. * Sets the stencil operation to use when stencil fails
  28716. * @param operation defines the stencil operation to use when stencil fails
  28717. */
  28718. setStencilOperationFail(operation: number): void;
  28719. /**
  28720. * Sets the stencil operation to use when depth fails
  28721. * @param operation defines the stencil operation to use when depth fails
  28722. */
  28723. setStencilOperationDepthFail(operation: number): void;
  28724. /**
  28725. * Sets the stencil operation to use when stencil passes
  28726. * @param operation defines the stencil operation to use when stencil passes
  28727. */
  28728. setStencilOperationPass(operation: number): void;
  28729. /**
  28730. * Sets a boolean indicating if the dithering state is enabled or disabled
  28731. * @param value defines the dithering state
  28732. */
  28733. setDitheringState(value: boolean): void;
  28734. /**
  28735. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  28736. * @param value defines the rasterizer state
  28737. */
  28738. setRasterizerState(value: boolean): void;
  28739. /**
  28740. * stop executing a render loop function and remove it from the execution array
  28741. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  28742. */
  28743. stopRenderLoop(renderFunction?: () => void): void;
  28744. /** @hidden */
  28745. _renderLoop(): void;
  28746. /**
  28747. * Register and execute a render loop. The engine can have more than one render function
  28748. * @param renderFunction defines the function to continuously execute
  28749. */
  28750. runRenderLoop(renderFunction: () => void): void;
  28751. /**
  28752. * Toggle full screen mode
  28753. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28754. */
  28755. switchFullscreen(requestPointerLock: boolean): void;
  28756. /**
  28757. * Enters full screen mode
  28758. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28759. */
  28760. enterFullscreen(requestPointerLock: boolean): void;
  28761. /**
  28762. * Exits full screen mode
  28763. */
  28764. exitFullscreen(): void;
  28765. /**
  28766. * Clear the current render buffer or the current render target (if any is set up)
  28767. * @param color defines the color to use
  28768. * @param backBuffer defines if the back buffer must be cleared
  28769. * @param depth defines if the depth buffer must be cleared
  28770. * @param stencil defines if the stencil buffer must be cleared
  28771. */
  28772. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  28773. /**
  28774. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  28775. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28776. * @param y defines the y-coordinate of the corner of the clear rectangle
  28777. * @param width defines the width of the clear rectangle
  28778. * @param height defines the height of the clear rectangle
  28779. * @param clearColor defines the clear color
  28780. */
  28781. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  28782. /**
  28783. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  28784. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28785. * @param y defines the y-coordinate of the corner of the clear rectangle
  28786. * @param width defines the width of the clear rectangle
  28787. * @param height defines the height of the clear rectangle
  28788. */
  28789. enableScissor(x: number, y: number, width: number, height: number): void;
  28790. /**
  28791. * Disable previously set scissor test rectangle
  28792. */
  28793. disableScissor(): void;
  28794. private _viewportCached;
  28795. /** @hidden */
  28796. _viewport(x: number, y: number, width: number, height: number): void;
  28797. /**
  28798. * Set the WebGL's viewport
  28799. * @param viewport defines the viewport element to be used
  28800. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  28801. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  28802. */
  28803. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  28804. /**
  28805. * Directly set the WebGL Viewport
  28806. * @param x defines the x coordinate of the viewport (in screen space)
  28807. * @param y defines the y coordinate of the viewport (in screen space)
  28808. * @param width defines the width of the viewport (in screen space)
  28809. * @param height defines the height of the viewport (in screen space)
  28810. * @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
  28811. */
  28812. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  28813. /**
  28814. * Begin a new frame
  28815. */
  28816. beginFrame(): void;
  28817. /**
  28818. * Enf the current frame
  28819. */
  28820. endFrame(): void;
  28821. /**
  28822. * Resize the view according to the canvas' size
  28823. */
  28824. resize(): void;
  28825. /**
  28826. * Force a specific size of the canvas
  28827. * @param width defines the new canvas' width
  28828. * @param height defines the new canvas' height
  28829. */
  28830. setSize(width: number, height: number): void;
  28831. /**
  28832. * Binds the frame buffer to the specified texture.
  28833. * @param texture The texture to render to or null for the default canvas
  28834. * @param faceIndex The face of the texture to render to in case of cube texture
  28835. * @param requiredWidth The width of the target to render to
  28836. * @param requiredHeight The height of the target to render to
  28837. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  28838. * @param depthStencilTexture The depth stencil texture to use to render
  28839. * @param lodLevel defines le lod level to bind to the frame buffer
  28840. */
  28841. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  28842. /** @hidden */
  28843. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  28844. /**
  28845. * Unbind the current render target texture from the webGL context
  28846. * @param texture defines the render target texture to unbind
  28847. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  28848. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  28849. */
  28850. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  28851. /**
  28852. * Force the mipmap generation for the given render target texture
  28853. * @param texture defines the render target texture to use
  28854. */
  28855. generateMipMapsForCubemap(texture: InternalTexture): void;
  28856. /**
  28857. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  28858. */
  28859. flushFramebuffer(): void;
  28860. /**
  28861. * Unbind the current render target and bind the default framebuffer
  28862. */
  28863. restoreDefaultFramebuffer(): void;
  28864. /**
  28865. * Create an uniform buffer
  28866. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28867. * @param elements defines the content of the uniform buffer
  28868. * @returns the webGL uniform buffer
  28869. */
  28870. createUniformBuffer(elements: FloatArray): DataBuffer;
  28871. /**
  28872. * Create a dynamic uniform buffer
  28873. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28874. * @param elements defines the content of the uniform buffer
  28875. * @returns the webGL uniform buffer
  28876. */
  28877. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  28878. /**
  28879. * Update an existing uniform buffer
  28880. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28881. * @param uniformBuffer defines the target uniform buffer
  28882. * @param elements defines the content to update
  28883. * @param offset defines the offset in the uniform buffer where update should start
  28884. * @param count defines the size of the data to update
  28885. */
  28886. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  28887. private _resetVertexBufferBinding;
  28888. /**
  28889. * Creates a vertex buffer
  28890. * @param data the data for the vertex buffer
  28891. * @returns the new WebGL static buffer
  28892. */
  28893. createVertexBuffer(data: DataArray): DataBuffer;
  28894. /**
  28895. * Creates a dynamic vertex buffer
  28896. * @param data the data for the dynamic vertex buffer
  28897. * @returns the new WebGL dynamic buffer
  28898. */
  28899. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  28900. /**
  28901. * Update a dynamic index buffer
  28902. * @param indexBuffer defines the target index buffer
  28903. * @param indices defines the data to update
  28904. * @param offset defines the offset in the target index buffer where update should start
  28905. */
  28906. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  28907. /**
  28908. * Updates a dynamic vertex buffer.
  28909. * @param vertexBuffer the vertex buffer to update
  28910. * @param data the data used to update the vertex buffer
  28911. * @param byteOffset the byte offset of the data
  28912. * @param byteLength the byte length of the data
  28913. */
  28914. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  28915. private _resetIndexBufferBinding;
  28916. /**
  28917. * Creates a new index buffer
  28918. * @param indices defines the content of the index buffer
  28919. * @param updatable defines if the index buffer must be updatable
  28920. * @returns a new webGL buffer
  28921. */
  28922. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  28923. /**
  28924. * Bind a webGL buffer to the webGL context
  28925. * @param buffer defines the buffer to bind
  28926. */
  28927. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  28928. /**
  28929. * Bind an uniform buffer to the current webGL context
  28930. * @param buffer defines the buffer to bind
  28931. */
  28932. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  28933. /**
  28934. * Bind a buffer to the current webGL context at a given location
  28935. * @param buffer defines the buffer to bind
  28936. * @param location defines the index where to bind the buffer
  28937. */
  28938. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  28939. /**
  28940. * Bind a specific block at a given index in a specific shader program
  28941. * @param pipelineContext defines the pipeline context to use
  28942. * @param blockName defines the block name
  28943. * @param index defines the index where to bind the block
  28944. */
  28945. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  28946. private bindIndexBuffer;
  28947. private bindBuffer;
  28948. /**
  28949. * update the bound buffer with the given data
  28950. * @param data defines the data to update
  28951. */
  28952. updateArrayBuffer(data: Float32Array): void;
  28953. private _vertexAttribPointer;
  28954. private _bindIndexBufferWithCache;
  28955. private _bindVertexBuffersAttributes;
  28956. /**
  28957. * Records a vertex array object
  28958. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28959. * @param vertexBuffers defines the list of vertex buffers to store
  28960. * @param indexBuffer defines the index buffer to store
  28961. * @param effect defines the effect to store
  28962. * @returns the new vertex array object
  28963. */
  28964. recordVertexArrayObject(vertexBuffers: {
  28965. [key: string]: VertexBuffer;
  28966. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  28967. /**
  28968. * Bind a specific vertex array object
  28969. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28970. * @param vertexArrayObject defines the vertex array object to bind
  28971. * @param indexBuffer defines the index buffer to bind
  28972. */
  28973. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  28974. /**
  28975. * Bind webGl buffers directly to the webGL context
  28976. * @param vertexBuffer defines the vertex buffer to bind
  28977. * @param indexBuffer defines the index buffer to bind
  28978. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  28979. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  28980. * @param effect defines the effect associated with the vertex buffer
  28981. */
  28982. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  28983. private _unbindVertexArrayObject;
  28984. /**
  28985. * Bind a list of vertex buffers to the webGL context
  28986. * @param vertexBuffers defines the list of vertex buffers to bind
  28987. * @param indexBuffer defines the index buffer to bind
  28988. * @param effect defines the effect associated with the vertex buffers
  28989. */
  28990. bindBuffers(vertexBuffers: {
  28991. [key: string]: Nullable<VertexBuffer>;
  28992. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  28993. /**
  28994. * Unbind all instance attributes
  28995. */
  28996. unbindInstanceAttributes(): void;
  28997. /**
  28998. * Release and free the memory of a vertex array object
  28999. * @param vao defines the vertex array object to delete
  29000. */
  29001. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  29002. /** @hidden */
  29003. _releaseBuffer(buffer: DataBuffer): boolean;
  29004. /**
  29005. * Creates a webGL buffer to use with instanciation
  29006. * @param capacity defines the size of the buffer
  29007. * @returns the webGL buffer
  29008. */
  29009. createInstancesBuffer(capacity: number): DataBuffer;
  29010. /**
  29011. * Delete a webGL buffer used with instanciation
  29012. * @param buffer defines the webGL buffer to delete
  29013. */
  29014. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  29015. /**
  29016. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  29017. * @param instancesBuffer defines the webGL buffer to update and bind
  29018. * @param data defines the data to store in the buffer
  29019. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  29020. */
  29021. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  29022. /**
  29023. * Apply all cached states (depth, culling, stencil and alpha)
  29024. */
  29025. applyStates(): void;
  29026. /**
  29027. * Send a draw order
  29028. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29029. * @param indexStart defines the starting index
  29030. * @param indexCount defines the number of index to draw
  29031. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29032. */
  29033. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  29034. /**
  29035. * Draw a list of points
  29036. * @param verticesStart defines the index of first vertex to draw
  29037. * @param verticesCount defines the count of vertices to draw
  29038. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29039. */
  29040. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29041. /**
  29042. * Draw a list of unindexed primitives
  29043. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29044. * @param verticesStart defines the index of first vertex to draw
  29045. * @param verticesCount defines the count of vertices to draw
  29046. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29047. */
  29048. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29049. /**
  29050. * Draw a list of indexed primitives
  29051. * @param fillMode defines the primitive to use
  29052. * @param indexStart defines the starting index
  29053. * @param indexCount defines the number of index to draw
  29054. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29055. */
  29056. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  29057. /**
  29058. * Draw a list of unindexed primitives
  29059. * @param fillMode defines the primitive to use
  29060. * @param verticesStart defines the index of first vertex to draw
  29061. * @param verticesCount defines the count of vertices to draw
  29062. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29063. */
  29064. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29065. private _drawMode;
  29066. /** @hidden */
  29067. _releaseEffect(effect: Effect): void;
  29068. /** @hidden */
  29069. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  29070. /**
  29071. * Create a new effect (used to store vertex/fragment shaders)
  29072. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  29073. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  29074. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  29075. * @param samplers defines an array of string used to represent textures
  29076. * @param defines defines the string containing the defines to use to compile the shaders
  29077. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  29078. * @param onCompiled defines a function to call when the effect creation is successful
  29079. * @param onError defines a function to call when the effect creation has failed
  29080. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  29081. * @returns the new Effect
  29082. */
  29083. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  29084. private _compileShader;
  29085. private _compileRawShader;
  29086. /**
  29087. * Directly creates a webGL program
  29088. * @param pipelineContext defines the pipeline context to attach to
  29089. * @param vertexCode defines the vertex shader code to use
  29090. * @param fragmentCode defines the fragment shader code to use
  29091. * @param context defines the webGL context to use (if not set, the current one will be used)
  29092. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29093. * @returns the new webGL program
  29094. */
  29095. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29096. /**
  29097. * Creates a webGL program
  29098. * @param pipelineContext defines the pipeline context to attach to
  29099. * @param vertexCode defines the vertex shader code to use
  29100. * @param fragmentCode defines the fragment shader code to use
  29101. * @param defines defines the string containing the defines to use to compile the shaders
  29102. * @param context defines the webGL context to use (if not set, the current one will be used)
  29103. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29104. * @returns the new webGL program
  29105. */
  29106. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29107. /**
  29108. * Creates a new pipeline context
  29109. * @returns the new pipeline
  29110. */
  29111. createPipelineContext(): WebGLPipelineContext;
  29112. private _createShaderProgram;
  29113. private _finalizePipelineContext;
  29114. /** @hidden */
  29115. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  29116. /** @hidden */
  29117. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  29118. /** @hidden */
  29119. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  29120. /**
  29121. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  29122. * @param pipelineContext defines the pipeline context to use
  29123. * @param uniformsNames defines the list of uniform names
  29124. * @returns an array of webGL uniform locations
  29125. */
  29126. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  29127. /**
  29128. * Gets the lsit of active attributes for a given webGL program
  29129. * @param pipelineContext defines the pipeline context to use
  29130. * @param attributesNames defines the list of attribute names to get
  29131. * @returns an array of indices indicating the offset of each attribute
  29132. */
  29133. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  29134. /**
  29135. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  29136. * @param effect defines the effect to activate
  29137. */
  29138. enableEffect(effect: Nullable<Effect>): void;
  29139. /**
  29140. * Set the value of an uniform to an array of int32
  29141. * @param uniform defines the webGL uniform location where to store the value
  29142. * @param array defines the array of int32 to store
  29143. */
  29144. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29145. /**
  29146. * Set the value of an uniform to an array of int32 (stored as vec2)
  29147. * @param uniform defines the webGL uniform location where to store the value
  29148. * @param array defines the array of int32 to store
  29149. */
  29150. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29151. /**
  29152. * Set the value of an uniform to an array of int32 (stored as vec3)
  29153. * @param uniform defines the webGL uniform location where to store the value
  29154. * @param array defines the array of int32 to store
  29155. */
  29156. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29157. /**
  29158. * Set the value of an uniform to an array of int32 (stored as vec4)
  29159. * @param uniform defines the webGL uniform location where to store the value
  29160. * @param array defines the array of int32 to store
  29161. */
  29162. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29163. /**
  29164. * Set the value of an uniform to an array of float32
  29165. * @param uniform defines the webGL uniform location where to store the value
  29166. * @param array defines the array of float32 to store
  29167. */
  29168. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29169. /**
  29170. * Set the value of an uniform to an array of float32 (stored as vec2)
  29171. * @param uniform defines the webGL uniform location where to store the value
  29172. * @param array defines the array of float32 to store
  29173. */
  29174. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29175. /**
  29176. * Set the value of an uniform to an array of float32 (stored as vec3)
  29177. * @param uniform defines the webGL uniform location where to store the value
  29178. * @param array defines the array of float32 to store
  29179. */
  29180. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29181. /**
  29182. * Set the value of an uniform to an array of float32 (stored as vec4)
  29183. * @param uniform defines the webGL uniform location where to store the value
  29184. * @param array defines the array of float32 to store
  29185. */
  29186. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29187. /**
  29188. * Set the value of an uniform to an array of number
  29189. * @param uniform defines the webGL uniform location where to store the value
  29190. * @param array defines the array of number to store
  29191. */
  29192. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29193. /**
  29194. * Set the value of an uniform to an array of number (stored as vec2)
  29195. * @param uniform defines the webGL uniform location where to store the value
  29196. * @param array defines the array of number to store
  29197. */
  29198. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29199. /**
  29200. * Set the value of an uniform to an array of number (stored as vec3)
  29201. * @param uniform defines the webGL uniform location where to store the value
  29202. * @param array defines the array of number to store
  29203. */
  29204. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29205. /**
  29206. * Set the value of an uniform to an array of number (stored as vec4)
  29207. * @param uniform defines the webGL uniform location where to store the value
  29208. * @param array defines the array of number to store
  29209. */
  29210. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29211. /**
  29212. * Set the value of an uniform to an array of float32 (stored as matrices)
  29213. * @param uniform defines the webGL uniform location where to store the value
  29214. * @param matrices defines the array of float32 to store
  29215. */
  29216. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  29217. /**
  29218. * Set the value of an uniform to a matrix
  29219. * @param uniform defines the webGL uniform location where to store the value
  29220. * @param matrix defines the matrix to store
  29221. */
  29222. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  29223. /**
  29224. * Set the value of an uniform to a matrix (3x3)
  29225. * @param uniform defines the webGL uniform location where to store the value
  29226. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  29227. */
  29228. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29229. /**
  29230. * Set the value of an uniform to a matrix (2x2)
  29231. * @param uniform defines the webGL uniform location where to store the value
  29232. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  29233. */
  29234. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29235. /**
  29236. * Set the value of an uniform to a number (int)
  29237. * @param uniform defines the webGL uniform location where to store the value
  29238. * @param value defines the int number to store
  29239. */
  29240. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29241. /**
  29242. * Set the value of an uniform to a number (float)
  29243. * @param uniform defines the webGL uniform location where to store the value
  29244. * @param value defines the float number to store
  29245. */
  29246. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29247. /**
  29248. * Set the value of an uniform to a vec2
  29249. * @param uniform defines the webGL uniform location where to store the value
  29250. * @param x defines the 1st component of the value
  29251. * @param y defines the 2nd component of the value
  29252. */
  29253. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  29254. /**
  29255. * Set the value of an uniform to a vec3
  29256. * @param uniform defines the webGL uniform location where to store the value
  29257. * @param x defines the 1st component of the value
  29258. * @param y defines the 2nd component of the value
  29259. * @param z defines the 3rd component of the value
  29260. */
  29261. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  29262. /**
  29263. * Set the value of an uniform to a boolean
  29264. * @param uniform defines the webGL uniform location where to store the value
  29265. * @param bool defines the boolean to store
  29266. */
  29267. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  29268. /**
  29269. * Set the value of an uniform to a vec4
  29270. * @param uniform defines the webGL uniform location where to store the value
  29271. * @param x defines the 1st component of the value
  29272. * @param y defines the 2nd component of the value
  29273. * @param z defines the 3rd component of the value
  29274. * @param w defines the 4th component of the value
  29275. */
  29276. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  29277. /**
  29278. * Set the value of an uniform to a Color3
  29279. * @param uniform defines the webGL uniform location where to store the value
  29280. * @param color3 defines the color to store
  29281. */
  29282. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  29283. /**
  29284. * Set the value of an uniform to a Color3 and an alpha value
  29285. * @param uniform defines the webGL uniform location where to store the value
  29286. * @param color3 defines the color to store
  29287. * @param alpha defines the alpha component to store
  29288. */
  29289. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  29290. /**
  29291. * Sets a Color4 on a uniform variable
  29292. * @param uniform defines the uniform location
  29293. * @param color4 defines the value to be set
  29294. */
  29295. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  29296. /**
  29297. * Set various states to the webGL context
  29298. * @param culling defines backface culling state
  29299. * @param zOffset defines the value to apply to zOffset (0 by default)
  29300. * @param force defines if states must be applied even if cache is up to date
  29301. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  29302. */
  29303. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  29304. /**
  29305. * Set the z offset to apply to current rendering
  29306. * @param value defines the offset to apply
  29307. */
  29308. setZOffset(value: number): void;
  29309. /**
  29310. * Gets the current value of the zOffset
  29311. * @returns the current zOffset state
  29312. */
  29313. getZOffset(): number;
  29314. /**
  29315. * Enable or disable depth buffering
  29316. * @param enable defines the state to set
  29317. */
  29318. setDepthBuffer(enable: boolean): void;
  29319. /**
  29320. * Gets a boolean indicating if depth writing is enabled
  29321. * @returns the current depth writing state
  29322. */
  29323. getDepthWrite(): boolean;
  29324. /**
  29325. * Enable or disable depth writing
  29326. * @param enable defines the state to set
  29327. */
  29328. setDepthWrite(enable: boolean): void;
  29329. /**
  29330. * Enable or disable color writing
  29331. * @param enable defines the state to set
  29332. */
  29333. setColorWrite(enable: boolean): void;
  29334. /**
  29335. * Gets a boolean indicating if color writing is enabled
  29336. * @returns the current color writing state
  29337. */
  29338. getColorWrite(): boolean;
  29339. /**
  29340. * Sets alpha constants used by some alpha blending modes
  29341. * @param r defines the red component
  29342. * @param g defines the green component
  29343. * @param b defines the blue component
  29344. * @param a defines the alpha component
  29345. */
  29346. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  29347. /**
  29348. * Sets the current alpha mode
  29349. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  29350. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  29351. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  29352. */
  29353. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  29354. /**
  29355. * Gets the current alpha mode
  29356. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  29357. * @returns the current alpha mode
  29358. */
  29359. getAlphaMode(): number;
  29360. /**
  29361. * Clears the list of texture accessible through engine.
  29362. * This can help preventing texture load conflict due to name collision.
  29363. */
  29364. clearInternalTexturesCache(): void;
  29365. /**
  29366. * Force the entire cache to be cleared
  29367. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  29368. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  29369. */
  29370. wipeCaches(bruteForce?: boolean): void;
  29371. /**
  29372. * Set the compressed texture format to use, based on the formats you have, and the formats
  29373. * supported by the hardware / browser.
  29374. *
  29375. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  29376. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  29377. * to API arguments needed to compressed textures. This puts the burden on the container
  29378. * generator to house the arcane code for determining these for current & future formats.
  29379. *
  29380. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  29381. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  29382. *
  29383. * Note: The result of this call is not taken into account when a texture is base64.
  29384. *
  29385. * @param formatsAvailable defines the list of those format families you have created
  29386. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  29387. *
  29388. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  29389. * @returns The extension selected.
  29390. */
  29391. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  29392. /** @hidden */
  29393. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  29394. min: number;
  29395. mag: number;
  29396. };
  29397. /** @hidden */
  29398. _createTexture(): WebGLTexture;
  29399. /**
  29400. * Usually called from Texture.ts.
  29401. * Passed information to create a WebGLTexture
  29402. * @param urlArg defines a value which contains one of the following:
  29403. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  29404. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  29405. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  29406. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  29407. * @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)
  29408. * @param scene needed for loading to the correct scene
  29409. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  29410. * @param onLoad optional callback to be called upon successful completion
  29411. * @param onError optional callback to be called upon failure
  29412. * @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
  29413. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  29414. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  29415. * @param forcedExtension defines the extension to use to pick the right loader
  29416. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  29417. * @returns a InternalTexture for assignment back into BABYLON.Texture
  29418. */
  29419. 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;
  29420. private _rescaleTexture;
  29421. private _unpackFlipYCached;
  29422. /**
  29423. * In case you are sharing the context with other applications, it might
  29424. * be interested to not cache the unpack flip y state to ensure a consistent
  29425. * value would be set.
  29426. */
  29427. enableUnpackFlipYCached: boolean;
  29428. /** @hidden */
  29429. _unpackFlipY(value: boolean): void;
  29430. /** @hidden */
  29431. _getUnpackAlignement(): number;
  29432. /**
  29433. * Creates a dynamic texture
  29434. * @param width defines the width of the texture
  29435. * @param height defines the height of the texture
  29436. * @param generateMipMaps defines if the engine should generate the mip levels
  29437. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  29438. * @returns the dynamic texture inside an InternalTexture
  29439. */
  29440. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  29441. /**
  29442. * Update the sampling mode of a given texture
  29443. * @param samplingMode defines the required sampling mode
  29444. * @param texture defines the texture to update
  29445. */
  29446. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  29447. /**
  29448. * Update the content of a dynamic texture
  29449. * @param texture defines the texture to update
  29450. * @param canvas defines the canvas containing the source
  29451. * @param invertY defines if data must be stored with Y axis inverted
  29452. * @param premulAlpha defines if alpha is stored as premultiplied
  29453. * @param format defines the format of the data
  29454. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  29455. */
  29456. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  29457. /**
  29458. * Update a video texture
  29459. * @param texture defines the texture to update
  29460. * @param video defines the video element to use
  29461. * @param invertY defines if data must be stored with Y axis inverted
  29462. */
  29463. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  29464. /**
  29465. * Updates a depth texture Comparison Mode and Function.
  29466. * If the comparison Function is equal to 0, the mode will be set to none.
  29467. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  29468. * @param texture The texture to set the comparison function for
  29469. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  29470. */
  29471. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  29472. /** @hidden */
  29473. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  29474. width: number;
  29475. height: number;
  29476. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  29477. /**
  29478. * Creates a depth stencil texture.
  29479. * This is only available in WebGL 2 or with the depth texture extension available.
  29480. * @param size The size of face edge in the texture.
  29481. * @param options The options defining the texture.
  29482. * @returns The texture
  29483. */
  29484. createDepthStencilTexture(size: number | {
  29485. width: number;
  29486. height: number;
  29487. }, options: DepthTextureCreationOptions): InternalTexture;
  29488. /**
  29489. * Creates a depth stencil texture.
  29490. * This is only available in WebGL 2 or with the depth texture extension available.
  29491. * @param size The size of face edge in the texture.
  29492. * @param options The options defining the texture.
  29493. * @returns The texture
  29494. */
  29495. private _createDepthStencilTexture;
  29496. /**
  29497. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  29498. * @param renderTarget The render target to set the frame buffer for
  29499. */
  29500. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  29501. /**
  29502. * Creates a new render target texture
  29503. * @param size defines the size of the texture
  29504. * @param options defines the options used to create the texture
  29505. * @returns a new render target texture stored in an InternalTexture
  29506. */
  29507. createRenderTargetTexture(size: number | {
  29508. width: number;
  29509. height: number;
  29510. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  29511. /** @hidden */
  29512. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  29513. /**
  29514. * Updates the sample count of a render target texture
  29515. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  29516. * @param texture defines the texture to update
  29517. * @param samples defines the sample count to set
  29518. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  29519. */
  29520. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  29521. /** @hidden */
  29522. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29523. /** @hidden */
  29524. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29525. /** @hidden */
  29526. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29527. /** @hidden */
  29528. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  29529. /**
  29530. * @hidden
  29531. */
  29532. _setCubeMapTextureParams(loadMipmap: boolean): void;
  29533. private _prepareWebGLTextureContinuation;
  29534. private _prepareWebGLTexture;
  29535. /** @hidden */
  29536. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  29537. /** @hidden */
  29538. _releaseFramebufferObjects(texture: InternalTexture): void;
  29539. /** @hidden */
  29540. _releaseTexture(texture: InternalTexture): void;
  29541. private setProgram;
  29542. private _boundUniforms;
  29543. /**
  29544. * Binds an effect to the webGL context
  29545. * @param effect defines the effect to bind
  29546. */
  29547. bindSamplers(effect: Effect): void;
  29548. private _activateCurrentTexture;
  29549. /** @hidden */
  29550. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  29551. /** @hidden */
  29552. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  29553. /**
  29554. * Sets a texture to the webGL context from a postprocess
  29555. * @param channel defines the channel to use
  29556. * @param postProcess defines the source postprocess
  29557. */
  29558. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  29559. /**
  29560. * Binds the output of the passed in post process to the texture channel specified
  29561. * @param channel The channel the texture should be bound to
  29562. * @param postProcess The post process which's output should be bound
  29563. */
  29564. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  29565. /**
  29566. * Unbind all textures from the webGL context
  29567. */
  29568. unbindAllTextures(): void;
  29569. /**
  29570. * Sets a texture to the according uniform.
  29571. * @param channel The texture channel
  29572. * @param uniform The uniform to set
  29573. * @param texture The texture to apply
  29574. */
  29575. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  29576. /**
  29577. * Sets a depth stencil texture from a render target to the according uniform.
  29578. * @param channel The texture channel
  29579. * @param uniform The uniform to set
  29580. * @param texture The render target texture containing the depth stencil texture to apply
  29581. */
  29582. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  29583. private _bindSamplerUniformToChannel;
  29584. private _getTextureWrapMode;
  29585. private _setTexture;
  29586. /**
  29587. * Sets an array of texture to the webGL context
  29588. * @param channel defines the channel where the texture array must be set
  29589. * @param uniform defines the associated uniform location
  29590. * @param textures defines the array of textures to bind
  29591. */
  29592. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  29593. /** @hidden */
  29594. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  29595. private _setTextureParameterFloat;
  29596. private _setTextureParameterInteger;
  29597. /**
  29598. * Reads pixels from the current frame buffer. Please note that this function can be slow
  29599. * @param x defines the x coordinate of the rectangle where pixels must be read
  29600. * @param y defines the y coordinate of the rectangle where pixels must be read
  29601. * @param width defines the width of the rectangle where pixels must be read
  29602. * @param height defines the height of the rectangle where pixels must be read
  29603. * @returns a Uint8Array containing RGBA colors
  29604. */
  29605. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  29606. /**
  29607. * Add an externaly attached data from its key.
  29608. * This method call will fail and return false, if such key already exists.
  29609. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  29610. * @param key the unique key that identifies the data
  29611. * @param data the data object to associate to the key for this Engine instance
  29612. * @return true if no such key were already present and the data was added successfully, false otherwise
  29613. */
  29614. addExternalData<T>(key: string, data: T): boolean;
  29615. /**
  29616. * Get an externaly attached data from its key
  29617. * @param key the unique key that identifies the data
  29618. * @return the associated data, if present (can be null), or undefined if not present
  29619. */
  29620. getExternalData<T>(key: string): T;
  29621. /**
  29622. * Get an externaly attached data from its key, create it using a factory if it's not already present
  29623. * @param key the unique key that identifies the data
  29624. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  29625. * @return the associated data, can be null if the factory returned null.
  29626. */
  29627. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  29628. /**
  29629. * Remove an externaly attached data from the Engine instance
  29630. * @param key the unique key that identifies the data
  29631. * @return true if the data was successfully removed, false if it doesn't exist
  29632. */
  29633. removeExternalData(key: string): boolean;
  29634. /**
  29635. * Unbind all vertex attributes from the webGL context
  29636. */
  29637. unbindAllAttributes(): void;
  29638. /**
  29639. * 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
  29640. */
  29641. releaseEffects(): void;
  29642. /**
  29643. * Dispose and release all associated resources
  29644. */
  29645. dispose(): void;
  29646. /**
  29647. * Display the loading screen
  29648. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29649. */
  29650. displayLoadingUI(): void;
  29651. /**
  29652. * Hide the loading screen
  29653. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29654. */
  29655. hideLoadingUI(): void;
  29656. /**
  29657. * Gets the current loading screen object
  29658. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29659. */
  29660. /**
  29661. * Sets the current loading screen object
  29662. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29663. */
  29664. loadingScreen: ILoadingScreen;
  29665. /**
  29666. * Sets the current loading screen text
  29667. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29668. */
  29669. loadingUIText: string;
  29670. /**
  29671. * Sets the current loading screen background color
  29672. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29673. */
  29674. loadingUIBackgroundColor: string;
  29675. /**
  29676. * Attach a new callback raised when context lost event is fired
  29677. * @param callback defines the callback to call
  29678. */
  29679. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29680. /**
  29681. * Attach a new callback raised when context restored event is fired
  29682. * @param callback defines the callback to call
  29683. */
  29684. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29685. /**
  29686. * Gets the source code of the vertex shader associated with a specific webGL program
  29687. * @param program defines the program to use
  29688. * @returns a string containing the source code of the vertex shader associated with the program
  29689. */
  29690. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  29691. /**
  29692. * Gets the source code of the fragment shader associated with a specific webGL program
  29693. * @param program defines the program to use
  29694. * @returns a string containing the source code of the fragment shader associated with the program
  29695. */
  29696. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  29697. /**
  29698. * Get the current error code of the webGL context
  29699. * @returns the error code
  29700. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  29701. */
  29702. getError(): number;
  29703. /**
  29704. * Gets the current framerate
  29705. * @returns a number representing the framerate
  29706. */
  29707. getFps(): number;
  29708. /**
  29709. * Gets the time spent between current and previous frame
  29710. * @returns a number representing the delta time in ms
  29711. */
  29712. getDeltaTime(): number;
  29713. private _measureFps;
  29714. /** @hidden */
  29715. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  29716. private _canRenderToFloatFramebuffer;
  29717. private _canRenderToHalfFloatFramebuffer;
  29718. private _canRenderToFramebuffer;
  29719. /** @hidden */
  29720. _getWebGLTextureType(type: number): number;
  29721. /** @hidden */
  29722. _getInternalFormat(format: number): number;
  29723. /** @hidden */
  29724. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  29725. /** @hidden */
  29726. _getRGBAMultiSampleBufferFormat(type: number): number;
  29727. /** @hidden */
  29728. _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;
  29729. /** @hidden */
  29730. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  29731. /**
  29732. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  29733. * @returns true if the engine can be created
  29734. * @ignorenaming
  29735. */
  29736. static isSupported(): boolean;
  29737. }
  29738. }
  29739. declare module "babylonjs/Materials/effect" {
  29740. import { Observable } from "babylonjs/Misc/observable";
  29741. import { Nullable } from "babylonjs/types";
  29742. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  29743. import { IDisposable } from "babylonjs/scene";
  29744. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  29745. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  29746. import { Engine } from "babylonjs/Engines/engine";
  29747. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29748. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29749. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29750. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29751. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29752. /**
  29753. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  29754. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  29755. */
  29756. export class EffectFallbacks {
  29757. private _defines;
  29758. private _currentRank;
  29759. private _maxRank;
  29760. private _mesh;
  29761. /**
  29762. * Removes the fallback from the bound mesh.
  29763. */
  29764. unBindMesh(): void;
  29765. /**
  29766. * Adds a fallback on the specified property.
  29767. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29768. * @param define The name of the define in the shader
  29769. */
  29770. addFallback(rank: number, define: string): void;
  29771. /**
  29772. * Sets the mesh to use CPU skinning when needing to fallback.
  29773. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29774. * @param mesh The mesh to use the fallbacks.
  29775. */
  29776. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  29777. /**
  29778. * Checks to see if more fallbacks are still availible.
  29779. */
  29780. readonly isMoreFallbacks: boolean;
  29781. /**
  29782. * Removes the defines that shoould be removed when falling back.
  29783. * @param currentDefines defines the current define statements for the shader.
  29784. * @param effect defines the current effect we try to compile
  29785. * @returns The resulting defines with defines of the current rank removed.
  29786. */
  29787. reduce(currentDefines: string, effect: Effect): string;
  29788. }
  29789. /**
  29790. * Options to be used when creating an effect.
  29791. */
  29792. export class EffectCreationOptions {
  29793. /**
  29794. * Atrributes that will be used in the shader.
  29795. */
  29796. attributes: string[];
  29797. /**
  29798. * Uniform varible names that will be set in the shader.
  29799. */
  29800. uniformsNames: string[];
  29801. /**
  29802. * Uniform buffer varible names that will be set in the shader.
  29803. */
  29804. uniformBuffersNames: string[];
  29805. /**
  29806. * Sampler texture variable names that will be set in the shader.
  29807. */
  29808. samplers: string[];
  29809. /**
  29810. * Define statements that will be set in the shader.
  29811. */
  29812. defines: any;
  29813. /**
  29814. * Possible fallbacks for this effect to improve performance when needed.
  29815. */
  29816. fallbacks: Nullable<EffectFallbacks>;
  29817. /**
  29818. * Callback that will be called when the shader is compiled.
  29819. */
  29820. onCompiled: Nullable<(effect: Effect) => void>;
  29821. /**
  29822. * Callback that will be called if an error occurs during shader compilation.
  29823. */
  29824. onError: Nullable<(effect: Effect, errors: string) => void>;
  29825. /**
  29826. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29827. */
  29828. indexParameters: any;
  29829. /**
  29830. * Max number of lights that can be used in the shader.
  29831. */
  29832. maxSimultaneousLights: number;
  29833. /**
  29834. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29835. */
  29836. transformFeedbackVaryings: Nullable<string[]>;
  29837. }
  29838. /**
  29839. * Effect containing vertex and fragment shader that can be executed on an object.
  29840. */
  29841. export class Effect implements IDisposable {
  29842. /**
  29843. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29844. */
  29845. static ShadersRepository: string;
  29846. /**
  29847. * Name of the effect.
  29848. */
  29849. name: any;
  29850. /**
  29851. * String container all the define statements that should be set on the shader.
  29852. */
  29853. defines: string;
  29854. /**
  29855. * Callback that will be called when the shader is compiled.
  29856. */
  29857. onCompiled: Nullable<(effect: Effect) => void>;
  29858. /**
  29859. * Callback that will be called if an error occurs during shader compilation.
  29860. */
  29861. onError: Nullable<(effect: Effect, errors: string) => void>;
  29862. /**
  29863. * Callback that will be called when effect is bound.
  29864. */
  29865. onBind: Nullable<(effect: Effect) => void>;
  29866. /**
  29867. * Unique ID of the effect.
  29868. */
  29869. uniqueId: number;
  29870. /**
  29871. * Observable that will be called when the shader is compiled.
  29872. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29873. */
  29874. onCompileObservable: Observable<Effect>;
  29875. /**
  29876. * Observable that will be called if an error occurs during shader compilation.
  29877. */
  29878. onErrorObservable: Observable<Effect>;
  29879. /** @hidden */
  29880. _onBindObservable: Nullable<Observable<Effect>>;
  29881. /**
  29882. * Observable that will be called when effect is bound.
  29883. */
  29884. readonly onBindObservable: Observable<Effect>;
  29885. /** @hidden */
  29886. _bonesComputationForcedToCPU: boolean;
  29887. private static _uniqueIdSeed;
  29888. private _engine;
  29889. private _uniformBuffersNames;
  29890. private _uniformsNames;
  29891. private _samplerList;
  29892. private _samplers;
  29893. private _isReady;
  29894. private _compilationError;
  29895. private _attributesNames;
  29896. private _attributes;
  29897. private _uniforms;
  29898. /**
  29899. * Key for the effect.
  29900. * @hidden
  29901. */
  29902. _key: string;
  29903. private _indexParameters;
  29904. private _fallbacks;
  29905. private _vertexSourceCode;
  29906. private _fragmentSourceCode;
  29907. private _vertexSourceCodeOverride;
  29908. private _fragmentSourceCodeOverride;
  29909. private _transformFeedbackVaryings;
  29910. /**
  29911. * Compiled shader to webGL program.
  29912. * @hidden
  29913. */
  29914. _pipelineContext: Nullable<IPipelineContext>;
  29915. private _valueCache;
  29916. private static _baseCache;
  29917. /**
  29918. * Instantiates an effect.
  29919. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29920. * @param baseName Name of the effect.
  29921. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29922. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29923. * @param samplers List of sampler variables that will be passed to the shader.
  29924. * @param engine Engine to be used to render the effect
  29925. * @param defines Define statements to be added to the shader.
  29926. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29927. * @param onCompiled Callback that will be called when the shader is compiled.
  29928. * @param onError Callback that will be called if an error occurs during shader compilation.
  29929. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29930. */
  29931. 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);
  29932. /**
  29933. * Unique key for this effect
  29934. */
  29935. readonly key: string;
  29936. /**
  29937. * If the effect has been compiled and prepared.
  29938. * @returns if the effect is compiled and prepared.
  29939. */
  29940. isReady(): boolean;
  29941. /**
  29942. * The engine the effect was initialized with.
  29943. * @returns the engine.
  29944. */
  29945. getEngine(): Engine;
  29946. /**
  29947. * The pipeline context for this effect
  29948. * @returns the associated pipeline context
  29949. */
  29950. getPipelineContext(): Nullable<IPipelineContext>;
  29951. /**
  29952. * The set of names of attribute variables for the shader.
  29953. * @returns An array of attribute names.
  29954. */
  29955. getAttributesNames(): string[];
  29956. /**
  29957. * Returns the attribute at the given index.
  29958. * @param index The index of the attribute.
  29959. * @returns The location of the attribute.
  29960. */
  29961. getAttributeLocation(index: number): number;
  29962. /**
  29963. * Returns the attribute based on the name of the variable.
  29964. * @param name of the attribute to look up.
  29965. * @returns the attribute location.
  29966. */
  29967. getAttributeLocationByName(name: string): number;
  29968. /**
  29969. * The number of attributes.
  29970. * @returns the numnber of attributes.
  29971. */
  29972. getAttributesCount(): number;
  29973. /**
  29974. * Gets the index of a uniform variable.
  29975. * @param uniformName of the uniform to look up.
  29976. * @returns the index.
  29977. */
  29978. getUniformIndex(uniformName: string): number;
  29979. /**
  29980. * Returns the attribute based on the name of the variable.
  29981. * @param uniformName of the uniform to look up.
  29982. * @returns the location of the uniform.
  29983. */
  29984. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29985. /**
  29986. * Returns an array of sampler variable names
  29987. * @returns The array of sampler variable neames.
  29988. */
  29989. getSamplers(): string[];
  29990. /**
  29991. * The error from the last compilation.
  29992. * @returns the error string.
  29993. */
  29994. getCompilationError(): string;
  29995. /**
  29996. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29997. * @param func The callback to be used.
  29998. */
  29999. executeWhenCompiled(func: (effect: Effect) => void): void;
  30000. private _checkIsReady;
  30001. /** @hidden */
  30002. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  30003. /** @hidden */
  30004. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  30005. /** @hidden */
  30006. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  30007. private _processShaderConversion;
  30008. private _processIncludes;
  30009. private _processPrecision;
  30010. /**
  30011. * Recompiles the webGL program
  30012. * @param vertexSourceCode The source code for the vertex shader.
  30013. * @param fragmentSourceCode The source code for the fragment shader.
  30014. * @param onCompiled Callback called when completed.
  30015. * @param onError Callback called on error.
  30016. * @hidden
  30017. */
  30018. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  30019. /**
  30020. * Prepares the effect
  30021. * @hidden
  30022. */
  30023. _prepareEffect(): void;
  30024. /**
  30025. * Checks if the effect is supported. (Must be called after compilation)
  30026. */
  30027. readonly isSupported: boolean;
  30028. /**
  30029. * Binds a texture to the engine to be used as output of the shader.
  30030. * @param channel Name of the output variable.
  30031. * @param texture Texture to bind.
  30032. * @hidden
  30033. */
  30034. _bindTexture(channel: string, texture: InternalTexture): void;
  30035. /**
  30036. * Sets a texture on the engine to be used in the shader.
  30037. * @param channel Name of the sampler variable.
  30038. * @param texture Texture to set.
  30039. */
  30040. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  30041. /**
  30042. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  30043. * @param channel Name of the sampler variable.
  30044. * @param texture Texture to set.
  30045. */
  30046. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  30047. /**
  30048. * Sets an array of textures on the engine to be used in the shader.
  30049. * @param channel Name of the variable.
  30050. * @param textures Textures to set.
  30051. */
  30052. setTextureArray(channel: string, textures: BaseTexture[]): void;
  30053. /**
  30054. * 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)
  30055. * @param channel Name of the sampler variable.
  30056. * @param postProcess Post process to get the input texture from.
  30057. */
  30058. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  30059. /**
  30060. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  30061. * 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)
  30062. * @param channel Name of the sampler variable.
  30063. * @param postProcess Post process to get the output texture from.
  30064. */
  30065. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  30066. /** @hidden */
  30067. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  30068. /** @hidden */
  30069. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  30070. /** @hidden */
  30071. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  30072. /** @hidden */
  30073. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  30074. /**
  30075. * Binds a buffer to a uniform.
  30076. * @param buffer Buffer to bind.
  30077. * @param name Name of the uniform variable to bind to.
  30078. */
  30079. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  30080. /**
  30081. * Binds block to a uniform.
  30082. * @param blockName Name of the block to bind.
  30083. * @param index Index to bind.
  30084. */
  30085. bindUniformBlock(blockName: string, index: number): void;
  30086. /**
  30087. * Sets an interger value on a uniform variable.
  30088. * @param uniformName Name of the variable.
  30089. * @param value Value to be set.
  30090. * @returns this effect.
  30091. */
  30092. setInt(uniformName: string, value: number): Effect;
  30093. /**
  30094. * Sets an int array on a uniform variable.
  30095. * @param uniformName Name of the variable.
  30096. * @param array array to be set.
  30097. * @returns this effect.
  30098. */
  30099. setIntArray(uniformName: string, array: Int32Array): Effect;
  30100. /**
  30101. * 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)
  30102. * @param uniformName Name of the variable.
  30103. * @param array array to be set.
  30104. * @returns this effect.
  30105. */
  30106. setIntArray2(uniformName: string, array: Int32Array): Effect;
  30107. /**
  30108. * 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)
  30109. * @param uniformName Name of the variable.
  30110. * @param array array to be set.
  30111. * @returns this effect.
  30112. */
  30113. setIntArray3(uniformName: string, array: Int32Array): Effect;
  30114. /**
  30115. * 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)
  30116. * @param uniformName Name of the variable.
  30117. * @param array array to be set.
  30118. * @returns this effect.
  30119. */
  30120. setIntArray4(uniformName: string, array: Int32Array): Effect;
  30121. /**
  30122. * Sets an float array on a uniform variable.
  30123. * @param uniformName Name of the variable.
  30124. * @param array array to be set.
  30125. * @returns this effect.
  30126. */
  30127. setFloatArray(uniformName: string, array: Float32Array): Effect;
  30128. /**
  30129. * 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)
  30130. * @param uniformName Name of the variable.
  30131. * @param array array to be set.
  30132. * @returns this effect.
  30133. */
  30134. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  30135. /**
  30136. * 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)
  30137. * @param uniformName Name of the variable.
  30138. * @param array array to be set.
  30139. * @returns this effect.
  30140. */
  30141. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  30142. /**
  30143. * 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)
  30144. * @param uniformName Name of the variable.
  30145. * @param array array to be set.
  30146. * @returns this effect.
  30147. */
  30148. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  30149. /**
  30150. * Sets an array on a uniform variable.
  30151. * @param uniformName Name of the variable.
  30152. * @param array array to be set.
  30153. * @returns this effect.
  30154. */
  30155. setArray(uniformName: string, array: number[]): Effect;
  30156. /**
  30157. * 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)
  30158. * @param uniformName Name of the variable.
  30159. * @param array array to be set.
  30160. * @returns this effect.
  30161. */
  30162. setArray2(uniformName: string, array: number[]): Effect;
  30163. /**
  30164. * 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)
  30165. * @param uniformName Name of the variable.
  30166. * @param array array to be set.
  30167. * @returns this effect.
  30168. */
  30169. setArray3(uniformName: string, array: number[]): Effect;
  30170. /**
  30171. * 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)
  30172. * @param uniformName Name of the variable.
  30173. * @param array array to be set.
  30174. * @returns this effect.
  30175. */
  30176. setArray4(uniformName: string, array: number[]): Effect;
  30177. /**
  30178. * Sets matrices on a uniform variable.
  30179. * @param uniformName Name of the variable.
  30180. * @param matrices matrices to be set.
  30181. * @returns this effect.
  30182. */
  30183. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  30184. /**
  30185. * Sets matrix on a uniform variable.
  30186. * @param uniformName Name of the variable.
  30187. * @param matrix matrix to be set.
  30188. * @returns this effect.
  30189. */
  30190. setMatrix(uniformName: string, matrix: Matrix): Effect;
  30191. /**
  30192. * 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)
  30193. * @param uniformName Name of the variable.
  30194. * @param matrix matrix to be set.
  30195. * @returns this effect.
  30196. */
  30197. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  30198. /**
  30199. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  30200. * @param uniformName Name of the variable.
  30201. * @param matrix matrix to be set.
  30202. * @returns this effect.
  30203. */
  30204. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  30205. /**
  30206. * Sets a float on a uniform variable.
  30207. * @param uniformName Name of the variable.
  30208. * @param value value to be set.
  30209. * @returns this effect.
  30210. */
  30211. setFloat(uniformName: string, value: number): Effect;
  30212. /**
  30213. * Sets a boolean on a uniform variable.
  30214. * @param uniformName Name of the variable.
  30215. * @param bool value to be set.
  30216. * @returns this effect.
  30217. */
  30218. setBool(uniformName: string, bool: boolean): Effect;
  30219. /**
  30220. * Sets a Vector2 on a uniform variable.
  30221. * @param uniformName Name of the variable.
  30222. * @param vector2 vector2 to be set.
  30223. * @returns this effect.
  30224. */
  30225. setVector2(uniformName: string, vector2: Vector2): Effect;
  30226. /**
  30227. * Sets a float2 on a uniform variable.
  30228. * @param uniformName Name of the variable.
  30229. * @param x First float in float2.
  30230. * @param y Second float in float2.
  30231. * @returns this effect.
  30232. */
  30233. setFloat2(uniformName: string, x: number, y: number): Effect;
  30234. /**
  30235. * Sets a Vector3 on a uniform variable.
  30236. * @param uniformName Name of the variable.
  30237. * @param vector3 Value to be set.
  30238. * @returns this effect.
  30239. */
  30240. setVector3(uniformName: string, vector3: Vector3): Effect;
  30241. /**
  30242. * Sets a float3 on a uniform variable.
  30243. * @param uniformName Name of the variable.
  30244. * @param x First float in float3.
  30245. * @param y Second float in float3.
  30246. * @param z Third float in float3.
  30247. * @returns this effect.
  30248. */
  30249. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  30250. /**
  30251. * Sets a Vector4 on a uniform variable.
  30252. * @param uniformName Name of the variable.
  30253. * @param vector4 Value to be set.
  30254. * @returns this effect.
  30255. */
  30256. setVector4(uniformName: string, vector4: Vector4): Effect;
  30257. /**
  30258. * Sets a float4 on a uniform variable.
  30259. * @param uniformName Name of the variable.
  30260. * @param x First float in float4.
  30261. * @param y Second float in float4.
  30262. * @param z Third float in float4.
  30263. * @param w Fourth float in float4.
  30264. * @returns this effect.
  30265. */
  30266. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  30267. /**
  30268. * Sets a Color3 on a uniform variable.
  30269. * @param uniformName Name of the variable.
  30270. * @param color3 Value to be set.
  30271. * @returns this effect.
  30272. */
  30273. setColor3(uniformName: string, color3: Color3): Effect;
  30274. /**
  30275. * Sets a Color4 on a uniform variable.
  30276. * @param uniformName Name of the variable.
  30277. * @param color3 Value to be set.
  30278. * @param alpha Alpha value to be set.
  30279. * @returns this effect.
  30280. */
  30281. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  30282. /**
  30283. * Sets a Color4 on a uniform variable
  30284. * @param uniformName defines the name of the variable
  30285. * @param color4 defines the value to be set
  30286. * @returns this effect.
  30287. */
  30288. setDirectColor4(uniformName: string, color4: Color4): Effect;
  30289. /** Release all associated resources */
  30290. dispose(): void;
  30291. /**
  30292. * This function will add a new shader to the shader store
  30293. * @param name the name of the shader
  30294. * @param pixelShader optional pixel shader content
  30295. * @param vertexShader optional vertex shader content
  30296. */
  30297. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  30298. /**
  30299. * Store of each shader (The can be looked up using effect.key)
  30300. */
  30301. static ShadersStore: {
  30302. [key: string]: string;
  30303. };
  30304. /**
  30305. * Store of each included file for a shader (The can be looked up using effect.key)
  30306. */
  30307. static IncludesShadersStore: {
  30308. [key: string]: string;
  30309. };
  30310. /**
  30311. * Resets the cache of effects.
  30312. */
  30313. static ResetCache(): void;
  30314. }
  30315. }
  30316. declare module "babylonjs/Materials/colorCurves" {
  30317. import { Effect } from "babylonjs/Materials/effect";
  30318. /**
  30319. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30320. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30321. * 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;
  30322. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30323. */
  30324. export class ColorCurves {
  30325. private _dirty;
  30326. private _tempColor;
  30327. private _globalCurve;
  30328. private _highlightsCurve;
  30329. private _midtonesCurve;
  30330. private _shadowsCurve;
  30331. private _positiveCurve;
  30332. private _negativeCurve;
  30333. private _globalHue;
  30334. private _globalDensity;
  30335. private _globalSaturation;
  30336. private _globalExposure;
  30337. /**
  30338. * Gets the global Hue value.
  30339. * 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).
  30340. */
  30341. /**
  30342. * Sets the global Hue value.
  30343. * 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).
  30344. */
  30345. globalHue: number;
  30346. /**
  30347. * Gets the global Density value.
  30348. * 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.
  30349. * Values less than zero provide a filter of opposite hue.
  30350. */
  30351. /**
  30352. * Sets the global Density value.
  30353. * 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.
  30354. * Values less than zero provide a filter of opposite hue.
  30355. */
  30356. globalDensity: number;
  30357. /**
  30358. * Gets the global Saturation value.
  30359. * 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.
  30360. */
  30361. /**
  30362. * Sets the global Saturation value.
  30363. * 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.
  30364. */
  30365. globalSaturation: number;
  30366. /**
  30367. * Gets the global Exposure value.
  30368. * 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.
  30369. */
  30370. /**
  30371. * Sets the global Exposure value.
  30372. * 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.
  30373. */
  30374. globalExposure: number;
  30375. private _highlightsHue;
  30376. private _highlightsDensity;
  30377. private _highlightsSaturation;
  30378. private _highlightsExposure;
  30379. /**
  30380. * Gets the highlights Hue value.
  30381. * 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).
  30382. */
  30383. /**
  30384. * Sets the highlights Hue value.
  30385. * 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).
  30386. */
  30387. highlightsHue: number;
  30388. /**
  30389. * Gets the highlights Density value.
  30390. * 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.
  30391. * Values less than zero provide a filter of opposite hue.
  30392. */
  30393. /**
  30394. * Sets the highlights Density value.
  30395. * 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.
  30396. * Values less than zero provide a filter of opposite hue.
  30397. */
  30398. highlightsDensity: number;
  30399. /**
  30400. * Gets the highlights Saturation value.
  30401. * 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.
  30402. */
  30403. /**
  30404. * Sets the highlights Saturation value.
  30405. * 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.
  30406. */
  30407. highlightsSaturation: number;
  30408. /**
  30409. * Gets the highlights Exposure value.
  30410. * 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.
  30411. */
  30412. /**
  30413. * Sets the highlights Exposure value.
  30414. * 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.
  30415. */
  30416. highlightsExposure: number;
  30417. private _midtonesHue;
  30418. private _midtonesDensity;
  30419. private _midtonesSaturation;
  30420. private _midtonesExposure;
  30421. /**
  30422. * Gets the midtones Hue value.
  30423. * 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).
  30424. */
  30425. /**
  30426. * Sets the midtones Hue value.
  30427. * 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).
  30428. */
  30429. midtonesHue: number;
  30430. /**
  30431. * Gets the midtones Density value.
  30432. * 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.
  30433. * Values less than zero provide a filter of opposite hue.
  30434. */
  30435. /**
  30436. * Sets the midtones Density value.
  30437. * 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.
  30438. * Values less than zero provide a filter of opposite hue.
  30439. */
  30440. midtonesDensity: number;
  30441. /**
  30442. * Gets the midtones Saturation value.
  30443. * 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.
  30444. */
  30445. /**
  30446. * Sets the midtones Saturation value.
  30447. * 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.
  30448. */
  30449. midtonesSaturation: number;
  30450. /**
  30451. * Gets the midtones Exposure value.
  30452. * 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.
  30453. */
  30454. /**
  30455. * Sets the midtones Exposure value.
  30456. * 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.
  30457. */
  30458. midtonesExposure: number;
  30459. private _shadowsHue;
  30460. private _shadowsDensity;
  30461. private _shadowsSaturation;
  30462. private _shadowsExposure;
  30463. /**
  30464. * Gets the shadows Hue value.
  30465. * 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).
  30466. */
  30467. /**
  30468. * Sets the shadows Hue value.
  30469. * 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).
  30470. */
  30471. shadowsHue: number;
  30472. /**
  30473. * Gets the shadows Density value.
  30474. * 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.
  30475. * Values less than zero provide a filter of opposite hue.
  30476. */
  30477. /**
  30478. * Sets the shadows Density value.
  30479. * 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.
  30480. * Values less than zero provide a filter of opposite hue.
  30481. */
  30482. shadowsDensity: number;
  30483. /**
  30484. * Gets the shadows Saturation value.
  30485. * 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.
  30486. */
  30487. /**
  30488. * Sets the shadows Saturation value.
  30489. * 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.
  30490. */
  30491. shadowsSaturation: number;
  30492. /**
  30493. * Gets the shadows Exposure value.
  30494. * 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.
  30495. */
  30496. /**
  30497. * Sets the shadows Exposure value.
  30498. * 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.
  30499. */
  30500. shadowsExposure: number;
  30501. /**
  30502. * Returns the class name
  30503. * @returns The class name
  30504. */
  30505. getClassName(): string;
  30506. /**
  30507. * Binds the color curves to the shader.
  30508. * @param colorCurves The color curve to bind
  30509. * @param effect The effect to bind to
  30510. * @param positiveUniform The positive uniform shader parameter
  30511. * @param neutralUniform The neutral uniform shader parameter
  30512. * @param negativeUniform The negative uniform shader parameter
  30513. */
  30514. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  30515. /**
  30516. * Prepare the list of uniforms associated with the ColorCurves effects.
  30517. * @param uniformsList The list of uniforms used in the effect
  30518. */
  30519. static PrepareUniforms(uniformsList: string[]): void;
  30520. /**
  30521. * Returns color grading data based on a hue, density, saturation and exposure value.
  30522. * @param filterHue The hue of the color filter.
  30523. * @param filterDensity The density of the color filter.
  30524. * @param saturation The saturation.
  30525. * @param exposure The exposure.
  30526. * @param result The result data container.
  30527. */
  30528. private getColorGradingDataToRef;
  30529. /**
  30530. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  30531. * @param value The input slider value in range [-100,100].
  30532. * @returns Adjusted value.
  30533. */
  30534. private static applyColorGradingSliderNonlinear;
  30535. /**
  30536. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  30537. * @param hue The hue (H) input.
  30538. * @param saturation The saturation (S) input.
  30539. * @param brightness The brightness (B) input.
  30540. * @result An RGBA color represented as Vector4.
  30541. */
  30542. private static fromHSBToRef;
  30543. /**
  30544. * Returns a value clamped between min and max
  30545. * @param value The value to clamp
  30546. * @param min The minimum of value
  30547. * @param max The maximum of value
  30548. * @returns The clamped value.
  30549. */
  30550. private static clamp;
  30551. /**
  30552. * Clones the current color curve instance.
  30553. * @return The cloned curves
  30554. */
  30555. clone(): ColorCurves;
  30556. /**
  30557. * Serializes the current color curve instance to a json representation.
  30558. * @return a JSON representation
  30559. */
  30560. serialize(): any;
  30561. /**
  30562. * Parses the color curve from a json representation.
  30563. * @param source the JSON source to parse
  30564. * @return The parsed curves
  30565. */
  30566. static Parse(source: any): ColorCurves;
  30567. }
  30568. }
  30569. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  30570. import { Observable } from "babylonjs/Misc/observable";
  30571. import { Nullable } from "babylonjs/types";
  30572. import { Color4 } from "babylonjs/Maths/math";
  30573. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  30574. import { Effect } from "babylonjs/Materials/effect";
  30575. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30576. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  30577. /**
  30578. * Interface to follow in your material defines to integrate easily the
  30579. * Image proccessing functions.
  30580. * @hidden
  30581. */
  30582. export interface IImageProcessingConfigurationDefines {
  30583. IMAGEPROCESSING: boolean;
  30584. VIGNETTE: boolean;
  30585. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30586. VIGNETTEBLENDMODEOPAQUE: boolean;
  30587. TONEMAPPING: boolean;
  30588. TONEMAPPING_ACES: boolean;
  30589. CONTRAST: boolean;
  30590. EXPOSURE: boolean;
  30591. COLORCURVES: boolean;
  30592. COLORGRADING: boolean;
  30593. COLORGRADING3D: boolean;
  30594. SAMPLER3DGREENDEPTH: boolean;
  30595. SAMPLER3DBGRMAP: boolean;
  30596. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30597. }
  30598. /**
  30599. * @hidden
  30600. */
  30601. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  30602. IMAGEPROCESSING: boolean;
  30603. VIGNETTE: boolean;
  30604. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30605. VIGNETTEBLENDMODEOPAQUE: boolean;
  30606. TONEMAPPING: boolean;
  30607. TONEMAPPING_ACES: boolean;
  30608. CONTRAST: boolean;
  30609. COLORCURVES: boolean;
  30610. COLORGRADING: boolean;
  30611. COLORGRADING3D: boolean;
  30612. SAMPLER3DGREENDEPTH: boolean;
  30613. SAMPLER3DBGRMAP: boolean;
  30614. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30615. EXPOSURE: boolean;
  30616. constructor();
  30617. }
  30618. /**
  30619. * This groups together the common properties used for image processing either in direct forward pass
  30620. * or through post processing effect depending on the use of the image processing pipeline in your scene
  30621. * or not.
  30622. */
  30623. export class ImageProcessingConfiguration {
  30624. /**
  30625. * Default tone mapping applied in BabylonJS.
  30626. */
  30627. static readonly TONEMAPPING_STANDARD: number;
  30628. /**
  30629. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  30630. * to other engines rendering to increase portability.
  30631. */
  30632. static readonly TONEMAPPING_ACES: number;
  30633. /**
  30634. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  30635. */
  30636. colorCurves: Nullable<ColorCurves>;
  30637. private _colorCurvesEnabled;
  30638. /**
  30639. * Gets wether the color curves effect is enabled.
  30640. */
  30641. /**
  30642. * Sets wether the color curves effect is enabled.
  30643. */
  30644. colorCurvesEnabled: boolean;
  30645. private _colorGradingTexture;
  30646. /**
  30647. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  30648. */
  30649. /**
  30650. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  30651. */
  30652. colorGradingTexture: Nullable<BaseTexture>;
  30653. private _colorGradingEnabled;
  30654. /**
  30655. * Gets wether the color grading effect is enabled.
  30656. */
  30657. /**
  30658. * Sets wether the color grading effect is enabled.
  30659. */
  30660. colorGradingEnabled: boolean;
  30661. private _colorGradingWithGreenDepth;
  30662. /**
  30663. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  30664. */
  30665. /**
  30666. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  30667. */
  30668. colorGradingWithGreenDepth: boolean;
  30669. private _colorGradingBGR;
  30670. /**
  30671. * Gets wether the color grading texture contains BGR values.
  30672. */
  30673. /**
  30674. * Sets wether the color grading texture contains BGR values.
  30675. */
  30676. colorGradingBGR: boolean;
  30677. /** @hidden */
  30678. _exposure: number;
  30679. /**
  30680. * Gets the Exposure used in the effect.
  30681. */
  30682. /**
  30683. * Sets the Exposure used in the effect.
  30684. */
  30685. exposure: number;
  30686. private _toneMappingEnabled;
  30687. /**
  30688. * Gets wether the tone mapping effect is enabled.
  30689. */
  30690. /**
  30691. * Sets wether the tone mapping effect is enabled.
  30692. */
  30693. toneMappingEnabled: boolean;
  30694. private _toneMappingType;
  30695. /**
  30696. * Gets the type of tone mapping effect.
  30697. */
  30698. /**
  30699. * Sets the type of tone mapping effect used in BabylonJS.
  30700. */
  30701. toneMappingType: number;
  30702. protected _contrast: number;
  30703. /**
  30704. * Gets the contrast used in the effect.
  30705. */
  30706. /**
  30707. * Sets the contrast used in the effect.
  30708. */
  30709. contrast: number;
  30710. /**
  30711. * Vignette stretch size.
  30712. */
  30713. vignetteStretch: number;
  30714. /**
  30715. * Vignette centre X Offset.
  30716. */
  30717. vignetteCentreX: number;
  30718. /**
  30719. * Vignette centre Y Offset.
  30720. */
  30721. vignetteCentreY: number;
  30722. /**
  30723. * Vignette weight or intensity of the vignette effect.
  30724. */
  30725. vignetteWeight: number;
  30726. /**
  30727. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  30728. * if vignetteEnabled is set to true.
  30729. */
  30730. vignetteColor: Color4;
  30731. /**
  30732. * Camera field of view used by the Vignette effect.
  30733. */
  30734. vignetteCameraFov: number;
  30735. private _vignetteBlendMode;
  30736. /**
  30737. * Gets the vignette blend mode allowing different kind of effect.
  30738. */
  30739. /**
  30740. * Sets the vignette blend mode allowing different kind of effect.
  30741. */
  30742. vignetteBlendMode: number;
  30743. private _vignetteEnabled;
  30744. /**
  30745. * Gets wether the vignette effect is enabled.
  30746. */
  30747. /**
  30748. * Sets wether the vignette effect is enabled.
  30749. */
  30750. vignetteEnabled: boolean;
  30751. private _applyByPostProcess;
  30752. /**
  30753. * Gets wether the image processing is applied through a post process or not.
  30754. */
  30755. /**
  30756. * Sets wether the image processing is applied through a post process or not.
  30757. */
  30758. applyByPostProcess: boolean;
  30759. private _isEnabled;
  30760. /**
  30761. * Gets wether the image processing is enabled or not.
  30762. */
  30763. /**
  30764. * Sets wether the image processing is enabled or not.
  30765. */
  30766. isEnabled: boolean;
  30767. /**
  30768. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  30769. */
  30770. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  30771. /**
  30772. * Method called each time the image processing information changes requires to recompile the effect.
  30773. */
  30774. protected _updateParameters(): void;
  30775. /**
  30776. * Gets the current class name.
  30777. * @return "ImageProcessingConfiguration"
  30778. */
  30779. getClassName(): string;
  30780. /**
  30781. * Prepare the list of uniforms associated with the Image Processing effects.
  30782. * @param uniforms The list of uniforms used in the effect
  30783. * @param defines the list of defines currently in use
  30784. */
  30785. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  30786. /**
  30787. * Prepare the list of samplers associated with the Image Processing effects.
  30788. * @param samplersList The list of uniforms used in the effect
  30789. * @param defines the list of defines currently in use
  30790. */
  30791. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  30792. /**
  30793. * Prepare the list of defines associated to the shader.
  30794. * @param defines the list of defines to complete
  30795. * @param forPostProcess Define if we are currently in post process mode or not
  30796. */
  30797. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  30798. /**
  30799. * Returns true if all the image processing information are ready.
  30800. * @returns True if ready, otherwise, false
  30801. */
  30802. isReady(): boolean;
  30803. /**
  30804. * Binds the image processing to the shader.
  30805. * @param effect The effect to bind to
  30806. * @param aspectRatio Define the current aspect ratio of the effect
  30807. */
  30808. bind(effect: Effect, aspectRatio?: number): void;
  30809. /**
  30810. * Clones the current image processing instance.
  30811. * @return The cloned image processing
  30812. */
  30813. clone(): ImageProcessingConfiguration;
  30814. /**
  30815. * Serializes the current image processing instance to a json representation.
  30816. * @return a JSON representation
  30817. */
  30818. serialize(): any;
  30819. /**
  30820. * Parses the image processing from a json representation.
  30821. * @param source the JSON source to parse
  30822. * @return The parsed image processing
  30823. */
  30824. static Parse(source: any): ImageProcessingConfiguration;
  30825. private static _VIGNETTEMODE_MULTIPLY;
  30826. private static _VIGNETTEMODE_OPAQUE;
  30827. /**
  30828. * Used to apply the vignette as a mix with the pixel color.
  30829. */
  30830. static readonly VIGNETTEMODE_MULTIPLY: number;
  30831. /**
  30832. * Used to apply the vignette as a replacement of the pixel color.
  30833. */
  30834. static readonly VIGNETTEMODE_OPAQUE: number;
  30835. }
  30836. }
  30837. declare module "babylonjs/Materials/fresnelParameters" {
  30838. import { Color3 } from "babylonjs/Maths/math";
  30839. /**
  30840. * This represents all the required information to add a fresnel effect on a material:
  30841. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30842. */
  30843. export class FresnelParameters {
  30844. private _isEnabled;
  30845. /**
  30846. * Define if the fresnel effect is enable or not.
  30847. */
  30848. isEnabled: boolean;
  30849. /**
  30850. * Define the color used on edges (grazing angle)
  30851. */
  30852. leftColor: Color3;
  30853. /**
  30854. * Define the color used on center
  30855. */
  30856. rightColor: Color3;
  30857. /**
  30858. * Define bias applied to computed fresnel term
  30859. */
  30860. bias: number;
  30861. /**
  30862. * Defined the power exponent applied to fresnel term
  30863. */
  30864. power: number;
  30865. /**
  30866. * Clones the current fresnel and its valuues
  30867. * @returns a clone fresnel configuration
  30868. */
  30869. clone(): FresnelParameters;
  30870. /**
  30871. * Serializes the current fresnel parameters to a JSON representation.
  30872. * @return the JSON serialization
  30873. */
  30874. serialize(): any;
  30875. /**
  30876. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  30877. * @param parsedFresnelParameters Define the JSON representation
  30878. * @returns the parsed parameters
  30879. */
  30880. static Parse(parsedFresnelParameters: any): FresnelParameters;
  30881. }
  30882. }
  30883. declare module "babylonjs/Misc/decorators" {
  30884. import { Nullable } from "babylonjs/types";
  30885. import { Scene } from "babylonjs/scene";
  30886. import { IAnimatable } from "babylonjs/Misc/tools";
  30887. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30888. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30889. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30890. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30891. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30892. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30893. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30894. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30895. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30896. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30897. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30898. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30899. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30900. /**
  30901. * Decorator used to define property that can be serialized as reference to a camera
  30902. * @param sourceName defines the name of the property to decorate
  30903. */
  30904. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30905. /**
  30906. * Class used to help serialization objects
  30907. */
  30908. export class SerializationHelper {
  30909. /** hidden */
  30910. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  30911. /** hidden */
  30912. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  30913. /** hidden */
  30914. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  30915. /** hidden */
  30916. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  30917. /**
  30918. * Appends the serialized animations from the source animations
  30919. * @param source Source containing the animations
  30920. * @param destination Target to store the animations
  30921. */
  30922. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30923. /**
  30924. * Static function used to serialized a specific entity
  30925. * @param entity defines the entity to serialize
  30926. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30927. * @returns a JSON compatible object representing the serialization of the entity
  30928. */
  30929. static Serialize<T>(entity: T, serializationObject?: any): any;
  30930. /**
  30931. * Creates a new entity from a serialization data object
  30932. * @param creationFunction defines a function used to instanciated the new entity
  30933. * @param source defines the source serialization data
  30934. * @param scene defines the hosting scene
  30935. * @param rootUrl defines the root url for resources
  30936. * @returns a new entity
  30937. */
  30938. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30939. /**
  30940. * Clones an object
  30941. * @param creationFunction defines the function used to instanciate the new object
  30942. * @param source defines the source object
  30943. * @returns the cloned object
  30944. */
  30945. static Clone<T>(creationFunction: () => T, source: T): T;
  30946. /**
  30947. * Instanciates a new object based on a source one (some data will be shared between both object)
  30948. * @param creationFunction defines the function used to instanciate the new object
  30949. * @param source defines the source object
  30950. * @returns the new object
  30951. */
  30952. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30953. }
  30954. }
  30955. declare module "babylonjs/Cameras/camera" {
  30956. import { SmartArray } from "babylonjs/Misc/smartArray";
  30957. import { Observable } from "babylonjs/Misc/observable";
  30958. import { Nullable } from "babylonjs/types";
  30959. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  30960. import { Scene } from "babylonjs/scene";
  30961. import { Matrix, Vector3, Viewport } from "babylonjs/Maths/math";
  30962. import { Node } from "babylonjs/node";
  30963. import { Mesh } from "babylonjs/Meshes/mesh";
  30964. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30965. import { ICullable } from "babylonjs/Culling/boundingInfo";
  30966. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30967. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30968. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  30969. import { Ray } from "babylonjs/Culling/ray";
  30970. /**
  30971. * This is the base class of all the camera used in the application.
  30972. * @see http://doc.babylonjs.com/features/cameras
  30973. */
  30974. export class Camera extends Node {
  30975. /** @hidden */
  30976. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  30977. /**
  30978. * This is the default projection mode used by the cameras.
  30979. * It helps recreating a feeling of perspective and better appreciate depth.
  30980. * This is the best way to simulate real life cameras.
  30981. */
  30982. static readonly PERSPECTIVE_CAMERA: number;
  30983. /**
  30984. * This helps creating camera with an orthographic mode.
  30985. * 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.
  30986. */
  30987. static readonly ORTHOGRAPHIC_CAMERA: number;
  30988. /**
  30989. * This is the default FOV mode for perspective cameras.
  30990. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  30991. */
  30992. static readonly FOVMODE_VERTICAL_FIXED: number;
  30993. /**
  30994. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  30995. */
  30996. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  30997. /**
  30998. * This specifies ther is no need for a camera rig.
  30999. * Basically only one eye is rendered corresponding to the camera.
  31000. */
  31001. static readonly RIG_MODE_NONE: number;
  31002. /**
  31003. * Simulates a camera Rig with one blue eye and one red eye.
  31004. * This can be use with 3d blue and red glasses.
  31005. */
  31006. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  31007. /**
  31008. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  31009. */
  31010. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  31011. /**
  31012. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  31013. */
  31014. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  31015. /**
  31016. * Defines that both eyes of the camera will be rendered over under each other.
  31017. */
  31018. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  31019. /**
  31020. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  31021. */
  31022. static readonly RIG_MODE_VR: number;
  31023. /**
  31024. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  31025. */
  31026. static readonly RIG_MODE_WEBVR: number;
  31027. /**
  31028. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  31029. */
  31030. static readonly RIG_MODE_CUSTOM: number;
  31031. /**
  31032. * Defines if by default attaching controls should prevent the default javascript event to continue.
  31033. */
  31034. static ForceAttachControlToAlwaysPreventDefault: boolean;
  31035. /**
  31036. * Define the input manager associated with the camera.
  31037. */
  31038. inputs: CameraInputsManager<Camera>;
  31039. /** @hidden */
  31040. _position: Vector3;
  31041. /**
  31042. * Define the current local position of the camera in the scene
  31043. */
  31044. position: Vector3;
  31045. /**
  31046. * The vector the camera should consider as up.
  31047. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  31048. */
  31049. upVector: Vector3;
  31050. /**
  31051. * Define the current limit on the left side for an orthographic camera
  31052. * In scene unit
  31053. */
  31054. orthoLeft: Nullable<number>;
  31055. /**
  31056. * Define the current limit on the right side for an orthographic camera
  31057. * In scene unit
  31058. */
  31059. orthoRight: Nullable<number>;
  31060. /**
  31061. * Define the current limit on the bottom side for an orthographic camera
  31062. * In scene unit
  31063. */
  31064. orthoBottom: Nullable<number>;
  31065. /**
  31066. * Define the current limit on the top side for an orthographic camera
  31067. * In scene unit
  31068. */
  31069. orthoTop: Nullable<number>;
  31070. /**
  31071. * Field Of View is set in Radians. (default is 0.8)
  31072. */
  31073. fov: number;
  31074. /**
  31075. * Define the minimum distance the camera can see from.
  31076. * This is important to note that the depth buffer are not infinite and the closer it starts
  31077. * the more your scene might encounter depth fighting issue.
  31078. */
  31079. minZ: number;
  31080. /**
  31081. * Define the maximum distance the camera can see to.
  31082. * This is important to note that the depth buffer are not infinite and the further it end
  31083. * the more your scene might encounter depth fighting issue.
  31084. */
  31085. maxZ: number;
  31086. /**
  31087. * Define the default inertia of the camera.
  31088. * This helps giving a smooth feeling to the camera movement.
  31089. */
  31090. inertia: number;
  31091. /**
  31092. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  31093. */
  31094. mode: number;
  31095. /**
  31096. * Define wether the camera is intermediate.
  31097. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  31098. */
  31099. isIntermediate: boolean;
  31100. /**
  31101. * Define the viewport of the camera.
  31102. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  31103. */
  31104. viewport: Viewport;
  31105. /**
  31106. * Restricts the camera to viewing objects with the same layerMask.
  31107. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  31108. */
  31109. layerMask: number;
  31110. /**
  31111. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  31112. */
  31113. fovMode: number;
  31114. /**
  31115. * Rig mode of the camera.
  31116. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  31117. * This is normally controlled byt the camera themselves as internal use.
  31118. */
  31119. cameraRigMode: number;
  31120. /**
  31121. * Defines the distance between both "eyes" in case of a RIG
  31122. */
  31123. interaxialDistance: number;
  31124. /**
  31125. * Defines if stereoscopic rendering is done side by side or over under.
  31126. */
  31127. isStereoscopicSideBySide: boolean;
  31128. /**
  31129. * 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
  31130. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  31131. * else in the scene.
  31132. */
  31133. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  31134. /**
  31135. * When set, the camera will render to this render target instead of the default canvas
  31136. */
  31137. outputRenderTarget: Nullable<RenderTargetTexture>;
  31138. /**
  31139. * Observable triggered when the camera view matrix has changed.
  31140. */
  31141. onViewMatrixChangedObservable: Observable<Camera>;
  31142. /**
  31143. * Observable triggered when the camera Projection matrix has changed.
  31144. */
  31145. onProjectionMatrixChangedObservable: Observable<Camera>;
  31146. /**
  31147. * Observable triggered when the inputs have been processed.
  31148. */
  31149. onAfterCheckInputsObservable: Observable<Camera>;
  31150. /**
  31151. * Observable triggered when reset has been called and applied to the camera.
  31152. */
  31153. onRestoreStateObservable: Observable<Camera>;
  31154. /** @hidden */
  31155. _cameraRigParams: any;
  31156. /** @hidden */
  31157. _rigCameras: Camera[];
  31158. /** @hidden */
  31159. _rigPostProcess: Nullable<PostProcess>;
  31160. protected _webvrViewMatrix: Matrix;
  31161. /** @hidden */
  31162. _skipRendering: boolean;
  31163. /** @hidden */
  31164. _projectionMatrix: Matrix;
  31165. /** @hidden */
  31166. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  31167. /** @hidden */
  31168. _activeMeshes: SmartArray<AbstractMesh>;
  31169. protected _globalPosition: Vector3;
  31170. /** hidden */
  31171. _computedViewMatrix: Matrix;
  31172. private _doNotComputeProjectionMatrix;
  31173. private _transformMatrix;
  31174. private _frustumPlanes;
  31175. private _refreshFrustumPlanes;
  31176. private _storedFov;
  31177. private _stateStored;
  31178. /**
  31179. * Instantiates a new camera object.
  31180. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  31181. * @see http://doc.babylonjs.com/features/cameras
  31182. * @param name Defines the name of the camera in the scene
  31183. * @param position Defines the position of the camera
  31184. * @param scene Defines the scene the camera belongs too
  31185. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  31186. */
  31187. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  31188. /**
  31189. * Store current camera state (fov, position, etc..)
  31190. * @returns the camera
  31191. */
  31192. storeState(): Camera;
  31193. /**
  31194. * Restores the camera state values if it has been stored. You must call storeState() first
  31195. */
  31196. protected _restoreStateValues(): boolean;
  31197. /**
  31198. * Restored camera state. You must call storeState() first.
  31199. * @returns true if restored and false otherwise
  31200. */
  31201. restoreState(): boolean;
  31202. /**
  31203. * Gets the class name of the camera.
  31204. * @returns the class name
  31205. */
  31206. getClassName(): string;
  31207. /** @hidden */
  31208. readonly _isCamera: boolean;
  31209. /**
  31210. * Gets a string representation of the camera useful for debug purpose.
  31211. * @param fullDetails Defines that a more verboe level of logging is required
  31212. * @returns the string representation
  31213. */
  31214. toString(fullDetails?: boolean): string;
  31215. /**
  31216. * Gets the current world space position of the camera.
  31217. */
  31218. readonly globalPosition: Vector3;
  31219. /**
  31220. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  31221. * @returns the active meshe list
  31222. */
  31223. getActiveMeshes(): SmartArray<AbstractMesh>;
  31224. /**
  31225. * Check wether a mesh is part of the current active mesh list of the camera
  31226. * @param mesh Defines the mesh to check
  31227. * @returns true if active, false otherwise
  31228. */
  31229. isActiveMesh(mesh: Mesh): boolean;
  31230. /**
  31231. * Is this camera ready to be used/rendered
  31232. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  31233. * @return true if the camera is ready
  31234. */
  31235. isReady(completeCheck?: boolean): boolean;
  31236. /** @hidden */
  31237. _initCache(): void;
  31238. /** @hidden */
  31239. _updateCache(ignoreParentClass?: boolean): void;
  31240. /** @hidden */
  31241. _isSynchronized(): boolean;
  31242. /** @hidden */
  31243. _isSynchronizedViewMatrix(): boolean;
  31244. /** @hidden */
  31245. _isSynchronizedProjectionMatrix(): boolean;
  31246. /**
  31247. * Attach the input controls to a specific dom element to get the input from.
  31248. * @param element Defines the element the controls should be listened from
  31249. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  31250. */
  31251. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31252. /**
  31253. * Detach the current controls from the specified dom element.
  31254. * @param element Defines the element to stop listening the inputs from
  31255. */
  31256. detachControl(element: HTMLElement): void;
  31257. /**
  31258. * Update the camera state according to the different inputs gathered during the frame.
  31259. */
  31260. update(): void;
  31261. /** @hidden */
  31262. _checkInputs(): void;
  31263. /** @hidden */
  31264. readonly rigCameras: Camera[];
  31265. /**
  31266. * Gets the post process used by the rig cameras
  31267. */
  31268. readonly rigPostProcess: Nullable<PostProcess>;
  31269. /**
  31270. * Internal, gets the first post proces.
  31271. * @returns the first post process to be run on this camera.
  31272. */
  31273. _getFirstPostProcess(): Nullable<PostProcess>;
  31274. private _cascadePostProcessesToRigCams;
  31275. /**
  31276. * Attach a post process to the camera.
  31277. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  31278. * @param postProcess The post process to attach to the camera
  31279. * @param insertAt The position of the post process in case several of them are in use in the scene
  31280. * @returns the position the post process has been inserted at
  31281. */
  31282. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  31283. /**
  31284. * Detach a post process to the camera.
  31285. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  31286. * @param postProcess The post process to detach from the camera
  31287. */
  31288. detachPostProcess(postProcess: PostProcess): void;
  31289. /**
  31290. * Gets the current world matrix of the camera
  31291. */
  31292. getWorldMatrix(): Matrix;
  31293. /** @hidden */
  31294. _getViewMatrix(): Matrix;
  31295. /**
  31296. * Gets the current view matrix of the camera.
  31297. * @param force forces the camera to recompute the matrix without looking at the cached state
  31298. * @returns the view matrix
  31299. */
  31300. getViewMatrix(force?: boolean): Matrix;
  31301. /**
  31302. * Freeze the projection matrix.
  31303. * It will prevent the cache check of the camera projection compute and can speed up perf
  31304. * if no parameter of the camera are meant to change
  31305. * @param projection Defines manually a projection if necessary
  31306. */
  31307. freezeProjectionMatrix(projection?: Matrix): void;
  31308. /**
  31309. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  31310. */
  31311. unfreezeProjectionMatrix(): void;
  31312. /**
  31313. * Gets the current projection matrix of the camera.
  31314. * @param force forces the camera to recompute the matrix without looking at the cached state
  31315. * @returns the projection matrix
  31316. */
  31317. getProjectionMatrix(force?: boolean): Matrix;
  31318. /**
  31319. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  31320. * @returns a Matrix
  31321. */
  31322. getTransformationMatrix(): Matrix;
  31323. private _updateFrustumPlanes;
  31324. /**
  31325. * Checks if a cullable object (mesh...) is in the camera frustum
  31326. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  31327. * @param target The object to check
  31328. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  31329. * @returns true if the object is in frustum otherwise false
  31330. */
  31331. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  31332. /**
  31333. * Checks if a cullable object (mesh...) is in the camera frustum
  31334. * Unlike isInFrustum this cheks the full bounding box
  31335. * @param target The object to check
  31336. * @returns true if the object is in frustum otherwise false
  31337. */
  31338. isCompletelyInFrustum(target: ICullable): boolean;
  31339. /**
  31340. * Gets a ray in the forward direction from the camera.
  31341. * @param length Defines the length of the ray to create
  31342. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  31343. * @param origin Defines the start point of the ray which defaults to the camera position
  31344. * @returns the forward ray
  31345. */
  31346. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  31347. /**
  31348. * Releases resources associated with this node.
  31349. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  31350. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  31351. */
  31352. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  31353. /** @hidden */
  31354. _isLeftCamera: boolean;
  31355. /**
  31356. * Gets the left camera of a rig setup in case of Rigged Camera
  31357. */
  31358. readonly isLeftCamera: boolean;
  31359. /** @hidden */
  31360. _isRightCamera: boolean;
  31361. /**
  31362. * Gets the right camera of a rig setup in case of Rigged Camera
  31363. */
  31364. readonly isRightCamera: boolean;
  31365. /**
  31366. * Gets the left camera of a rig setup in case of Rigged Camera
  31367. */
  31368. readonly leftCamera: Nullable<FreeCamera>;
  31369. /**
  31370. * Gets the right camera of a rig setup in case of Rigged Camera
  31371. */
  31372. readonly rightCamera: Nullable<FreeCamera>;
  31373. /**
  31374. * Gets the left camera target of a rig setup in case of Rigged Camera
  31375. * @returns the target position
  31376. */
  31377. getLeftTarget(): Nullable<Vector3>;
  31378. /**
  31379. * Gets the right camera target of a rig setup in case of Rigged Camera
  31380. * @returns the target position
  31381. */
  31382. getRightTarget(): Nullable<Vector3>;
  31383. /**
  31384. * @hidden
  31385. */
  31386. setCameraRigMode(mode: number, rigParams: any): void;
  31387. /** @hidden */
  31388. static _setStereoscopicRigMode(camera: Camera): void;
  31389. /** @hidden */
  31390. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  31391. /** @hidden */
  31392. static _setVRRigMode(camera: Camera, rigParams: any): void;
  31393. /** @hidden */
  31394. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  31395. /** @hidden */
  31396. _getVRProjectionMatrix(): Matrix;
  31397. protected _updateCameraRotationMatrix(): void;
  31398. protected _updateWebVRCameraRotationMatrix(): void;
  31399. /**
  31400. * This function MUST be overwritten by the different WebVR cameras available.
  31401. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  31402. * @hidden
  31403. */
  31404. _getWebVRProjectionMatrix(): Matrix;
  31405. /**
  31406. * This function MUST be overwritten by the different WebVR cameras available.
  31407. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  31408. * @hidden
  31409. */
  31410. _getWebVRViewMatrix(): Matrix;
  31411. /** @hidden */
  31412. setCameraRigParameter(name: string, value: any): void;
  31413. /**
  31414. * needs to be overridden by children so sub has required properties to be copied
  31415. * @hidden
  31416. */
  31417. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  31418. /**
  31419. * May need to be overridden by children
  31420. * @hidden
  31421. */
  31422. _updateRigCameras(): void;
  31423. /** @hidden */
  31424. _setupInputs(): void;
  31425. /**
  31426. * Serialiaze the camera setup to a json represention
  31427. * @returns the JSON representation
  31428. */
  31429. serialize(): any;
  31430. /**
  31431. * Clones the current camera.
  31432. * @param name The cloned camera name
  31433. * @returns the cloned camera
  31434. */
  31435. clone(name: string): Camera;
  31436. /**
  31437. * Gets the direction of the camera relative to a given local axis.
  31438. * @param localAxis Defines the reference axis to provide a relative direction.
  31439. * @return the direction
  31440. */
  31441. getDirection(localAxis: Vector3): Vector3;
  31442. /**
  31443. * Gets the direction of the camera relative to a given local axis into a passed vector.
  31444. * @param localAxis Defines the reference axis to provide a relative direction.
  31445. * @param result Defines the vector to store the result in
  31446. */
  31447. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  31448. /**
  31449. * Gets a camera constructor for a given camera type
  31450. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  31451. * @param name The name of the camera the result will be able to instantiate
  31452. * @param scene The scene the result will construct the camera in
  31453. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  31454. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  31455. * @returns a factory method to construc the camera
  31456. */
  31457. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  31458. /**
  31459. * Compute the world matrix of the camera.
  31460. * @returns the camera workd matrix
  31461. */
  31462. computeWorldMatrix(): Matrix;
  31463. /**
  31464. * Parse a JSON and creates the camera from the parsed information
  31465. * @param parsedCamera The JSON to parse
  31466. * @param scene The scene to instantiate the camera in
  31467. * @returns the newly constructed camera
  31468. */
  31469. static Parse(parsedCamera: any, scene: Scene): Camera;
  31470. }
  31471. }
  31472. declare module "babylonjs/Misc/tools" {
  31473. import { FloatArray, IndicesArray, Nullable } from "babylonjs/types";
  31474. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  31475. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31476. import { Observable } from "babylonjs/Misc/observable";
  31477. import { DomManagement } from "babylonjs/Misc/domManagement";
  31478. import { WebRequest } from "babylonjs/Misc/webRequest";
  31479. import { Camera } from "babylonjs/Cameras/camera";
  31480. import { Engine } from "babylonjs/Engines/engine";
  31481. import { Animation } from "babylonjs/Animations/animation";
  31482. /**
  31483. * Interface for any object that can request an animation frame
  31484. */
  31485. export interface ICustomAnimationFrameRequester {
  31486. /**
  31487. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  31488. */
  31489. renderFunction?: Function;
  31490. /**
  31491. * Called to request the next frame to render to
  31492. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  31493. */
  31494. requestAnimationFrame: Function;
  31495. /**
  31496. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  31497. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  31498. */
  31499. requestID?: number;
  31500. }
  31501. /**
  31502. * Interface containing an array of animations
  31503. */
  31504. export interface IAnimatable {
  31505. /**
  31506. * Array of animations
  31507. */
  31508. animations: Nullable<Array<Animation>>;
  31509. }
  31510. /** Interface used by value gradients (color, factor, ...) */
  31511. export interface IValueGradient {
  31512. /**
  31513. * Gets or sets the gradient value (between 0 and 1)
  31514. */
  31515. gradient: number;
  31516. }
  31517. /** Class used to store color4 gradient */
  31518. export class ColorGradient implements IValueGradient {
  31519. /**
  31520. * Gets or sets the gradient value (between 0 and 1)
  31521. */
  31522. gradient: number;
  31523. /**
  31524. * Gets or sets first associated color
  31525. */
  31526. color1: Color4;
  31527. /**
  31528. * Gets or sets second associated color
  31529. */
  31530. color2?: Color4;
  31531. /**
  31532. * Will get a color picked randomly between color1 and color2.
  31533. * If color2 is undefined then color1 will be used
  31534. * @param result defines the target Color4 to store the result in
  31535. */
  31536. getColorToRef(result: Color4): void;
  31537. }
  31538. /** Class used to store color 3 gradient */
  31539. export class Color3Gradient implements IValueGradient {
  31540. /**
  31541. * Gets or sets the gradient value (between 0 and 1)
  31542. */
  31543. gradient: number;
  31544. /**
  31545. * Gets or sets the associated color
  31546. */
  31547. color: Color3;
  31548. }
  31549. /** Class used to store factor gradient */
  31550. export class FactorGradient implements IValueGradient {
  31551. /**
  31552. * Gets or sets the gradient value (between 0 and 1)
  31553. */
  31554. gradient: number;
  31555. /**
  31556. * Gets or sets first associated factor
  31557. */
  31558. factor1: number;
  31559. /**
  31560. * Gets or sets second associated factor
  31561. */
  31562. factor2?: number;
  31563. /**
  31564. * Will get a number picked randomly between factor1 and factor2.
  31565. * If factor2 is undefined then factor1 will be used
  31566. * @returns the picked number
  31567. */
  31568. getFactor(): number;
  31569. }
  31570. /**
  31571. * @ignore
  31572. * Application error to support additional information when loading a file
  31573. */
  31574. export class LoadFileError extends Error {
  31575. /** defines the optional web request */
  31576. request?: WebRequest | undefined;
  31577. private static _setPrototypeOf;
  31578. /**
  31579. * Creates a new LoadFileError
  31580. * @param message defines the message of the error
  31581. * @param request defines the optional web request
  31582. */
  31583. constructor(message: string,
  31584. /** defines the optional web request */
  31585. request?: WebRequest | undefined);
  31586. }
  31587. /**
  31588. * Class used to define a retry strategy when error happens while loading assets
  31589. */
  31590. export class RetryStrategy {
  31591. /**
  31592. * Function used to defines an exponential back off strategy
  31593. * @param maxRetries defines the maximum number of retries (3 by default)
  31594. * @param baseInterval defines the interval between retries
  31595. * @returns the strategy function to use
  31596. */
  31597. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  31598. }
  31599. /**
  31600. * File request interface
  31601. */
  31602. export interface IFileRequest {
  31603. /**
  31604. * Raised when the request is complete (success or error).
  31605. */
  31606. onCompleteObservable: Observable<IFileRequest>;
  31607. /**
  31608. * Aborts the request for a file.
  31609. */
  31610. abort: () => void;
  31611. }
  31612. /**
  31613. * Class containing a set of static utilities functions
  31614. */
  31615. export class Tools {
  31616. /**
  31617. * Gets or sets the base URL to use to load assets
  31618. */
  31619. static BaseUrl: string;
  31620. /**
  31621. * Enable/Disable Custom HTTP Request Headers globally.
  31622. * default = false
  31623. * @see CustomRequestHeaders
  31624. */
  31625. static UseCustomRequestHeaders: boolean;
  31626. /**
  31627. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  31628. * i.e. when loading files, where the server/service expects an Authorization header
  31629. */
  31630. static CustomRequestHeaders: {
  31631. [key: string]: string;
  31632. };
  31633. /**
  31634. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  31635. */
  31636. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  31637. /**
  31638. * Default behaviour for cors in the application.
  31639. * It can be a string if the expected behavior is identical in the entire app.
  31640. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  31641. */
  31642. static CorsBehavior: string | ((url: string | string[]) => string);
  31643. /**
  31644. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31645. * @ignorenaming
  31646. */
  31647. static UseFallbackTexture: boolean;
  31648. /**
  31649. * Use this object to register external classes like custom textures or material
  31650. * to allow the laoders to instantiate them
  31651. */
  31652. static RegisteredExternalClasses: {
  31653. [key: string]: Object;
  31654. };
  31655. /**
  31656. * Texture content used if a texture cannot loaded
  31657. * @ignorenaming
  31658. */
  31659. static fallbackTexture: string;
  31660. /**
  31661. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  31662. * @param u defines the coordinate on X axis
  31663. * @param v defines the coordinate on Y axis
  31664. * @param width defines the width of the source data
  31665. * @param height defines the height of the source data
  31666. * @param pixels defines the source byte array
  31667. * @param color defines the output color
  31668. */
  31669. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  31670. /**
  31671. * Interpolates between a and b via alpha
  31672. * @param a The lower value (returned when alpha = 0)
  31673. * @param b The upper value (returned when alpha = 1)
  31674. * @param alpha The interpolation-factor
  31675. * @return The mixed value
  31676. */
  31677. static Mix(a: number, b: number, alpha: number): number;
  31678. /**
  31679. * Tries to instantiate a new object from a given class name
  31680. * @param className defines the class name to instantiate
  31681. * @returns the new object or null if the system was not able to do the instantiation
  31682. */
  31683. static Instantiate(className: string): any;
  31684. /**
  31685. * Provides a slice function that will work even on IE
  31686. * @param data defines the array to slice
  31687. * @param start defines the start of the data (optional)
  31688. * @param end defines the end of the data (optional)
  31689. * @returns the new sliced array
  31690. */
  31691. static Slice<T>(data: T, start?: number, end?: number): T;
  31692. /**
  31693. * Polyfill for setImmediate
  31694. * @param action defines the action to execute after the current execution block
  31695. */
  31696. static SetImmediate(action: () => void): void;
  31697. /**
  31698. * Function indicating if a number is an exponent of 2
  31699. * @param value defines the value to test
  31700. * @returns true if the value is an exponent of 2
  31701. */
  31702. static IsExponentOfTwo(value: number): boolean;
  31703. private static _tmpFloatArray;
  31704. /**
  31705. * Returns the nearest 32-bit single precision float representation of a Number
  31706. * @param value A Number. If the parameter is of a different type, it will get converted
  31707. * to a number or to NaN if it cannot be converted
  31708. * @returns number
  31709. */
  31710. static FloatRound(value: number): number;
  31711. /**
  31712. * Find the next highest power of two.
  31713. * @param x Number to start search from.
  31714. * @return Next highest power of two.
  31715. */
  31716. static CeilingPOT(x: number): number;
  31717. /**
  31718. * Find the next lowest power of two.
  31719. * @param x Number to start search from.
  31720. * @return Next lowest power of two.
  31721. */
  31722. static FloorPOT(x: number): number;
  31723. /**
  31724. * Find the nearest power of two.
  31725. * @param x Number to start search from.
  31726. * @return Next nearest power of two.
  31727. */
  31728. static NearestPOT(x: number): number;
  31729. /**
  31730. * Get the closest exponent of two
  31731. * @param value defines the value to approximate
  31732. * @param max defines the maximum value to return
  31733. * @param mode defines how to define the closest value
  31734. * @returns closest exponent of two of the given value
  31735. */
  31736. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31737. /**
  31738. * Extracts the filename from a path
  31739. * @param path defines the path to use
  31740. * @returns the filename
  31741. */
  31742. static GetFilename(path: string): string;
  31743. /**
  31744. * Extracts the "folder" part of a path (everything before the filename).
  31745. * @param uri The URI to extract the info from
  31746. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  31747. * @returns The "folder" part of the path
  31748. */
  31749. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  31750. /**
  31751. * Extracts text content from a DOM element hierarchy
  31752. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  31753. */
  31754. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  31755. /**
  31756. * Convert an angle in radians to degrees
  31757. * @param angle defines the angle to convert
  31758. * @returns the angle in degrees
  31759. */
  31760. static ToDegrees(angle: number): number;
  31761. /**
  31762. * Convert an angle in degrees to radians
  31763. * @param angle defines the angle to convert
  31764. * @returns the angle in radians
  31765. */
  31766. static ToRadians(angle: number): number;
  31767. /**
  31768. * Encode a buffer to a base64 string
  31769. * @param buffer defines the buffer to encode
  31770. * @returns the encoded string
  31771. */
  31772. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  31773. /**
  31774. * Extracts minimum and maximum values from a list of indexed positions
  31775. * @param positions defines the positions to use
  31776. * @param indices defines the indices to the positions
  31777. * @param indexStart defines the start index
  31778. * @param indexCount defines the end index
  31779. * @param bias defines bias value to add to the result
  31780. * @return minimum and maximum values
  31781. */
  31782. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  31783. minimum: Vector3;
  31784. maximum: Vector3;
  31785. };
  31786. /**
  31787. * Extracts minimum and maximum values from a list of positions
  31788. * @param positions defines the positions to use
  31789. * @param start defines the start index in the positions array
  31790. * @param count defines the number of positions to handle
  31791. * @param bias defines bias value to add to the result
  31792. * @param stride defines the stride size to use (distance between two positions in the positions array)
  31793. * @return minimum and maximum values
  31794. */
  31795. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  31796. minimum: Vector3;
  31797. maximum: Vector3;
  31798. };
  31799. /**
  31800. * Returns an array if obj is not an array
  31801. * @param obj defines the object to evaluate as an array
  31802. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  31803. * @returns either obj directly if obj is an array or a new array containing obj
  31804. */
  31805. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  31806. /**
  31807. * Gets the pointer prefix to use
  31808. * @returns "pointer" if touch is enabled. Else returns "mouse"
  31809. */
  31810. static GetPointerPrefix(): string;
  31811. /**
  31812. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31813. * @param func - the function to be called
  31814. * @param requester - the object that will request the next frame. Falls back to window.
  31815. * @returns frame number
  31816. */
  31817. static QueueNewFrame(func: () => void, requester?: any): number;
  31818. /**
  31819. * Ask the browser to promote the current element to fullscreen rendering mode
  31820. * @param element defines the DOM element to promote
  31821. */
  31822. static RequestFullscreen(element: HTMLElement): void;
  31823. /**
  31824. * Asks the browser to exit fullscreen mode
  31825. */
  31826. static ExitFullscreen(): void;
  31827. /**
  31828. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  31829. * @param url define the url we are trying
  31830. * @param element define the dom element where to configure the cors policy
  31831. */
  31832. static SetCorsBehavior(url: string | string[], element: {
  31833. crossOrigin: string | null;
  31834. }): void;
  31835. /**
  31836. * Removes unwanted characters from an url
  31837. * @param url defines the url to clean
  31838. * @returns the cleaned url
  31839. */
  31840. static CleanUrl(url: string): string;
  31841. /**
  31842. * Gets or sets a function used to pre-process url before using them to load assets
  31843. */
  31844. static PreprocessUrl: (url: string) => string;
  31845. /**
  31846. * Loads an image as an HTMLImageElement.
  31847. * @param input url string, ArrayBuffer, or Blob to load
  31848. * @param onLoad callback called when the image successfully loads
  31849. * @param onError callback called when the image fails to load
  31850. * @param offlineProvider offline provider for caching
  31851. * @returns the HTMLImageElement of the loaded image
  31852. */
  31853. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  31854. /**
  31855. * Loads a file
  31856. * @param url url string, ArrayBuffer, or Blob to load
  31857. * @param onSuccess callback called when the file successfully loads
  31858. * @param onProgress callback called while file is loading (if the server supports this mode)
  31859. * @param offlineProvider defines the offline provider for caching
  31860. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31861. * @param onError callback called when the file fails to load
  31862. * @returns a file request object
  31863. */
  31864. 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;
  31865. /**
  31866. * Load a script (identified by an url). When the url returns, the
  31867. * content of this file is added into a new script element, attached to the DOM (body element)
  31868. * @param scriptUrl defines the url of the script to laod
  31869. * @param onSuccess defines the callback called when the script is loaded
  31870. * @param onError defines the callback to call if an error occurs
  31871. * @param scriptId defines the id of the script element
  31872. */
  31873. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  31874. /**
  31875. * Load an asynchronous script (identified by an url). When the url returns, the
  31876. * content of this file is added into a new script element, attached to the DOM (body element)
  31877. * @param scriptUrl defines the url of the script to laod
  31878. * @param scriptId defines the id of the script element
  31879. * @returns a promise request object
  31880. */
  31881. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Nullable<Promise<boolean>>;
  31882. /**
  31883. * Loads a file from a blob
  31884. * @param fileToLoad defines the blob to use
  31885. * @param callback defines the callback to call when data is loaded
  31886. * @param progressCallback defines the callback to call during loading process
  31887. * @returns a file request object
  31888. */
  31889. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  31890. /**
  31891. * Loads a file
  31892. * @param fileToLoad defines the file to load
  31893. * @param callback defines the callback to call when data is loaded
  31894. * @param progressCallBack defines the callback to call during loading process
  31895. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  31896. * @returns a file request object
  31897. */
  31898. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  31899. /**
  31900. * Creates a data url from a given string content
  31901. * @param content defines the content to convert
  31902. * @returns the new data url link
  31903. */
  31904. static FileAsURL(content: string): string;
  31905. /**
  31906. * Format the given number to a specific decimal format
  31907. * @param value defines the number to format
  31908. * @param decimals defines the number of decimals to use
  31909. * @returns the formatted string
  31910. */
  31911. static Format(value: number, decimals?: number): string;
  31912. /**
  31913. * Checks if a given vector is inside a specific range
  31914. * @param v defines the vector to test
  31915. * @param min defines the minimum range
  31916. * @param max defines the maximum range
  31917. */
  31918. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  31919. /**
  31920. * Tries to copy an object by duplicating every property
  31921. * @param source defines the source object
  31922. * @param destination defines the target object
  31923. * @param doNotCopyList defines a list of properties to avoid
  31924. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  31925. */
  31926. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  31927. /**
  31928. * Gets a boolean indicating if the given object has no own property
  31929. * @param obj defines the object to test
  31930. * @returns true if object has no own property
  31931. */
  31932. static IsEmpty(obj: any): boolean;
  31933. /**
  31934. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  31935. * @param str Source string
  31936. * @param suffix Suffix to search for in the source string
  31937. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  31938. */
  31939. static EndsWith(str: string, suffix: string): boolean;
  31940. /**
  31941. * Function used to register events at window level
  31942. * @param events defines the events to register
  31943. */
  31944. static RegisterTopRootEvents(events: {
  31945. name: string;
  31946. handler: Nullable<(e: FocusEvent) => any>;
  31947. }[]): void;
  31948. /**
  31949. * Function used to unregister events from window level
  31950. * @param events defines the events to unregister
  31951. */
  31952. static UnregisterTopRootEvents(events: {
  31953. name: string;
  31954. handler: Nullable<(e: FocusEvent) => any>;
  31955. }[]): void;
  31956. /**
  31957. * @ignore
  31958. */
  31959. static _ScreenshotCanvas: HTMLCanvasElement;
  31960. /**
  31961. * Dumps the current bound framebuffer
  31962. * @param width defines the rendering width
  31963. * @param height defines the rendering height
  31964. * @param engine defines the hosting engine
  31965. * @param successCallback defines the callback triggered once the data are available
  31966. * @param mimeType defines the mime type of the result
  31967. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  31968. */
  31969. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31970. /**
  31971. * Converts the canvas data to blob.
  31972. * This acts as a polyfill for browsers not supporting the to blob function.
  31973. * @param canvas Defines the canvas to extract the data from
  31974. * @param successCallback Defines the callback triggered once the data are available
  31975. * @param mimeType Defines the mime type of the result
  31976. */
  31977. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  31978. /**
  31979. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  31980. * @param successCallback defines the callback triggered once the data are available
  31981. * @param mimeType defines the mime type of the result
  31982. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  31983. */
  31984. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31985. /**
  31986. * Downloads a blob in the browser
  31987. * @param blob defines the blob to download
  31988. * @param fileName defines the name of the downloaded file
  31989. */
  31990. static Download(blob: Blob, fileName: string): void;
  31991. /**
  31992. * Captures a screenshot of the current rendering
  31993. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31994. * @param engine defines the rendering engine
  31995. * @param camera defines the source camera
  31996. * @param size This parameter can be set to a single number or to an object with the
  31997. * following (optional) properties: precision, width, height. If a single number is passed,
  31998. * it will be used for both width and height. If an object is passed, the screenshot size
  31999. * will be derived from the parameters. The precision property is a multiplier allowing
  32000. * rendering at a higher or lower resolution
  32001. * @param successCallback defines the callback receives a single parameter which contains the
  32002. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32003. * src parameter of an <img> to display it
  32004. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32005. * Check your browser for supported MIME types
  32006. */
  32007. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  32008. /**
  32009. * Generates an image screenshot from the specified camera.
  32010. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32011. * @param engine The engine to use for rendering
  32012. * @param camera The camera to use for rendering
  32013. * @param size This parameter can be set to a single number or to an object with the
  32014. * following (optional) properties: precision, width, height. If a single number is passed,
  32015. * it will be used for both width and height. If an object is passed, the screenshot size
  32016. * will be derived from the parameters. The precision property is a multiplier allowing
  32017. * rendering at a higher or lower resolution
  32018. * @param successCallback The callback receives a single parameter which contains the
  32019. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32020. * src parameter of an <img> to display it
  32021. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32022. * Check your browser for supported MIME types
  32023. * @param samples Texture samples (default: 1)
  32024. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32025. * @param fileName A name for for the downloaded file.
  32026. */
  32027. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  32028. /**
  32029. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  32030. * Be aware Math.random() could cause collisions, but:
  32031. * "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"
  32032. * @returns a pseudo random id
  32033. */
  32034. static RandomId(): string;
  32035. /**
  32036. * Test if the given uri is a base64 string
  32037. * @param uri The uri to test
  32038. * @return True if the uri is a base64 string or false otherwise
  32039. */
  32040. static IsBase64(uri: string): boolean;
  32041. /**
  32042. * Decode the given base64 uri.
  32043. * @param uri The uri to decode
  32044. * @return The decoded base64 data.
  32045. */
  32046. static DecodeBase64(uri: string): ArrayBuffer;
  32047. /**
  32048. * Gets the absolute url.
  32049. * @param url the input url
  32050. * @return the absolute url
  32051. */
  32052. static GetAbsoluteUrl(url: string): string;
  32053. /**
  32054. * No log
  32055. */
  32056. static readonly NoneLogLevel: number;
  32057. /**
  32058. * Only message logs
  32059. */
  32060. static readonly MessageLogLevel: number;
  32061. /**
  32062. * Only warning logs
  32063. */
  32064. static readonly WarningLogLevel: number;
  32065. /**
  32066. * Only error logs
  32067. */
  32068. static readonly ErrorLogLevel: number;
  32069. /**
  32070. * All logs
  32071. */
  32072. static readonly AllLogLevel: number;
  32073. /**
  32074. * Gets a value indicating the number of loading errors
  32075. * @ignorenaming
  32076. */
  32077. static readonly errorsCount: number;
  32078. /**
  32079. * Callback called when a new log is added
  32080. */
  32081. static OnNewCacheEntry: (entry: string) => void;
  32082. /**
  32083. * Log a message to the console
  32084. * @param message defines the message to log
  32085. */
  32086. static Log(message: string): void;
  32087. /**
  32088. * Write a warning message to the console
  32089. * @param message defines the message to log
  32090. */
  32091. static Warn(message: string): void;
  32092. /**
  32093. * Write an error message to the console
  32094. * @param message defines the message to log
  32095. */
  32096. static Error(message: string): void;
  32097. /**
  32098. * Gets current log cache (list of logs)
  32099. */
  32100. static readonly LogCache: string;
  32101. /**
  32102. * Clears the log cache
  32103. */
  32104. static ClearLogCache(): void;
  32105. /**
  32106. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  32107. */
  32108. static LogLevels: number;
  32109. /**
  32110. * Checks if the loaded document was accessed via `file:`-Protocol.
  32111. * @returns boolean
  32112. */
  32113. static IsFileURL(): boolean;
  32114. /**
  32115. * Checks if the window object exists
  32116. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  32117. */
  32118. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  32119. /**
  32120. * No performance log
  32121. */
  32122. static readonly PerformanceNoneLogLevel: number;
  32123. /**
  32124. * Use user marks to log performance
  32125. */
  32126. static readonly PerformanceUserMarkLogLevel: number;
  32127. /**
  32128. * Log performance to the console
  32129. */
  32130. static readonly PerformanceConsoleLogLevel: number;
  32131. private static _performance;
  32132. /**
  32133. * Sets the current performance log level
  32134. */
  32135. static PerformanceLogLevel: number;
  32136. private static _StartPerformanceCounterDisabled;
  32137. private static _EndPerformanceCounterDisabled;
  32138. private static _StartUserMark;
  32139. private static _EndUserMark;
  32140. private static _StartPerformanceConsole;
  32141. private static _EndPerformanceConsole;
  32142. /**
  32143. * Starts a performance counter
  32144. */
  32145. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32146. /**
  32147. * Ends a specific performance coutner
  32148. */
  32149. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32150. /**
  32151. * Gets either window.performance.now() if supported or Date.now() else
  32152. */
  32153. static readonly Now: number;
  32154. /**
  32155. * This method will return the name of the class used to create the instance of the given object.
  32156. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  32157. * @param object the object to get the class name from
  32158. * @param isType defines if the object is actually a type
  32159. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  32160. */
  32161. static GetClassName(object: any, isType?: boolean): string;
  32162. /**
  32163. * Gets the first element of an array satisfying a given predicate
  32164. * @param array defines the array to browse
  32165. * @param predicate defines the predicate to use
  32166. * @returns null if not found or the element
  32167. */
  32168. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  32169. /**
  32170. * This method will return the name of the full name of the class, including its owning module (if any).
  32171. * 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).
  32172. * @param object the object to get the class name from
  32173. * @param isType defines if the object is actually a type
  32174. * @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.
  32175. * @ignorenaming
  32176. */
  32177. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  32178. /**
  32179. * Returns a promise that resolves after the given amount of time.
  32180. * @param delay Number of milliseconds to delay
  32181. * @returns Promise that resolves after the given amount of time
  32182. */
  32183. static DelayAsync(delay: number): Promise<void>;
  32184. /**
  32185. * Gets the current gradient from an array of IValueGradient
  32186. * @param ratio defines the current ratio to get
  32187. * @param gradients defines the array of IValueGradient
  32188. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  32189. */
  32190. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  32191. }
  32192. /**
  32193. * This class is used to track a performance counter which is number based.
  32194. * The user has access to many properties which give statistics of different nature.
  32195. *
  32196. * The implementer can track two kinds of Performance Counter: time and count.
  32197. * 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.
  32198. * 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.
  32199. */
  32200. export class PerfCounter {
  32201. /**
  32202. * Gets or sets a global boolean to turn on and off all the counters
  32203. */
  32204. static Enabled: boolean;
  32205. /**
  32206. * Returns the smallest value ever
  32207. */
  32208. readonly min: number;
  32209. /**
  32210. * Returns the biggest value ever
  32211. */
  32212. readonly max: number;
  32213. /**
  32214. * Returns the average value since the performance counter is running
  32215. */
  32216. readonly average: number;
  32217. /**
  32218. * Returns the average value of the last second the counter was monitored
  32219. */
  32220. readonly lastSecAverage: number;
  32221. /**
  32222. * Returns the current value
  32223. */
  32224. readonly current: number;
  32225. /**
  32226. * Gets the accumulated total
  32227. */
  32228. readonly total: number;
  32229. /**
  32230. * Gets the total value count
  32231. */
  32232. readonly count: number;
  32233. /**
  32234. * Creates a new counter
  32235. */
  32236. constructor();
  32237. /**
  32238. * Call this method to start monitoring a new frame.
  32239. * 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.
  32240. */
  32241. fetchNewFrame(): void;
  32242. /**
  32243. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  32244. * @param newCount the count value to add to the monitored count
  32245. * @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.
  32246. */
  32247. addCount(newCount: number, fetchResult: boolean): void;
  32248. /**
  32249. * Start monitoring this performance counter
  32250. */
  32251. beginMonitoring(): void;
  32252. /**
  32253. * Compute the time lapsed since the previous beginMonitoring() call.
  32254. * @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
  32255. */
  32256. endMonitoring(newFrame?: boolean): void;
  32257. private _fetchResult;
  32258. private _startMonitoringTime;
  32259. private _min;
  32260. private _max;
  32261. private _average;
  32262. private _current;
  32263. private _totalValueCount;
  32264. private _totalAccumulated;
  32265. private _lastSecAverage;
  32266. private _lastSecAccumulated;
  32267. private _lastSecTime;
  32268. private _lastSecValueCount;
  32269. }
  32270. /**
  32271. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  32272. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  32273. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  32274. * @param name The name of the class, case should be preserved
  32275. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  32276. */
  32277. export function className(name: string, module?: string): (target: Object) => void;
  32278. /**
  32279. * An implementation of a loop for asynchronous functions.
  32280. */
  32281. export class AsyncLoop {
  32282. /**
  32283. * Defines the number of iterations for the loop
  32284. */
  32285. iterations: number;
  32286. /**
  32287. * Defines the current index of the loop.
  32288. */
  32289. index: number;
  32290. private _done;
  32291. private _fn;
  32292. private _successCallback;
  32293. /**
  32294. * Constructor.
  32295. * @param iterations the number of iterations.
  32296. * @param func the function to run each iteration
  32297. * @param successCallback the callback that will be called upon succesful execution
  32298. * @param offset starting offset.
  32299. */
  32300. constructor(
  32301. /**
  32302. * Defines the number of iterations for the loop
  32303. */
  32304. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  32305. /**
  32306. * Execute the next iteration. Must be called after the last iteration was finished.
  32307. */
  32308. executeNext(): void;
  32309. /**
  32310. * Break the loop and run the success callback.
  32311. */
  32312. breakLoop(): void;
  32313. /**
  32314. * Create and run an async loop.
  32315. * @param iterations the number of iterations.
  32316. * @param fn the function to run each iteration
  32317. * @param successCallback the callback that will be called upon succesful execution
  32318. * @param offset starting offset.
  32319. * @returns the created async loop object
  32320. */
  32321. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  32322. /**
  32323. * A for-loop that will run a given number of iterations synchronous and the rest async.
  32324. * @param iterations total number of iterations
  32325. * @param syncedIterations number of synchronous iterations in each async iteration.
  32326. * @param fn the function to call each iteration.
  32327. * @param callback a success call back that will be called when iterating stops.
  32328. * @param breakFunction a break condition (optional)
  32329. * @param timeout timeout settings for the setTimeout function. default - 0.
  32330. * @returns the created async loop object
  32331. */
  32332. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  32333. }
  32334. }
  32335. declare module "babylonjs/Collisions/collisionCoordinator" {
  32336. import { Nullable } from "babylonjs/types";
  32337. import { Scene } from "babylonjs/scene";
  32338. import { Vector3 } from "babylonjs/Maths/math";
  32339. import { Collider } from "babylonjs/Collisions/collider";
  32340. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32341. /** @hidden */
  32342. export interface ICollisionCoordinator {
  32343. createCollider(): Collider;
  32344. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32345. init(scene: Scene): void;
  32346. }
  32347. /** @hidden */
  32348. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  32349. private _scene;
  32350. private _scaledPosition;
  32351. private _scaledVelocity;
  32352. private _finalPosition;
  32353. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32354. createCollider(): Collider;
  32355. init(scene: Scene): void;
  32356. private _collideWithWorld;
  32357. }
  32358. }
  32359. declare module "babylonjs/Inputs/scene.inputManager" {
  32360. import { Nullable } from "babylonjs/types";
  32361. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  32362. import { Vector2 } from "babylonjs/Maths/math";
  32363. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32364. import { Scene } from "babylonjs/scene";
  32365. /**
  32366. * Class used to manage all inputs for the scene.
  32367. */
  32368. export class InputManager {
  32369. /** The distance in pixel that you have to move to prevent some events */
  32370. static DragMovementThreshold: number;
  32371. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  32372. static LongPressDelay: number;
  32373. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  32374. static DoubleClickDelay: number;
  32375. /** If you need to check double click without raising a single click at first click, enable this flag */
  32376. static ExclusiveDoubleClickMode: boolean;
  32377. private _wheelEventName;
  32378. private _onPointerMove;
  32379. private _onPointerDown;
  32380. private _onPointerUp;
  32381. private _initClickEvent;
  32382. private _initActionManager;
  32383. private _delayedSimpleClick;
  32384. private _delayedSimpleClickTimeout;
  32385. private _previousDelayedSimpleClickTimeout;
  32386. private _meshPickProceed;
  32387. private _previousButtonPressed;
  32388. private _currentPickResult;
  32389. private _previousPickResult;
  32390. private _totalPointersPressed;
  32391. private _doubleClickOccured;
  32392. private _pointerOverMesh;
  32393. private _pickedDownMesh;
  32394. private _pickedUpMesh;
  32395. private _pointerX;
  32396. private _pointerY;
  32397. private _unTranslatedPointerX;
  32398. private _unTranslatedPointerY;
  32399. private _startingPointerPosition;
  32400. private _previousStartingPointerPosition;
  32401. private _startingPointerTime;
  32402. private _previousStartingPointerTime;
  32403. private _pointerCaptures;
  32404. private _onKeyDown;
  32405. private _onKeyUp;
  32406. private _onCanvasFocusObserver;
  32407. private _onCanvasBlurObserver;
  32408. private _scene;
  32409. /**
  32410. * Creates a new InputManager
  32411. * @param scene defines the hosting scene
  32412. */
  32413. constructor(scene: Scene);
  32414. /**
  32415. * Gets the mesh that is currently under the pointer
  32416. */
  32417. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32418. /**
  32419. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  32420. */
  32421. readonly unTranslatedPointer: Vector2;
  32422. /**
  32423. * Gets or sets the current on-screen X position of the pointer
  32424. */
  32425. pointerX: number;
  32426. /**
  32427. * Gets or sets the current on-screen Y position of the pointer
  32428. */
  32429. pointerY: number;
  32430. private _updatePointerPosition;
  32431. private _processPointerMove;
  32432. private _setRayOnPointerInfo;
  32433. private _checkPrePointerObservable;
  32434. /**
  32435. * Use this method to simulate a pointer move on a mesh
  32436. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32437. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32438. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32439. */
  32440. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32441. /**
  32442. * Use this method to simulate a pointer down on a mesh
  32443. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32444. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32445. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32446. */
  32447. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32448. private _processPointerDown;
  32449. /** @hidden */
  32450. _isPointerSwiping(): boolean;
  32451. /**
  32452. * Use this method to simulate a pointer up on a mesh
  32453. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32454. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32455. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32456. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32457. */
  32458. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  32459. private _processPointerUp;
  32460. /**
  32461. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32462. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32463. * @returns true if the pointer was captured
  32464. */
  32465. isPointerCaptured(pointerId?: number): boolean;
  32466. /**
  32467. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32468. * @param attachUp defines if you want to attach events to pointerup
  32469. * @param attachDown defines if you want to attach events to pointerdown
  32470. * @param attachMove defines if you want to attach events to pointermove
  32471. */
  32472. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32473. /**
  32474. * Detaches all event handlers
  32475. */
  32476. detachControl(): void;
  32477. /**
  32478. * Force the value of meshUnderPointer
  32479. * @param mesh defines the mesh to use
  32480. */
  32481. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  32482. /**
  32483. * Gets the mesh under the pointer
  32484. * @returns a Mesh or null if no mesh is under the pointer
  32485. */
  32486. getPointerOverMesh(): Nullable<AbstractMesh>;
  32487. }
  32488. }
  32489. declare module "babylonjs/Animations/animationGroup" {
  32490. import { Animatable } from "babylonjs/Animations/animatable";
  32491. import { Animation } from "babylonjs/Animations/animation";
  32492. import { Scene, IDisposable } from "babylonjs/scene";
  32493. import { Observable } from "babylonjs/Misc/observable";
  32494. import { Nullable } from "babylonjs/types";
  32495. /**
  32496. * This class defines the direct association between an animation and a target
  32497. */
  32498. export class TargetedAnimation {
  32499. /**
  32500. * Animation to perform
  32501. */
  32502. animation: Animation;
  32503. /**
  32504. * Target to animate
  32505. */
  32506. target: any;
  32507. }
  32508. /**
  32509. * Use this class to create coordinated animations on multiple targets
  32510. */
  32511. export class AnimationGroup implements IDisposable {
  32512. /** The name of the animation group */
  32513. name: string;
  32514. private _scene;
  32515. private _targetedAnimations;
  32516. private _animatables;
  32517. private _from;
  32518. private _to;
  32519. private _isStarted;
  32520. private _isPaused;
  32521. private _speedRatio;
  32522. private _loopAnimation;
  32523. /**
  32524. * Gets or sets the unique id of the node
  32525. */
  32526. uniqueId: number;
  32527. /**
  32528. * This observable will notify when one animation have ended
  32529. */
  32530. onAnimationEndObservable: Observable<TargetedAnimation>;
  32531. /**
  32532. * Observer raised when one animation loops
  32533. */
  32534. onAnimationLoopObservable: Observable<TargetedAnimation>;
  32535. /**
  32536. * This observable will notify when all animations have ended.
  32537. */
  32538. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  32539. /**
  32540. * This observable will notify when all animations have paused.
  32541. */
  32542. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  32543. /**
  32544. * This observable will notify when all animations are playing.
  32545. */
  32546. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  32547. /**
  32548. * Gets the first frame
  32549. */
  32550. readonly from: number;
  32551. /**
  32552. * Gets the last frame
  32553. */
  32554. readonly to: number;
  32555. /**
  32556. * Define if the animations are started
  32557. */
  32558. readonly isStarted: boolean;
  32559. /**
  32560. * Gets a value indicating that the current group is playing
  32561. */
  32562. readonly isPlaying: boolean;
  32563. /**
  32564. * Gets or sets the speed ratio to use for all animations
  32565. */
  32566. /**
  32567. * Gets or sets the speed ratio to use for all animations
  32568. */
  32569. speedRatio: number;
  32570. /**
  32571. * Gets or sets if all animations should loop or not
  32572. */
  32573. loopAnimation: boolean;
  32574. /**
  32575. * Gets the targeted animations for this animation group
  32576. */
  32577. readonly targetedAnimations: Array<TargetedAnimation>;
  32578. /**
  32579. * returning the list of animatables controlled by this animation group.
  32580. */
  32581. readonly animatables: Array<Animatable>;
  32582. /**
  32583. * Instantiates a new Animation Group.
  32584. * This helps managing several animations at once.
  32585. * @see http://doc.babylonjs.com/how_to/group
  32586. * @param name Defines the name of the group
  32587. * @param scene Defines the scene the group belongs to
  32588. */
  32589. constructor(
  32590. /** The name of the animation group */
  32591. name: string, scene?: Nullable<Scene>);
  32592. /**
  32593. * Add an animation (with its target) in the group
  32594. * @param animation defines the animation we want to add
  32595. * @param target defines the target of the animation
  32596. * @returns the TargetedAnimation object
  32597. */
  32598. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  32599. /**
  32600. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  32601. * It can add constant keys at begin or end
  32602. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  32603. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  32604. * @returns the animation group
  32605. */
  32606. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  32607. /**
  32608. * Start all animations on given targets
  32609. * @param loop defines if animations must loop
  32610. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  32611. * @param from defines the from key (optional)
  32612. * @param to defines the to key (optional)
  32613. * @returns the current animation group
  32614. */
  32615. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  32616. /**
  32617. * Pause all animations
  32618. * @returns the animation group
  32619. */
  32620. pause(): AnimationGroup;
  32621. /**
  32622. * Play all animations to initial state
  32623. * This function will start() the animations if they were not started or will restart() them if they were paused
  32624. * @param loop defines if animations must loop
  32625. * @returns the animation group
  32626. */
  32627. play(loop?: boolean): AnimationGroup;
  32628. /**
  32629. * Reset all animations to initial state
  32630. * @returns the animation group
  32631. */
  32632. reset(): AnimationGroup;
  32633. /**
  32634. * Restart animations from key 0
  32635. * @returns the animation group
  32636. */
  32637. restart(): AnimationGroup;
  32638. /**
  32639. * Stop all animations
  32640. * @returns the animation group
  32641. */
  32642. stop(): AnimationGroup;
  32643. /**
  32644. * Set animation weight for all animatables
  32645. * @param weight defines the weight to use
  32646. * @return the animationGroup
  32647. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32648. */
  32649. setWeightForAllAnimatables(weight: number): AnimationGroup;
  32650. /**
  32651. * Synchronize and normalize all animatables with a source animatable
  32652. * @param root defines the root animatable to synchronize with
  32653. * @return the animationGroup
  32654. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32655. */
  32656. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  32657. /**
  32658. * Goes to a specific frame in this animation group
  32659. * @param frame the frame number to go to
  32660. * @return the animationGroup
  32661. */
  32662. goToFrame(frame: number): AnimationGroup;
  32663. /**
  32664. * Dispose all associated resources
  32665. */
  32666. dispose(): void;
  32667. private _checkAnimationGroupEnded;
  32668. /**
  32669. * Clone the current animation group and returns a copy
  32670. * @param newName defines the name of the new group
  32671. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  32672. * @returns the new aniamtion group
  32673. */
  32674. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  32675. /**
  32676. * Returns a new AnimationGroup object parsed from the source provided.
  32677. * @param parsedAnimationGroup defines the source
  32678. * @param scene defines the scene that will receive the animationGroup
  32679. * @returns a new AnimationGroup
  32680. */
  32681. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  32682. /**
  32683. * Returns the string "AnimationGroup"
  32684. * @returns "AnimationGroup"
  32685. */
  32686. getClassName(): string;
  32687. /**
  32688. * Creates a detailled string about the object
  32689. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  32690. * @returns a string representing the object
  32691. */
  32692. toString(fullDetails?: boolean): string;
  32693. }
  32694. }
  32695. declare module "babylonjs/scene" {
  32696. import { Nullable } from "babylonjs/types";
  32697. import { IAnimatable, IFileRequest, PerfCounter } from "babylonjs/Misc/tools";
  32698. import { Observable } from "babylonjs/Misc/observable";
  32699. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  32700. import { Color4, Color3, Plane, Vector2, Vector3, Matrix } from "babylonjs/Maths/math";
  32701. import { Geometry } from "babylonjs/Meshes/geometry";
  32702. import { TransformNode } from "babylonjs/Meshes/transformNode";
  32703. import { SubMesh } from "babylonjs/Meshes/subMesh";
  32704. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32705. import { Mesh } from "babylonjs/Meshes/mesh";
  32706. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  32707. import { Bone } from "babylonjs/Bones/bone";
  32708. import { Skeleton } from "babylonjs/Bones/skeleton";
  32709. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  32710. import { Camera } from "babylonjs/Cameras/camera";
  32711. import { AbstractScene } from "babylonjs/abstractScene";
  32712. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  32713. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  32714. import { Material } from "babylonjs/Materials/material";
  32715. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  32716. import { Effect } from "babylonjs/Materials/effect";
  32717. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  32718. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  32719. import { Light } from "babylonjs/Lights/light";
  32720. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  32721. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  32722. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  32723. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  32724. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  32725. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  32726. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32727. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  32728. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  32729. import { Engine } from "babylonjs/Engines/engine";
  32730. import { Node } from "babylonjs/node";
  32731. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  32732. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  32733. import { WebRequest } from "babylonjs/Misc/webRequest";
  32734. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  32735. import { Ray } from "babylonjs/Culling/ray";
  32736. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  32737. import { Animation } from "babylonjs/Animations/animation";
  32738. import { Animatable } from "babylonjs/Animations/animatable";
  32739. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  32740. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  32741. import { Collider } from "babylonjs/Collisions/collider";
  32742. /**
  32743. * Define an interface for all classes that will hold resources
  32744. */
  32745. export interface IDisposable {
  32746. /**
  32747. * Releases all held resources
  32748. */
  32749. dispose(): void;
  32750. }
  32751. /** Interface defining initialization parameters for Scene class */
  32752. export interface SceneOptions {
  32753. /**
  32754. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  32755. * It will improve performance when the number of geometries becomes important.
  32756. */
  32757. useGeometryUniqueIdsMap?: boolean;
  32758. /**
  32759. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  32760. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32761. */
  32762. useMaterialMeshMap?: boolean;
  32763. /**
  32764. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  32765. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32766. */
  32767. useClonedMeshhMap?: boolean;
  32768. }
  32769. /**
  32770. * Represents a scene to be rendered by the engine.
  32771. * @see http://doc.babylonjs.com/features/scene
  32772. */
  32773. export class Scene extends AbstractScene implements IAnimatable {
  32774. private static _uniqueIdCounter;
  32775. /** The fog is deactivated */
  32776. static readonly FOGMODE_NONE: number;
  32777. /** The fog density is following an exponential function */
  32778. static readonly FOGMODE_EXP: number;
  32779. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  32780. static readonly FOGMODE_EXP2: number;
  32781. /** The fog density is following a linear function. */
  32782. static readonly FOGMODE_LINEAR: number;
  32783. /**
  32784. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  32785. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32786. */
  32787. static MinDeltaTime: number;
  32788. /**
  32789. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  32790. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32791. */
  32792. static MaxDeltaTime: number;
  32793. /**
  32794. * Factory used to create the default material.
  32795. * @param name The name of the material to create
  32796. * @param scene The scene to create the material for
  32797. * @returns The default material
  32798. */
  32799. static DefaultMaterialFactory(scene: Scene): Material;
  32800. /**
  32801. * Factory used to create the a collision coordinator.
  32802. * @returns The collision coordinator
  32803. */
  32804. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  32805. /** @hidden */
  32806. _inputManager: InputManager;
  32807. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  32808. cameraToUseForPointers: Nullable<Camera>;
  32809. /** @hidden */
  32810. readonly _isScene: boolean;
  32811. /**
  32812. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  32813. */
  32814. autoClear: boolean;
  32815. /**
  32816. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  32817. */
  32818. autoClearDepthAndStencil: boolean;
  32819. /**
  32820. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  32821. */
  32822. clearColor: Color4;
  32823. /**
  32824. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  32825. */
  32826. ambientColor: Color3;
  32827. /**
  32828. * This is use to store the default BRDF lookup for PBR materials in your scene.
  32829. * It should only be one of the following (if not the default embedded one):
  32830. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  32831. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  32832. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  32833. * The material properties need to be setup according to the type of texture in use.
  32834. */
  32835. environmentBRDFTexture: BaseTexture;
  32836. /** @hidden */
  32837. protected _environmentTexture: Nullable<BaseTexture>;
  32838. /**
  32839. * Texture used in all pbr material as the reflection texture.
  32840. * As in the majority of the scene they are the same (exception for multi room and so on),
  32841. * this is easier to reference from here than from all the materials.
  32842. */
  32843. /**
  32844. * Texture used in all pbr material as the reflection texture.
  32845. * As in the majority of the scene they are the same (exception for multi room and so on),
  32846. * this is easier to set here than in all the materials.
  32847. */
  32848. environmentTexture: Nullable<BaseTexture>;
  32849. /** @hidden */
  32850. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  32851. /**
  32852. * Default image processing configuration used either in the rendering
  32853. * Forward main pass or through the imageProcessingPostProcess if present.
  32854. * As in the majority of the scene they are the same (exception for multi camera),
  32855. * this is easier to reference from here than from all the materials and post process.
  32856. *
  32857. * No setter as we it is a shared configuration, you can set the values instead.
  32858. */
  32859. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  32860. private _forceWireframe;
  32861. /**
  32862. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  32863. */
  32864. forceWireframe: boolean;
  32865. private _forcePointsCloud;
  32866. /**
  32867. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  32868. */
  32869. forcePointsCloud: boolean;
  32870. /**
  32871. * Gets or sets the active clipplane 1
  32872. */
  32873. clipPlane: Nullable<Plane>;
  32874. /**
  32875. * Gets or sets the active clipplane 2
  32876. */
  32877. clipPlane2: Nullable<Plane>;
  32878. /**
  32879. * Gets or sets the active clipplane 3
  32880. */
  32881. clipPlane3: Nullable<Plane>;
  32882. /**
  32883. * Gets or sets the active clipplane 4
  32884. */
  32885. clipPlane4: Nullable<Plane>;
  32886. /**
  32887. * Gets or sets a boolean indicating if animations are enabled
  32888. */
  32889. animationsEnabled: boolean;
  32890. private _animationPropertiesOverride;
  32891. /**
  32892. * Gets or sets the animation properties override
  32893. */
  32894. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  32895. /**
  32896. * Gets or sets a boolean indicating if a constant deltatime has to be used
  32897. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  32898. */
  32899. useConstantAnimationDeltaTime: boolean;
  32900. /**
  32901. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  32902. * Please note that it requires to run a ray cast through the scene on every frame
  32903. */
  32904. constantlyUpdateMeshUnderPointer: boolean;
  32905. /**
  32906. * Defines the HTML cursor to use when hovering over interactive elements
  32907. */
  32908. hoverCursor: string;
  32909. /**
  32910. * Defines the HTML default cursor to use (empty by default)
  32911. */
  32912. defaultCursor: string;
  32913. /**
  32914. * This is used to call preventDefault() on pointer down
  32915. * in order to block unwanted artifacts like system double clicks
  32916. */
  32917. preventDefaultOnPointerDown: boolean;
  32918. /**
  32919. * This is used to call preventDefault() on pointer up
  32920. * in order to block unwanted artifacts like system double clicks
  32921. */
  32922. preventDefaultOnPointerUp: boolean;
  32923. /**
  32924. * Gets or sets user defined metadata
  32925. */
  32926. metadata: any;
  32927. /**
  32928. * For internal use only. Please do not use.
  32929. */
  32930. reservedDataStore: any;
  32931. /**
  32932. * Gets the name of the plugin used to load this scene (null by default)
  32933. */
  32934. loadingPluginName: string;
  32935. /**
  32936. * Use this array to add regular expressions used to disable offline support for specific urls
  32937. */
  32938. disableOfflineSupportExceptionRules: RegExp[];
  32939. /**
  32940. * An event triggered when the scene is disposed.
  32941. */
  32942. onDisposeObservable: Observable<Scene>;
  32943. private _onDisposeObserver;
  32944. /** Sets a function to be executed when this scene is disposed. */
  32945. onDispose: () => void;
  32946. /**
  32947. * An event triggered before rendering the scene (right after animations and physics)
  32948. */
  32949. onBeforeRenderObservable: Observable<Scene>;
  32950. private _onBeforeRenderObserver;
  32951. /** Sets a function to be executed before rendering this scene */
  32952. beforeRender: Nullable<() => void>;
  32953. /**
  32954. * An event triggered after rendering the scene
  32955. */
  32956. onAfterRenderObservable: Observable<Scene>;
  32957. private _onAfterRenderObserver;
  32958. /** Sets a function to be executed after rendering this scene */
  32959. afterRender: Nullable<() => void>;
  32960. /**
  32961. * An event triggered before animating the scene
  32962. */
  32963. onBeforeAnimationsObservable: Observable<Scene>;
  32964. /**
  32965. * An event triggered after animations processing
  32966. */
  32967. onAfterAnimationsObservable: Observable<Scene>;
  32968. /**
  32969. * An event triggered before draw calls are ready to be sent
  32970. */
  32971. onBeforeDrawPhaseObservable: Observable<Scene>;
  32972. /**
  32973. * An event triggered after draw calls have been sent
  32974. */
  32975. onAfterDrawPhaseObservable: Observable<Scene>;
  32976. /**
  32977. * An event triggered when the scene is ready
  32978. */
  32979. onReadyObservable: Observable<Scene>;
  32980. /**
  32981. * An event triggered before rendering a camera
  32982. */
  32983. onBeforeCameraRenderObservable: Observable<Camera>;
  32984. private _onBeforeCameraRenderObserver;
  32985. /** Sets a function to be executed before rendering a camera*/
  32986. beforeCameraRender: () => void;
  32987. /**
  32988. * An event triggered after rendering a camera
  32989. */
  32990. onAfterCameraRenderObservable: Observable<Camera>;
  32991. private _onAfterCameraRenderObserver;
  32992. /** Sets a function to be executed after rendering a camera*/
  32993. afterCameraRender: () => void;
  32994. /**
  32995. * An event triggered when active meshes evaluation is about to start
  32996. */
  32997. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  32998. /**
  32999. * An event triggered when active meshes evaluation is done
  33000. */
  33001. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  33002. /**
  33003. * An event triggered when particles rendering is about to start
  33004. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33005. */
  33006. onBeforeParticlesRenderingObservable: Observable<Scene>;
  33007. /**
  33008. * An event triggered when particles rendering is done
  33009. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33010. */
  33011. onAfterParticlesRenderingObservable: Observable<Scene>;
  33012. /**
  33013. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  33014. */
  33015. onDataLoadedObservable: Observable<Scene>;
  33016. /**
  33017. * An event triggered when a camera is created
  33018. */
  33019. onNewCameraAddedObservable: Observable<Camera>;
  33020. /**
  33021. * An event triggered when a camera is removed
  33022. */
  33023. onCameraRemovedObservable: Observable<Camera>;
  33024. /**
  33025. * An event triggered when a light is created
  33026. */
  33027. onNewLightAddedObservable: Observable<Light>;
  33028. /**
  33029. * An event triggered when a light is removed
  33030. */
  33031. onLightRemovedObservable: Observable<Light>;
  33032. /**
  33033. * An event triggered when a geometry is created
  33034. */
  33035. onNewGeometryAddedObservable: Observable<Geometry>;
  33036. /**
  33037. * An event triggered when a geometry is removed
  33038. */
  33039. onGeometryRemovedObservable: Observable<Geometry>;
  33040. /**
  33041. * An event triggered when a transform node is created
  33042. */
  33043. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  33044. /**
  33045. * An event triggered when a transform node is removed
  33046. */
  33047. onTransformNodeRemovedObservable: Observable<TransformNode>;
  33048. /**
  33049. * An event triggered when a mesh is created
  33050. */
  33051. onNewMeshAddedObservable: Observable<AbstractMesh>;
  33052. /**
  33053. * An event triggered when a mesh is removed
  33054. */
  33055. onMeshRemovedObservable: Observable<AbstractMesh>;
  33056. /**
  33057. * An event triggered when a skeleton is created
  33058. */
  33059. onNewSkeletonAddedObservable: Observable<Skeleton>;
  33060. /**
  33061. * An event triggered when a skeleton is removed
  33062. */
  33063. onSkeletonRemovedObservable: Observable<Skeleton>;
  33064. /**
  33065. * An event triggered when a material is created
  33066. */
  33067. onNewMaterialAddedObservable: Observable<Material>;
  33068. /**
  33069. * An event triggered when a material is removed
  33070. */
  33071. onMaterialRemovedObservable: Observable<Material>;
  33072. /**
  33073. * An event triggered when a texture is created
  33074. */
  33075. onNewTextureAddedObservable: Observable<BaseTexture>;
  33076. /**
  33077. * An event triggered when a texture is removed
  33078. */
  33079. onTextureRemovedObservable: Observable<BaseTexture>;
  33080. /**
  33081. * An event triggered when render targets are about to be rendered
  33082. * Can happen multiple times per frame.
  33083. */
  33084. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  33085. /**
  33086. * An event triggered when render targets were rendered.
  33087. * Can happen multiple times per frame.
  33088. */
  33089. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  33090. /**
  33091. * An event triggered before calculating deterministic simulation step
  33092. */
  33093. onBeforeStepObservable: Observable<Scene>;
  33094. /**
  33095. * An event triggered after calculating deterministic simulation step
  33096. */
  33097. onAfterStepObservable: Observable<Scene>;
  33098. /**
  33099. * An event triggered when the activeCamera property is updated
  33100. */
  33101. onActiveCameraChanged: Observable<Scene>;
  33102. /**
  33103. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  33104. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33105. * 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)
  33106. */
  33107. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33108. /**
  33109. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  33110. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33111. * 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)
  33112. */
  33113. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33114. /**
  33115. * This Observable will when a mesh has been imported into the scene.
  33116. */
  33117. onMeshImportedObservable: Observable<AbstractMesh>;
  33118. /**
  33119. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  33120. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  33121. */
  33122. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  33123. /** @hidden */
  33124. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  33125. /**
  33126. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  33127. */
  33128. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  33129. /**
  33130. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  33131. */
  33132. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  33133. /**
  33134. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  33135. */
  33136. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  33137. /** Callback called when a pointer move is detected */
  33138. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33139. /** Callback called when a pointer down is detected */
  33140. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33141. /** Callback called when a pointer up is detected */
  33142. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  33143. /** Callback called when a pointer pick is detected */
  33144. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  33145. /**
  33146. * 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).
  33147. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  33148. */
  33149. onPrePointerObservable: Observable<PointerInfoPre>;
  33150. /**
  33151. * Observable event triggered each time an input event is received from the rendering canvas
  33152. */
  33153. onPointerObservable: Observable<PointerInfo>;
  33154. /**
  33155. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  33156. */
  33157. readonly unTranslatedPointer: Vector2;
  33158. /**
  33159. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  33160. */
  33161. static DragMovementThreshold: number;
  33162. /**
  33163. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  33164. */
  33165. static LongPressDelay: number;
  33166. /**
  33167. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  33168. */
  33169. static DoubleClickDelay: number;
  33170. /** If you need to check double click without raising a single click at first click, enable this flag */
  33171. static ExclusiveDoubleClickMode: boolean;
  33172. /** @hidden */
  33173. _mirroredCameraPosition: Nullable<Vector3>;
  33174. /**
  33175. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  33176. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  33177. */
  33178. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  33179. /**
  33180. * Observable event triggered each time an keyboard event is received from the hosting window
  33181. */
  33182. onKeyboardObservable: Observable<KeyboardInfo>;
  33183. private _useRightHandedSystem;
  33184. /**
  33185. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  33186. */
  33187. useRightHandedSystem: boolean;
  33188. private _timeAccumulator;
  33189. private _currentStepId;
  33190. private _currentInternalStep;
  33191. /**
  33192. * Sets the step Id used by deterministic lock step
  33193. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33194. * @param newStepId defines the step Id
  33195. */
  33196. setStepId(newStepId: number): void;
  33197. /**
  33198. * Gets the step Id used by deterministic lock step
  33199. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33200. * @returns the step Id
  33201. */
  33202. getStepId(): number;
  33203. /**
  33204. * Gets the internal step used by deterministic lock step
  33205. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33206. * @returns the internal step
  33207. */
  33208. getInternalStep(): number;
  33209. private _fogEnabled;
  33210. /**
  33211. * Gets or sets a boolean indicating if fog is enabled on this scene
  33212. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33213. * (Default is true)
  33214. */
  33215. fogEnabled: boolean;
  33216. private _fogMode;
  33217. /**
  33218. * Gets or sets the fog mode to use
  33219. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33220. * | mode | value |
  33221. * | --- | --- |
  33222. * | FOGMODE_NONE | 0 |
  33223. * | FOGMODE_EXP | 1 |
  33224. * | FOGMODE_EXP2 | 2 |
  33225. * | FOGMODE_LINEAR | 3 |
  33226. */
  33227. fogMode: number;
  33228. /**
  33229. * Gets or sets the fog color to use
  33230. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33231. * (Default is Color3(0.2, 0.2, 0.3))
  33232. */
  33233. fogColor: Color3;
  33234. /**
  33235. * Gets or sets the fog density to use
  33236. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33237. * (Default is 0.1)
  33238. */
  33239. fogDensity: number;
  33240. /**
  33241. * Gets or sets the fog start distance to use
  33242. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33243. * (Default is 0)
  33244. */
  33245. fogStart: number;
  33246. /**
  33247. * Gets or sets the fog end distance to use
  33248. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33249. * (Default is 1000)
  33250. */
  33251. fogEnd: number;
  33252. private _shadowsEnabled;
  33253. /**
  33254. * Gets or sets a boolean indicating if shadows are enabled on this scene
  33255. */
  33256. shadowsEnabled: boolean;
  33257. private _lightsEnabled;
  33258. /**
  33259. * Gets or sets a boolean indicating if lights are enabled on this scene
  33260. */
  33261. lightsEnabled: boolean;
  33262. /** All of the active cameras added to this scene. */
  33263. activeCameras: Camera[];
  33264. /** @hidden */
  33265. _activeCamera: Nullable<Camera>;
  33266. /** Gets or sets the current active camera */
  33267. activeCamera: Nullable<Camera>;
  33268. private _defaultMaterial;
  33269. /** The default material used on meshes when no material is affected */
  33270. /** The default material used on meshes when no material is affected */
  33271. defaultMaterial: Material;
  33272. private _texturesEnabled;
  33273. /**
  33274. * Gets or sets a boolean indicating if textures are enabled on this scene
  33275. */
  33276. texturesEnabled: boolean;
  33277. /**
  33278. * Gets or sets a boolean indicating if particles are enabled on this scene
  33279. */
  33280. particlesEnabled: boolean;
  33281. /**
  33282. * Gets or sets a boolean indicating if sprites are enabled on this scene
  33283. */
  33284. spritesEnabled: boolean;
  33285. private _skeletonsEnabled;
  33286. /**
  33287. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  33288. */
  33289. skeletonsEnabled: boolean;
  33290. /**
  33291. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  33292. */
  33293. lensFlaresEnabled: boolean;
  33294. /**
  33295. * Gets or sets a boolean indicating if collisions are enabled on this scene
  33296. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33297. */
  33298. collisionsEnabled: boolean;
  33299. private _collisionCoordinator;
  33300. /** @hidden */
  33301. readonly collisionCoordinator: ICollisionCoordinator;
  33302. /**
  33303. * Defines the gravity applied to this scene (used only for collisions)
  33304. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33305. */
  33306. gravity: Vector3;
  33307. /**
  33308. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  33309. */
  33310. postProcessesEnabled: boolean;
  33311. /**
  33312. * The list of postprocesses added to the scene
  33313. */
  33314. postProcesses: PostProcess[];
  33315. /**
  33316. * Gets the current postprocess manager
  33317. */
  33318. postProcessManager: PostProcessManager;
  33319. /**
  33320. * Gets or sets a boolean indicating if render targets are enabled on this scene
  33321. */
  33322. renderTargetsEnabled: boolean;
  33323. /**
  33324. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  33325. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  33326. */
  33327. dumpNextRenderTargets: boolean;
  33328. /**
  33329. * The list of user defined render targets added to the scene
  33330. */
  33331. customRenderTargets: RenderTargetTexture[];
  33332. /**
  33333. * Defines if texture loading must be delayed
  33334. * If true, textures will only be loaded when they need to be rendered
  33335. */
  33336. useDelayedTextureLoading: boolean;
  33337. /**
  33338. * Gets the list of meshes imported to the scene through SceneLoader
  33339. */
  33340. importedMeshesFiles: String[];
  33341. /**
  33342. * Gets or sets a boolean indicating if probes are enabled on this scene
  33343. */
  33344. probesEnabled: boolean;
  33345. /**
  33346. * Gets or sets the current offline provider to use to store scene data
  33347. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  33348. */
  33349. offlineProvider: IOfflineProvider;
  33350. /**
  33351. * Gets or sets the action manager associated with the scene
  33352. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33353. */
  33354. actionManager: AbstractActionManager;
  33355. private _meshesForIntersections;
  33356. /**
  33357. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  33358. */
  33359. proceduralTexturesEnabled: boolean;
  33360. private _engine;
  33361. private _totalVertices;
  33362. /** @hidden */
  33363. _activeIndices: PerfCounter;
  33364. /** @hidden */
  33365. _activeParticles: PerfCounter;
  33366. /** @hidden */
  33367. _activeBones: PerfCounter;
  33368. private _animationRatio;
  33369. /** @hidden */
  33370. _animationTimeLast: number;
  33371. /** @hidden */
  33372. _animationTime: number;
  33373. /**
  33374. * Gets or sets a general scale for animation speed
  33375. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  33376. */
  33377. animationTimeScale: number;
  33378. /** @hidden */
  33379. _cachedMaterial: Nullable<Material>;
  33380. /** @hidden */
  33381. _cachedEffect: Nullable<Effect>;
  33382. /** @hidden */
  33383. _cachedVisibility: Nullable<number>;
  33384. private _renderId;
  33385. private _frameId;
  33386. private _executeWhenReadyTimeoutId;
  33387. private _intermediateRendering;
  33388. private _viewUpdateFlag;
  33389. private _projectionUpdateFlag;
  33390. /** @hidden */
  33391. _toBeDisposed: Nullable<IDisposable>[];
  33392. private _activeRequests;
  33393. /** @hidden */
  33394. _pendingData: any[];
  33395. private _isDisposed;
  33396. /**
  33397. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  33398. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  33399. */
  33400. dispatchAllSubMeshesOfActiveMeshes: boolean;
  33401. private _activeMeshes;
  33402. private _processedMaterials;
  33403. private _renderTargets;
  33404. /** @hidden */
  33405. _activeParticleSystems: SmartArray<IParticleSystem>;
  33406. private _activeSkeletons;
  33407. private _softwareSkinnedMeshes;
  33408. private _renderingManager;
  33409. /** @hidden */
  33410. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  33411. private _transformMatrix;
  33412. private _sceneUbo;
  33413. /** @hidden */
  33414. _viewMatrix: Matrix;
  33415. private _projectionMatrix;
  33416. /** @hidden */
  33417. _forcedViewPosition: Nullable<Vector3>;
  33418. /** @hidden */
  33419. _frustumPlanes: Plane[];
  33420. /**
  33421. * Gets the list of frustum planes (built from the active camera)
  33422. */
  33423. readonly frustumPlanes: Plane[];
  33424. /**
  33425. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  33426. * This is useful if there are more lights that the maximum simulteanous authorized
  33427. */
  33428. requireLightSorting: boolean;
  33429. /** @hidden */
  33430. readonly useMaterialMeshMap: boolean;
  33431. /** @hidden */
  33432. readonly useClonedMeshhMap: boolean;
  33433. private _externalData;
  33434. private _uid;
  33435. /**
  33436. * @hidden
  33437. * Backing store of defined scene components.
  33438. */
  33439. _components: ISceneComponent[];
  33440. /**
  33441. * @hidden
  33442. * Backing store of defined scene components.
  33443. */
  33444. _serializableComponents: ISceneSerializableComponent[];
  33445. /**
  33446. * List of components to register on the next registration step.
  33447. */
  33448. private _transientComponents;
  33449. /**
  33450. * Registers the transient components if needed.
  33451. */
  33452. private _registerTransientComponents;
  33453. /**
  33454. * @hidden
  33455. * Add a component to the scene.
  33456. * Note that the ccomponent could be registered on th next frame if this is called after
  33457. * the register component stage.
  33458. * @param component Defines the component to add to the scene
  33459. */
  33460. _addComponent(component: ISceneComponent): void;
  33461. /**
  33462. * @hidden
  33463. * Gets a component from the scene.
  33464. * @param name defines the name of the component to retrieve
  33465. * @returns the component or null if not present
  33466. */
  33467. _getComponent(name: string): Nullable<ISceneComponent>;
  33468. /**
  33469. * @hidden
  33470. * Defines the actions happening before camera updates.
  33471. */
  33472. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  33473. /**
  33474. * @hidden
  33475. * Defines the actions happening before clear the canvas.
  33476. */
  33477. _beforeClearStage: Stage<SimpleStageAction>;
  33478. /**
  33479. * @hidden
  33480. * Defines the actions when collecting render targets for the frame.
  33481. */
  33482. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33483. /**
  33484. * @hidden
  33485. * Defines the actions happening for one camera in the frame.
  33486. */
  33487. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33488. /**
  33489. * @hidden
  33490. * Defines the actions happening during the per mesh ready checks.
  33491. */
  33492. _isReadyForMeshStage: Stage<MeshStageAction>;
  33493. /**
  33494. * @hidden
  33495. * Defines the actions happening before evaluate active mesh checks.
  33496. */
  33497. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  33498. /**
  33499. * @hidden
  33500. * Defines the actions happening during the evaluate sub mesh checks.
  33501. */
  33502. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  33503. /**
  33504. * @hidden
  33505. * Defines the actions happening during the active mesh stage.
  33506. */
  33507. _activeMeshStage: Stage<ActiveMeshStageAction>;
  33508. /**
  33509. * @hidden
  33510. * Defines the actions happening during the per camera render target step.
  33511. */
  33512. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  33513. /**
  33514. * @hidden
  33515. * Defines the actions happening just before the active camera is drawing.
  33516. */
  33517. _beforeCameraDrawStage: Stage<CameraStageAction>;
  33518. /**
  33519. * @hidden
  33520. * Defines the actions happening just before a render target is drawing.
  33521. */
  33522. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33523. /**
  33524. * @hidden
  33525. * Defines the actions happening just before a rendering group is drawing.
  33526. */
  33527. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33528. /**
  33529. * @hidden
  33530. * Defines the actions happening just before a mesh is drawing.
  33531. */
  33532. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33533. /**
  33534. * @hidden
  33535. * Defines the actions happening just after a mesh has been drawn.
  33536. */
  33537. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33538. /**
  33539. * @hidden
  33540. * Defines the actions happening just after a rendering group has been drawn.
  33541. */
  33542. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33543. /**
  33544. * @hidden
  33545. * Defines the actions happening just after the active camera has been drawn.
  33546. */
  33547. _afterCameraDrawStage: Stage<CameraStageAction>;
  33548. /**
  33549. * @hidden
  33550. * Defines the actions happening just after a render target has been drawn.
  33551. */
  33552. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33553. /**
  33554. * @hidden
  33555. * Defines the actions happening just after rendering all cameras and computing intersections.
  33556. */
  33557. _afterRenderStage: Stage<SimpleStageAction>;
  33558. /**
  33559. * @hidden
  33560. * Defines the actions happening when a pointer move event happens.
  33561. */
  33562. _pointerMoveStage: Stage<PointerMoveStageAction>;
  33563. /**
  33564. * @hidden
  33565. * Defines the actions happening when a pointer down event happens.
  33566. */
  33567. _pointerDownStage: Stage<PointerUpDownStageAction>;
  33568. /**
  33569. * @hidden
  33570. * Defines the actions happening when a pointer up event happens.
  33571. */
  33572. _pointerUpStage: Stage<PointerUpDownStageAction>;
  33573. /**
  33574. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  33575. */
  33576. private geometriesByUniqueId;
  33577. /**
  33578. * Creates a new Scene
  33579. * @param engine defines the engine to use to render this scene
  33580. * @param options defines the scene options
  33581. */
  33582. constructor(engine: Engine, options?: SceneOptions);
  33583. /**
  33584. * Gets a string idenfifying the name of the class
  33585. * @returns "Scene" string
  33586. */
  33587. getClassName(): string;
  33588. private _defaultMeshCandidates;
  33589. /**
  33590. * @hidden
  33591. */
  33592. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  33593. private _defaultSubMeshCandidates;
  33594. /**
  33595. * @hidden
  33596. */
  33597. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  33598. /**
  33599. * Sets the default candidate providers for the scene.
  33600. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  33601. * and getCollidingSubMeshCandidates to their default function
  33602. */
  33603. setDefaultCandidateProviders(): void;
  33604. /**
  33605. * Gets the mesh that is currently under the pointer
  33606. */
  33607. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33608. /**
  33609. * Gets or sets the current on-screen X position of the pointer
  33610. */
  33611. pointerX: number;
  33612. /**
  33613. * Gets or sets the current on-screen Y position of the pointer
  33614. */
  33615. pointerY: number;
  33616. /**
  33617. * Gets the cached material (ie. the latest rendered one)
  33618. * @returns the cached material
  33619. */
  33620. getCachedMaterial(): Nullable<Material>;
  33621. /**
  33622. * Gets the cached effect (ie. the latest rendered one)
  33623. * @returns the cached effect
  33624. */
  33625. getCachedEffect(): Nullable<Effect>;
  33626. /**
  33627. * Gets the cached visibility state (ie. the latest rendered one)
  33628. * @returns the cached visibility state
  33629. */
  33630. getCachedVisibility(): Nullable<number>;
  33631. /**
  33632. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  33633. * @param material defines the current material
  33634. * @param effect defines the current effect
  33635. * @param visibility defines the current visibility state
  33636. * @returns true if one parameter is not cached
  33637. */
  33638. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  33639. /**
  33640. * Gets the engine associated with the scene
  33641. * @returns an Engine
  33642. */
  33643. getEngine(): Engine;
  33644. /**
  33645. * Gets the total number of vertices rendered per frame
  33646. * @returns the total number of vertices rendered per frame
  33647. */
  33648. getTotalVertices(): number;
  33649. /**
  33650. * Gets the performance counter for total vertices
  33651. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33652. */
  33653. readonly totalVerticesPerfCounter: PerfCounter;
  33654. /**
  33655. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  33656. * @returns the total number of active indices rendered per frame
  33657. */
  33658. getActiveIndices(): number;
  33659. /**
  33660. * Gets the performance counter for active indices
  33661. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33662. */
  33663. readonly totalActiveIndicesPerfCounter: PerfCounter;
  33664. /**
  33665. * Gets the total number of active particles rendered per frame
  33666. * @returns the total number of active particles rendered per frame
  33667. */
  33668. getActiveParticles(): number;
  33669. /**
  33670. * Gets the performance counter for active particles
  33671. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33672. */
  33673. readonly activeParticlesPerfCounter: PerfCounter;
  33674. /**
  33675. * Gets the total number of active bones rendered per frame
  33676. * @returns the total number of active bones rendered per frame
  33677. */
  33678. getActiveBones(): number;
  33679. /**
  33680. * Gets the performance counter for active bones
  33681. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33682. */
  33683. readonly activeBonesPerfCounter: PerfCounter;
  33684. /**
  33685. * Gets the array of active meshes
  33686. * @returns an array of AbstractMesh
  33687. */
  33688. getActiveMeshes(): SmartArray<AbstractMesh>;
  33689. /**
  33690. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  33691. * @returns a number
  33692. */
  33693. getAnimationRatio(): number;
  33694. /**
  33695. * Gets an unique Id for the current render phase
  33696. * @returns a number
  33697. */
  33698. getRenderId(): number;
  33699. /**
  33700. * Gets an unique Id for the current frame
  33701. * @returns a number
  33702. */
  33703. getFrameId(): number;
  33704. /** Call this function if you want to manually increment the render Id*/
  33705. incrementRenderId(): void;
  33706. private _createUbo;
  33707. /**
  33708. * Use this method to simulate a pointer move on a mesh
  33709. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33710. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33711. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33712. * @returns the current scene
  33713. */
  33714. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33715. /**
  33716. * Use this method to simulate a pointer down on a mesh
  33717. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33718. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33719. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33720. * @returns the current scene
  33721. */
  33722. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33723. /**
  33724. * Use this method to simulate a pointer up on a mesh
  33725. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33726. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33727. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33728. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33729. * @returns the current scene
  33730. */
  33731. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  33732. /**
  33733. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33734. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33735. * @returns true if the pointer was captured
  33736. */
  33737. isPointerCaptured(pointerId?: number): boolean;
  33738. /**
  33739. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33740. * @param attachUp defines if you want to attach events to pointerup
  33741. * @param attachDown defines if you want to attach events to pointerdown
  33742. * @param attachMove defines if you want to attach events to pointermove
  33743. */
  33744. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33745. /** Detaches all event handlers*/
  33746. detachControl(): void;
  33747. /**
  33748. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  33749. * Delay loaded resources are not taking in account
  33750. * @return true if all required resources are ready
  33751. */
  33752. isReady(): boolean;
  33753. /** Resets all cached information relative to material (including effect and visibility) */
  33754. resetCachedMaterial(): void;
  33755. /**
  33756. * Registers a function to be called before every frame render
  33757. * @param func defines the function to register
  33758. */
  33759. registerBeforeRender(func: () => void): void;
  33760. /**
  33761. * Unregisters a function called before every frame render
  33762. * @param func defines the function to unregister
  33763. */
  33764. unregisterBeforeRender(func: () => void): void;
  33765. /**
  33766. * Registers a function to be called after every frame render
  33767. * @param func defines the function to register
  33768. */
  33769. registerAfterRender(func: () => void): void;
  33770. /**
  33771. * Unregisters a function called after every frame render
  33772. * @param func defines the function to unregister
  33773. */
  33774. unregisterAfterRender(func: () => void): void;
  33775. private _executeOnceBeforeRender;
  33776. /**
  33777. * The provided function will run before render once and will be disposed afterwards.
  33778. * A timeout delay can be provided so that the function will be executed in N ms.
  33779. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  33780. * @param func The function to be executed.
  33781. * @param timeout optional delay in ms
  33782. */
  33783. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  33784. /** @hidden */
  33785. _addPendingData(data: any): void;
  33786. /** @hidden */
  33787. _removePendingData(data: any): void;
  33788. /**
  33789. * Returns the number of items waiting to be loaded
  33790. * @returns the number of items waiting to be loaded
  33791. */
  33792. getWaitingItemsCount(): number;
  33793. /**
  33794. * Returns a boolean indicating if the scene is still loading data
  33795. */
  33796. readonly isLoading: boolean;
  33797. /**
  33798. * Registers a function to be executed when the scene is ready
  33799. * @param {Function} func - the function to be executed
  33800. */
  33801. executeWhenReady(func: () => void): void;
  33802. /**
  33803. * Returns a promise that resolves when the scene is ready
  33804. * @returns A promise that resolves when the scene is ready
  33805. */
  33806. whenReadyAsync(): Promise<void>;
  33807. /** @hidden */
  33808. _checkIsReady(): void;
  33809. /**
  33810. * Gets all animatable attached to the scene
  33811. */
  33812. readonly animatables: Animatable[];
  33813. /**
  33814. * Resets the last animation time frame.
  33815. * Useful to override when animations start running when loading a scene for the first time.
  33816. */
  33817. resetLastAnimationTimeFrame(): void;
  33818. /**
  33819. * Gets the current view matrix
  33820. * @returns a Matrix
  33821. */
  33822. getViewMatrix(): Matrix;
  33823. /**
  33824. * Gets the current projection matrix
  33825. * @returns a Matrix
  33826. */
  33827. getProjectionMatrix(): Matrix;
  33828. /**
  33829. * Gets the current transform matrix
  33830. * @returns a Matrix made of View * Projection
  33831. */
  33832. getTransformMatrix(): Matrix;
  33833. /**
  33834. * Sets the current transform matrix
  33835. * @param viewL defines the View matrix to use
  33836. * @param projectionL defines the Projection matrix to use
  33837. * @param viewR defines the right View matrix to use (if provided)
  33838. * @param projectionR defines the right Projection matrix to use (if provided)
  33839. */
  33840. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  33841. /**
  33842. * Gets the uniform buffer used to store scene data
  33843. * @returns a UniformBuffer
  33844. */
  33845. getSceneUniformBuffer(): UniformBuffer;
  33846. /**
  33847. * Gets an unique (relatively to the current scene) Id
  33848. * @returns an unique number for the scene
  33849. */
  33850. getUniqueId(): number;
  33851. /**
  33852. * Add a mesh to the list of scene's meshes
  33853. * @param newMesh defines the mesh to add
  33854. * @param recursive if all child meshes should also be added to the scene
  33855. */
  33856. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  33857. /**
  33858. * Remove a mesh for the list of scene's meshes
  33859. * @param toRemove defines the mesh to remove
  33860. * @param recursive if all child meshes should also be removed from the scene
  33861. * @returns the index where the mesh was in the mesh list
  33862. */
  33863. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  33864. /**
  33865. * Add a transform node to the list of scene's transform nodes
  33866. * @param newTransformNode defines the transform node to add
  33867. */
  33868. addTransformNode(newTransformNode: TransformNode): void;
  33869. /**
  33870. * Remove a transform node for the list of scene's transform nodes
  33871. * @param toRemove defines the transform node to remove
  33872. * @returns the index where the transform node was in the transform node list
  33873. */
  33874. removeTransformNode(toRemove: TransformNode): number;
  33875. /**
  33876. * Remove a skeleton for the list of scene's skeletons
  33877. * @param toRemove defines the skeleton to remove
  33878. * @returns the index where the skeleton was in the skeleton list
  33879. */
  33880. removeSkeleton(toRemove: Skeleton): number;
  33881. /**
  33882. * Remove a morph target for the list of scene's morph targets
  33883. * @param toRemove defines the morph target to remove
  33884. * @returns the index where the morph target was in the morph target list
  33885. */
  33886. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  33887. /**
  33888. * Remove a light for the list of scene's lights
  33889. * @param toRemove defines the light to remove
  33890. * @returns the index where the light was in the light list
  33891. */
  33892. removeLight(toRemove: Light): number;
  33893. /**
  33894. * Remove a camera for the list of scene's cameras
  33895. * @param toRemove defines the camera to remove
  33896. * @returns the index where the camera was in the camera list
  33897. */
  33898. removeCamera(toRemove: Camera): number;
  33899. /**
  33900. * Remove a particle system for the list of scene's particle systems
  33901. * @param toRemove defines the particle system to remove
  33902. * @returns the index where the particle system was in the particle system list
  33903. */
  33904. removeParticleSystem(toRemove: IParticleSystem): number;
  33905. /**
  33906. * Remove a animation for the list of scene's animations
  33907. * @param toRemove defines the animation to remove
  33908. * @returns the index where the animation was in the animation list
  33909. */
  33910. removeAnimation(toRemove: Animation): number;
  33911. /**
  33912. * Will stop the animation of the given target
  33913. * @param target - the target
  33914. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  33915. * @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)
  33916. */
  33917. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  33918. /**
  33919. * Removes the given animation group from this scene.
  33920. * @param toRemove The animation group to remove
  33921. * @returns The index of the removed animation group
  33922. */
  33923. removeAnimationGroup(toRemove: AnimationGroup): number;
  33924. /**
  33925. * Removes the given multi-material from this scene.
  33926. * @param toRemove The multi-material to remove
  33927. * @returns The index of the removed multi-material
  33928. */
  33929. removeMultiMaterial(toRemove: MultiMaterial): number;
  33930. /**
  33931. * Removes the given material from this scene.
  33932. * @param toRemove The material to remove
  33933. * @returns The index of the removed material
  33934. */
  33935. removeMaterial(toRemove: Material): number;
  33936. /**
  33937. * Removes the given action manager from this scene.
  33938. * @param toRemove The action manager to remove
  33939. * @returns The index of the removed action manager
  33940. */
  33941. removeActionManager(toRemove: AbstractActionManager): number;
  33942. /**
  33943. * Removes the given texture from this scene.
  33944. * @param toRemove The texture to remove
  33945. * @returns The index of the removed texture
  33946. */
  33947. removeTexture(toRemove: BaseTexture): number;
  33948. /**
  33949. * Adds the given light to this scene
  33950. * @param newLight The light to add
  33951. */
  33952. addLight(newLight: Light): void;
  33953. /**
  33954. * Sorts the list list based on light priorities
  33955. */
  33956. sortLightsByPriority(): void;
  33957. /**
  33958. * Adds the given camera to this scene
  33959. * @param newCamera The camera to add
  33960. */
  33961. addCamera(newCamera: Camera): void;
  33962. /**
  33963. * Adds the given skeleton to this scene
  33964. * @param newSkeleton The skeleton to add
  33965. */
  33966. addSkeleton(newSkeleton: Skeleton): void;
  33967. /**
  33968. * Adds the given particle system to this scene
  33969. * @param newParticleSystem The particle system to add
  33970. */
  33971. addParticleSystem(newParticleSystem: IParticleSystem): void;
  33972. /**
  33973. * Adds the given animation to this scene
  33974. * @param newAnimation The animation to add
  33975. */
  33976. addAnimation(newAnimation: Animation): void;
  33977. /**
  33978. * Adds the given animation group to this scene.
  33979. * @param newAnimationGroup The animation group to add
  33980. */
  33981. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  33982. /**
  33983. * Adds the given multi-material to this scene
  33984. * @param newMultiMaterial The multi-material to add
  33985. */
  33986. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  33987. /**
  33988. * Adds the given material to this scene
  33989. * @param newMaterial The material to add
  33990. */
  33991. addMaterial(newMaterial: Material): void;
  33992. /**
  33993. * Adds the given morph target to this scene
  33994. * @param newMorphTargetManager The morph target to add
  33995. */
  33996. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  33997. /**
  33998. * Adds the given geometry to this scene
  33999. * @param newGeometry The geometry to add
  34000. */
  34001. addGeometry(newGeometry: Geometry): void;
  34002. /**
  34003. * Adds the given action manager to this scene
  34004. * @param newActionManager The action manager to add
  34005. */
  34006. addActionManager(newActionManager: AbstractActionManager): void;
  34007. /**
  34008. * Adds the given texture to this scene.
  34009. * @param newTexture The texture to add
  34010. */
  34011. addTexture(newTexture: BaseTexture): void;
  34012. /**
  34013. * Switch active camera
  34014. * @param newCamera defines the new active camera
  34015. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  34016. */
  34017. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  34018. /**
  34019. * sets the active camera of the scene using its ID
  34020. * @param id defines the camera's ID
  34021. * @return the new active camera or null if none found.
  34022. */
  34023. setActiveCameraByID(id: string): Nullable<Camera>;
  34024. /**
  34025. * sets the active camera of the scene using its name
  34026. * @param name defines the camera's name
  34027. * @returns the new active camera or null if none found.
  34028. */
  34029. setActiveCameraByName(name: string): Nullable<Camera>;
  34030. /**
  34031. * get an animation group using its name
  34032. * @param name defines the material's name
  34033. * @return the animation group or null if none found.
  34034. */
  34035. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  34036. /**
  34037. * Get a material using its unique id
  34038. * @param uniqueId defines the material's unique id
  34039. * @return the material or null if none found.
  34040. */
  34041. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  34042. /**
  34043. * get a material using its id
  34044. * @param id defines the material's ID
  34045. * @return the material or null if none found.
  34046. */
  34047. getMaterialByID(id: string): Nullable<Material>;
  34048. /**
  34049. * Gets a material using its name
  34050. * @param name defines the material's name
  34051. * @return the material or null if none found.
  34052. */
  34053. getMaterialByName(name: string): Nullable<Material>;
  34054. /**
  34055. * Gets a camera using its id
  34056. * @param id defines the id to look for
  34057. * @returns the camera or null if not found
  34058. */
  34059. getCameraByID(id: string): Nullable<Camera>;
  34060. /**
  34061. * Gets a camera using its unique id
  34062. * @param uniqueId defines the unique id to look for
  34063. * @returns the camera or null if not found
  34064. */
  34065. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  34066. /**
  34067. * Gets a camera using its name
  34068. * @param name defines the camera's name
  34069. * @return the camera or null if none found.
  34070. */
  34071. getCameraByName(name: string): Nullable<Camera>;
  34072. /**
  34073. * Gets a bone using its id
  34074. * @param id defines the bone's id
  34075. * @return the bone or null if not found
  34076. */
  34077. getBoneByID(id: string): Nullable<Bone>;
  34078. /**
  34079. * Gets a bone using its id
  34080. * @param name defines the bone's name
  34081. * @return the bone or null if not found
  34082. */
  34083. getBoneByName(name: string): Nullable<Bone>;
  34084. /**
  34085. * Gets a light node using its name
  34086. * @param name defines the the light's name
  34087. * @return the light or null if none found.
  34088. */
  34089. getLightByName(name: string): Nullable<Light>;
  34090. /**
  34091. * Gets a light node using its id
  34092. * @param id defines the light's id
  34093. * @return the light or null if none found.
  34094. */
  34095. getLightByID(id: string): Nullable<Light>;
  34096. /**
  34097. * Gets a light node using its scene-generated unique ID
  34098. * @param uniqueId defines the light's unique id
  34099. * @return the light or null if none found.
  34100. */
  34101. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  34102. /**
  34103. * Gets a particle system by id
  34104. * @param id defines the particle system id
  34105. * @return the corresponding system or null if none found
  34106. */
  34107. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  34108. /**
  34109. * Gets a geometry using its ID
  34110. * @param id defines the geometry's id
  34111. * @return the geometry or null if none found.
  34112. */
  34113. getGeometryByID(id: string): Nullable<Geometry>;
  34114. private _getGeometryByUniqueID;
  34115. /**
  34116. * Add a new geometry to this scene
  34117. * @param geometry defines the geometry to be added to the scene.
  34118. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  34119. * @return a boolean defining if the geometry was added or not
  34120. */
  34121. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  34122. /**
  34123. * Removes an existing geometry
  34124. * @param geometry defines the geometry to be removed from the scene
  34125. * @return a boolean defining if the geometry was removed or not
  34126. */
  34127. removeGeometry(geometry: Geometry): boolean;
  34128. /**
  34129. * Gets the list of geometries attached to the scene
  34130. * @returns an array of Geometry
  34131. */
  34132. getGeometries(): Geometry[];
  34133. /**
  34134. * Gets the first added mesh found of a given ID
  34135. * @param id defines the id to search for
  34136. * @return the mesh found or null if not found at all
  34137. */
  34138. getMeshByID(id: string): Nullable<AbstractMesh>;
  34139. /**
  34140. * Gets a list of meshes using their id
  34141. * @param id defines the id to search for
  34142. * @returns a list of meshes
  34143. */
  34144. getMeshesByID(id: string): Array<AbstractMesh>;
  34145. /**
  34146. * Gets the first added transform node found of a given ID
  34147. * @param id defines the id to search for
  34148. * @return the found transform node or null if not found at all.
  34149. */
  34150. getTransformNodeByID(id: string): Nullable<TransformNode>;
  34151. /**
  34152. * Gets a transform node with its auto-generated unique id
  34153. * @param uniqueId efines the unique id to search for
  34154. * @return the found transform node or null if not found at all.
  34155. */
  34156. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  34157. /**
  34158. * Gets a list of transform nodes using their id
  34159. * @param id defines the id to search for
  34160. * @returns a list of transform nodes
  34161. */
  34162. getTransformNodesByID(id: string): Array<TransformNode>;
  34163. /**
  34164. * Gets a mesh with its auto-generated unique id
  34165. * @param uniqueId defines the unique id to search for
  34166. * @return the found mesh or null if not found at all.
  34167. */
  34168. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  34169. /**
  34170. * Gets a the last added mesh using a given id
  34171. * @param id defines the id to search for
  34172. * @return the found mesh or null if not found at all.
  34173. */
  34174. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  34175. /**
  34176. * Gets a the last added node (Mesh, Camera, Light) using a given id
  34177. * @param id defines the id to search for
  34178. * @return the found node or null if not found at all
  34179. */
  34180. getLastEntryByID(id: string): Nullable<Node>;
  34181. /**
  34182. * Gets a node (Mesh, Camera, Light) using a given id
  34183. * @param id defines the id to search for
  34184. * @return the found node or null if not found at all
  34185. */
  34186. getNodeByID(id: string): Nullable<Node>;
  34187. /**
  34188. * Gets a node (Mesh, Camera, Light) using a given name
  34189. * @param name defines the name to search for
  34190. * @return the found node or null if not found at all.
  34191. */
  34192. getNodeByName(name: string): Nullable<Node>;
  34193. /**
  34194. * Gets a mesh using a given name
  34195. * @param name defines the name to search for
  34196. * @return the found mesh or null if not found at all.
  34197. */
  34198. getMeshByName(name: string): Nullable<AbstractMesh>;
  34199. /**
  34200. * Gets a transform node using a given name
  34201. * @param name defines the name to search for
  34202. * @return the found transform node or null if not found at all.
  34203. */
  34204. getTransformNodeByName(name: string): Nullable<TransformNode>;
  34205. /**
  34206. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  34207. * @param id defines the id to search for
  34208. * @return the found skeleton or null if not found at all.
  34209. */
  34210. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  34211. /**
  34212. * Gets a skeleton using a given auto generated unique id
  34213. * @param uniqueId defines the unique id to search for
  34214. * @return the found skeleton or null if not found at all.
  34215. */
  34216. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  34217. /**
  34218. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  34219. * @param id defines the id to search for
  34220. * @return the found skeleton or null if not found at all.
  34221. */
  34222. getSkeletonById(id: string): Nullable<Skeleton>;
  34223. /**
  34224. * Gets a skeleton using a given name
  34225. * @param name defines the name to search for
  34226. * @return the found skeleton or null if not found at all.
  34227. */
  34228. getSkeletonByName(name: string): Nullable<Skeleton>;
  34229. /**
  34230. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  34231. * @param id defines the id to search for
  34232. * @return the found morph target manager or null if not found at all.
  34233. */
  34234. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  34235. /**
  34236. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  34237. * @param id defines the id to search for
  34238. * @return the found morph target or null if not found at all.
  34239. */
  34240. getMorphTargetById(id: string): Nullable<MorphTarget>;
  34241. /**
  34242. * Gets a boolean indicating if the given mesh is active
  34243. * @param mesh defines the mesh to look for
  34244. * @returns true if the mesh is in the active list
  34245. */
  34246. isActiveMesh(mesh: AbstractMesh): boolean;
  34247. /**
  34248. * Return a unique id as a string which can serve as an identifier for the scene
  34249. */
  34250. readonly uid: string;
  34251. /**
  34252. * Add an externaly attached data from its key.
  34253. * This method call will fail and return false, if such key already exists.
  34254. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  34255. * @param key the unique key that identifies the data
  34256. * @param data the data object to associate to the key for this Engine instance
  34257. * @return true if no such key were already present and the data was added successfully, false otherwise
  34258. */
  34259. addExternalData<T>(key: string, data: T): boolean;
  34260. /**
  34261. * Get an externaly attached data from its key
  34262. * @param key the unique key that identifies the data
  34263. * @return the associated data, if present (can be null), or undefined if not present
  34264. */
  34265. getExternalData<T>(key: string): Nullable<T>;
  34266. /**
  34267. * Get an externaly attached data from its key, create it using a factory if it's not already present
  34268. * @param key the unique key that identifies the data
  34269. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  34270. * @return the associated data, can be null if the factory returned null.
  34271. */
  34272. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  34273. /**
  34274. * Remove an externaly attached data from the Engine instance
  34275. * @param key the unique key that identifies the data
  34276. * @return true if the data was successfully removed, false if it doesn't exist
  34277. */
  34278. removeExternalData(key: string): boolean;
  34279. private _evaluateSubMesh;
  34280. /**
  34281. * Clear the processed materials smart array preventing retention point in material dispose.
  34282. */
  34283. freeProcessedMaterials(): void;
  34284. private _preventFreeActiveMeshesAndRenderingGroups;
  34285. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  34286. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  34287. * when disposing several meshes in a row or a hierarchy of meshes.
  34288. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  34289. */
  34290. blockfreeActiveMeshesAndRenderingGroups: boolean;
  34291. /**
  34292. * Clear the active meshes smart array preventing retention point in mesh dispose.
  34293. */
  34294. freeActiveMeshes(): void;
  34295. /**
  34296. * Clear the info related to rendering groups preventing retention points during dispose.
  34297. */
  34298. freeRenderingGroups(): void;
  34299. /** @hidden */
  34300. _isInIntermediateRendering(): boolean;
  34301. /**
  34302. * Lambda returning the list of potentially active meshes.
  34303. */
  34304. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  34305. /**
  34306. * Lambda returning the list of potentially active sub meshes.
  34307. */
  34308. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  34309. /**
  34310. * Lambda returning the list of potentially intersecting sub meshes.
  34311. */
  34312. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  34313. /**
  34314. * Lambda returning the list of potentially colliding sub meshes.
  34315. */
  34316. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  34317. private _activeMeshesFrozen;
  34318. /**
  34319. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  34320. * @returns the current scene
  34321. */
  34322. freezeActiveMeshes(): Scene;
  34323. /**
  34324. * Use this function to restart evaluating active meshes on every frame
  34325. * @returns the current scene
  34326. */
  34327. unfreezeActiveMeshes(): Scene;
  34328. private _evaluateActiveMeshes;
  34329. private _activeMesh;
  34330. /**
  34331. * Update the transform matrix to update from the current active camera
  34332. * @param force defines a boolean used to force the update even if cache is up to date
  34333. */
  34334. updateTransformMatrix(force?: boolean): void;
  34335. private _bindFrameBuffer;
  34336. /** @hidden */
  34337. _allowPostProcessClearColor: boolean;
  34338. /** @hidden */
  34339. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  34340. private _processSubCameras;
  34341. private _checkIntersections;
  34342. /** @hidden */
  34343. _advancePhysicsEngineStep(step: number): void;
  34344. /**
  34345. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  34346. */
  34347. getDeterministicFrameTime: () => number;
  34348. /** @hidden */
  34349. _animate(): void;
  34350. /** Execute all animations (for a frame) */
  34351. animate(): void;
  34352. /**
  34353. * Render the scene
  34354. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  34355. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  34356. */
  34357. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  34358. /**
  34359. * Freeze all materials
  34360. * A frozen material will not be updatable but should be faster to render
  34361. */
  34362. freezeMaterials(): void;
  34363. /**
  34364. * Unfreeze all materials
  34365. * A frozen material will not be updatable but should be faster to render
  34366. */
  34367. unfreezeMaterials(): void;
  34368. /**
  34369. * Releases all held ressources
  34370. */
  34371. dispose(): void;
  34372. /**
  34373. * Gets if the scene is already disposed
  34374. */
  34375. readonly isDisposed: boolean;
  34376. /**
  34377. * Call this function to reduce memory footprint of the scene.
  34378. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  34379. */
  34380. clearCachedVertexData(): void;
  34381. /**
  34382. * This function will remove the local cached buffer data from texture.
  34383. * It will save memory but will prevent the texture from being rebuilt
  34384. */
  34385. cleanCachedTextureBuffer(): void;
  34386. /**
  34387. * Get the world extend vectors with an optional filter
  34388. *
  34389. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  34390. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  34391. */
  34392. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  34393. min: Vector3;
  34394. max: Vector3;
  34395. };
  34396. /**
  34397. * Creates a ray that can be used to pick in the scene
  34398. * @param x defines the x coordinate of the origin (on-screen)
  34399. * @param y defines the y coordinate of the origin (on-screen)
  34400. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34401. * @param camera defines the camera to use for the picking
  34402. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34403. * @returns a Ray
  34404. */
  34405. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  34406. /**
  34407. * Creates a ray that can be used to pick in the scene
  34408. * @param x defines the x coordinate of the origin (on-screen)
  34409. * @param y defines the y coordinate of the origin (on-screen)
  34410. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34411. * @param result defines the ray where to store the picking ray
  34412. * @param camera defines the camera to use for the picking
  34413. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34414. * @returns the current scene
  34415. */
  34416. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  34417. /**
  34418. * Creates a ray that can be used to pick in the scene
  34419. * @param x defines the x coordinate of the origin (on-screen)
  34420. * @param y defines the y coordinate of the origin (on-screen)
  34421. * @param camera defines the camera to use for the picking
  34422. * @returns a Ray
  34423. */
  34424. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  34425. /**
  34426. * Creates a ray that can be used to pick in the scene
  34427. * @param x defines the x coordinate of the origin (on-screen)
  34428. * @param y defines the y coordinate of the origin (on-screen)
  34429. * @param result defines the ray where to store the picking ray
  34430. * @param camera defines the camera to use for the picking
  34431. * @returns the current scene
  34432. */
  34433. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  34434. /** Launch a ray to try to pick a mesh in the scene
  34435. * @param x position on screen
  34436. * @param y position on screen
  34437. * @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
  34438. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  34439. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34440. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34441. * @returns a PickingInfo
  34442. */
  34443. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  34444. /** Use the given ray to pick a mesh in the scene
  34445. * @param ray The ray to use to pick meshes
  34446. * @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
  34447. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  34448. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34449. * @returns a PickingInfo
  34450. */
  34451. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34452. /**
  34453. * Launch a ray to try to pick a mesh in the scene
  34454. * @param x X position on screen
  34455. * @param y Y position on screen
  34456. * @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
  34457. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34458. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34459. * @returns an array of PickingInfo
  34460. */
  34461. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34462. /**
  34463. * Launch a ray to try to pick a mesh in the scene
  34464. * @param ray Ray to use
  34465. * @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
  34466. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34467. * @returns an array of PickingInfo
  34468. */
  34469. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34470. /**
  34471. * Force the value of meshUnderPointer
  34472. * @param mesh defines the mesh to use
  34473. */
  34474. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34475. /**
  34476. * Gets the mesh under the pointer
  34477. * @returns a Mesh or null if no mesh is under the pointer
  34478. */
  34479. getPointerOverMesh(): Nullable<AbstractMesh>;
  34480. /** @hidden */
  34481. _rebuildGeometries(): void;
  34482. /** @hidden */
  34483. _rebuildTextures(): void;
  34484. private _getByTags;
  34485. /**
  34486. * Get a list of meshes by tags
  34487. * @param tagsQuery defines the tags query to use
  34488. * @param forEach defines a predicate used to filter results
  34489. * @returns an array of Mesh
  34490. */
  34491. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  34492. /**
  34493. * Get a list of cameras by tags
  34494. * @param tagsQuery defines the tags query to use
  34495. * @param forEach defines a predicate used to filter results
  34496. * @returns an array of Camera
  34497. */
  34498. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  34499. /**
  34500. * Get a list of lights by tags
  34501. * @param tagsQuery defines the tags query to use
  34502. * @param forEach defines a predicate used to filter results
  34503. * @returns an array of Light
  34504. */
  34505. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  34506. /**
  34507. * Get a list of materials by tags
  34508. * @param tagsQuery defines the tags query to use
  34509. * @param forEach defines a predicate used to filter results
  34510. * @returns an array of Material
  34511. */
  34512. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  34513. /**
  34514. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  34515. * This allowed control for front to back rendering or reversly depending of the special needs.
  34516. *
  34517. * @param renderingGroupId The rendering group id corresponding to its index
  34518. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  34519. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  34520. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  34521. */
  34522. 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;
  34523. /**
  34524. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  34525. *
  34526. * @param renderingGroupId The rendering group id corresponding to its index
  34527. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34528. * @param depth Automatically clears depth between groups if true and autoClear is true.
  34529. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  34530. */
  34531. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  34532. /**
  34533. * Gets the current auto clear configuration for one rendering group of the rendering
  34534. * manager.
  34535. * @param index the rendering group index to get the information for
  34536. * @returns The auto clear setup for the requested rendering group
  34537. */
  34538. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  34539. private _blockMaterialDirtyMechanism;
  34540. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  34541. blockMaterialDirtyMechanism: boolean;
  34542. /**
  34543. * Will flag all materials as dirty to trigger new shader compilation
  34544. * @param flag defines the flag used to specify which material part must be marked as dirty
  34545. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  34546. */
  34547. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34548. /** @hidden */
  34549. _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;
  34550. /** @hidden */
  34551. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34552. }
  34553. }
  34554. declare module "babylonjs/assetContainer" {
  34555. import { AbstractScene } from "babylonjs/abstractScene";
  34556. import { Scene } from "babylonjs/scene";
  34557. import { Mesh } from "babylonjs/Meshes/mesh";
  34558. /**
  34559. * Set of assets to keep when moving a scene into an asset container.
  34560. */
  34561. export class KeepAssets extends AbstractScene {
  34562. }
  34563. /**
  34564. * Container with a set of assets that can be added or removed from a scene.
  34565. */
  34566. export class AssetContainer extends AbstractScene {
  34567. /**
  34568. * The scene the AssetContainer belongs to.
  34569. */
  34570. scene: Scene;
  34571. /**
  34572. * Instantiates an AssetContainer.
  34573. * @param scene The scene the AssetContainer belongs to.
  34574. */
  34575. constructor(scene: Scene);
  34576. /**
  34577. * Adds all the assets from the container to the scene.
  34578. */
  34579. addAllToScene(): void;
  34580. /**
  34581. * Removes all the assets in the container from the scene
  34582. */
  34583. removeAllFromScene(): void;
  34584. /**
  34585. * Disposes all the assets in the container
  34586. */
  34587. dispose(): void;
  34588. private _moveAssets;
  34589. /**
  34590. * Removes all the assets contained in the scene and adds them to the container.
  34591. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  34592. */
  34593. moveAllFromScene(keepAssets?: KeepAssets): void;
  34594. /**
  34595. * 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.
  34596. * @returns the root mesh
  34597. */
  34598. createRootMesh(): Mesh;
  34599. }
  34600. }
  34601. declare module "babylonjs/abstractScene" {
  34602. import { Scene } from "babylonjs/scene";
  34603. import { Nullable } from "babylonjs/types";
  34604. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34605. import { TransformNode } from "babylonjs/Meshes/transformNode";
  34606. import { Geometry } from "babylonjs/Meshes/geometry";
  34607. import { Skeleton } from "babylonjs/Bones/skeleton";
  34608. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  34609. import { AssetContainer } from "babylonjs/assetContainer";
  34610. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  34611. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  34612. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  34613. import { Material } from "babylonjs/Materials/material";
  34614. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  34615. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  34616. import { Camera } from "babylonjs/Cameras/camera";
  34617. import { Light } from "babylonjs/Lights/light";
  34618. import { Node } from "babylonjs/node";
  34619. import { Animation } from "babylonjs/Animations/animation";
  34620. /**
  34621. * Defines how the parser contract is defined.
  34622. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  34623. */
  34624. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  34625. /**
  34626. * Defines how the individual parser contract is defined.
  34627. * These parser can parse an individual asset
  34628. */
  34629. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  34630. /**
  34631. * Base class of the scene acting as a container for the different elements composing a scene.
  34632. * This class is dynamically extended by the different components of the scene increasing
  34633. * flexibility and reducing coupling
  34634. */
  34635. export abstract class AbstractScene {
  34636. /**
  34637. * Stores the list of available parsers in the application.
  34638. */
  34639. private static _BabylonFileParsers;
  34640. /**
  34641. * Stores the list of available individual parsers in the application.
  34642. */
  34643. private static _IndividualBabylonFileParsers;
  34644. /**
  34645. * Adds a parser in the list of available ones
  34646. * @param name Defines the name of the parser
  34647. * @param parser Defines the parser to add
  34648. */
  34649. static AddParser(name: string, parser: BabylonFileParser): void;
  34650. /**
  34651. * Gets a general parser from the list of avaialble ones
  34652. * @param name Defines the name of the parser
  34653. * @returns the requested parser or null
  34654. */
  34655. static GetParser(name: string): Nullable<BabylonFileParser>;
  34656. /**
  34657. * Adds n individual parser in the list of available ones
  34658. * @param name Defines the name of the parser
  34659. * @param parser Defines the parser to add
  34660. */
  34661. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  34662. /**
  34663. * Gets an individual parser from the list of avaialble ones
  34664. * @param name Defines the name of the parser
  34665. * @returns the requested parser or null
  34666. */
  34667. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  34668. /**
  34669. * Parser json data and populate both a scene and its associated container object
  34670. * @param jsonData Defines the data to parse
  34671. * @param scene Defines the scene to parse the data for
  34672. * @param container Defines the container attached to the parsing sequence
  34673. * @param rootUrl Defines the root url of the data
  34674. */
  34675. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  34676. /**
  34677. * Gets the list of root nodes (ie. nodes with no parent)
  34678. */
  34679. rootNodes: Node[];
  34680. /** All of the cameras added to this scene
  34681. * @see http://doc.babylonjs.com/babylon101/cameras
  34682. */
  34683. cameras: Camera[];
  34684. /**
  34685. * All of the lights added to this scene
  34686. * @see http://doc.babylonjs.com/babylon101/lights
  34687. */
  34688. lights: Light[];
  34689. /**
  34690. * All of the (abstract) meshes added to this scene
  34691. */
  34692. meshes: AbstractMesh[];
  34693. /**
  34694. * The list of skeletons added to the scene
  34695. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  34696. */
  34697. skeletons: Skeleton[];
  34698. /**
  34699. * All of the particle systems added to this scene
  34700. * @see http://doc.babylonjs.com/babylon101/particles
  34701. */
  34702. particleSystems: IParticleSystem[];
  34703. /**
  34704. * Gets a list of Animations associated with the scene
  34705. */
  34706. animations: Animation[];
  34707. /**
  34708. * All of the animation groups added to this scene
  34709. * @see http://doc.babylonjs.com/how_to/group
  34710. */
  34711. animationGroups: AnimationGroup[];
  34712. /**
  34713. * All of the multi-materials added to this scene
  34714. * @see http://doc.babylonjs.com/how_to/multi_materials
  34715. */
  34716. multiMaterials: MultiMaterial[];
  34717. /**
  34718. * All of the materials added to this scene
  34719. * In the context of a Scene, it is not supposed to be modified manually.
  34720. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  34721. * Note also that the order of the Material wihin the array is not significant and might change.
  34722. * @see http://doc.babylonjs.com/babylon101/materials
  34723. */
  34724. materials: Material[];
  34725. /**
  34726. * The list of morph target managers added to the scene
  34727. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  34728. */
  34729. morphTargetManagers: MorphTargetManager[];
  34730. /**
  34731. * The list of geometries used in the scene.
  34732. */
  34733. geometries: Geometry[];
  34734. /**
  34735. * All of the tranform nodes added to this scene
  34736. * In the context of a Scene, it is not supposed to be modified manually.
  34737. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  34738. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  34739. * @see http://doc.babylonjs.com/how_to/transformnode
  34740. */
  34741. transformNodes: TransformNode[];
  34742. /**
  34743. * ActionManagers available on the scene.
  34744. */
  34745. actionManagers: AbstractActionManager[];
  34746. /**
  34747. * Textures to keep.
  34748. */
  34749. textures: BaseTexture[];
  34750. /**
  34751. * Environment texture for the scene
  34752. */
  34753. environmentTexture: Nullable<BaseTexture>;
  34754. }
  34755. }
  34756. declare module "babylonjs/Audio/sound" {
  34757. import { Observable } from "babylonjs/Misc/observable";
  34758. import { Vector3 } from "babylonjs/Maths/math";
  34759. import { Nullable } from "babylonjs/types";
  34760. import { Scene } from "babylonjs/scene";
  34761. import { TransformNode } from "babylonjs/Meshes/transformNode";
  34762. /**
  34763. * Defines a sound that can be played in the application.
  34764. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  34765. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34766. */
  34767. export class Sound {
  34768. /**
  34769. * The name of the sound in the scene.
  34770. */
  34771. name: string;
  34772. /**
  34773. * Does the sound autoplay once loaded.
  34774. */
  34775. autoplay: boolean;
  34776. /**
  34777. * Does the sound loop after it finishes playing once.
  34778. */
  34779. loop: boolean;
  34780. /**
  34781. * Does the sound use a custom attenuation curve to simulate the falloff
  34782. * happening when the source gets further away from the camera.
  34783. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34784. */
  34785. useCustomAttenuation: boolean;
  34786. /**
  34787. * The sound track id this sound belongs to.
  34788. */
  34789. soundTrackId: number;
  34790. /**
  34791. * Is this sound currently played.
  34792. */
  34793. isPlaying: boolean;
  34794. /**
  34795. * Is this sound currently paused.
  34796. */
  34797. isPaused: boolean;
  34798. /**
  34799. * Does this sound enables spatial sound.
  34800. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34801. */
  34802. spatialSound: boolean;
  34803. /**
  34804. * Define the reference distance the sound should be heard perfectly.
  34805. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34806. */
  34807. refDistance: number;
  34808. /**
  34809. * Define the roll off factor of spatial sounds.
  34810. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34811. */
  34812. rolloffFactor: number;
  34813. /**
  34814. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  34815. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34816. */
  34817. maxDistance: number;
  34818. /**
  34819. * Define the distance attenuation model the sound will follow.
  34820. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34821. */
  34822. distanceModel: string;
  34823. /**
  34824. * @hidden
  34825. * Back Compat
  34826. **/
  34827. onended: () => any;
  34828. /**
  34829. * Observable event when the current playing sound finishes.
  34830. */
  34831. onEndedObservable: Observable<Sound>;
  34832. private _panningModel;
  34833. private _playbackRate;
  34834. private _streaming;
  34835. private _startTime;
  34836. private _startOffset;
  34837. private _position;
  34838. /** @hidden */
  34839. _positionInEmitterSpace: boolean;
  34840. private _localDirection;
  34841. private _volume;
  34842. private _isReadyToPlay;
  34843. private _isDirectional;
  34844. private _readyToPlayCallback;
  34845. private _audioBuffer;
  34846. private _soundSource;
  34847. private _streamingSource;
  34848. private _soundPanner;
  34849. private _soundGain;
  34850. private _inputAudioNode;
  34851. private _outputAudioNode;
  34852. private _coneInnerAngle;
  34853. private _coneOuterAngle;
  34854. private _coneOuterGain;
  34855. private _scene;
  34856. private _connectedTransformNode;
  34857. private _customAttenuationFunction;
  34858. private _registerFunc;
  34859. private _isOutputConnected;
  34860. private _htmlAudioElement;
  34861. private _urlType;
  34862. /** @hidden */
  34863. static _SceneComponentInitialization: (scene: Scene) => void;
  34864. /**
  34865. * Create a sound and attach it to a scene
  34866. * @param name Name of your sound
  34867. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  34868. * @param scene defines the scene the sound belongs to
  34869. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  34870. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  34871. */
  34872. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  34873. /**
  34874. * Release the sound and its associated resources
  34875. */
  34876. dispose(): void;
  34877. /**
  34878. * Gets if the sounds is ready to be played or not.
  34879. * @returns true if ready, otherwise false
  34880. */
  34881. isReady(): boolean;
  34882. private _soundLoaded;
  34883. /**
  34884. * Sets the data of the sound from an audiobuffer
  34885. * @param audioBuffer The audioBuffer containing the data
  34886. */
  34887. setAudioBuffer(audioBuffer: AudioBuffer): void;
  34888. /**
  34889. * Updates the current sounds options such as maxdistance, loop...
  34890. * @param options A JSON object containing values named as the object properties
  34891. */
  34892. updateOptions(options: any): void;
  34893. private _createSpatialParameters;
  34894. private _updateSpatialParameters;
  34895. /**
  34896. * Switch the panning model to HRTF:
  34897. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34898. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34899. */
  34900. switchPanningModelToHRTF(): void;
  34901. /**
  34902. * Switch the panning model to Equal Power:
  34903. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34904. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34905. */
  34906. switchPanningModelToEqualPower(): void;
  34907. private _switchPanningModel;
  34908. /**
  34909. * Connect this sound to a sound track audio node like gain...
  34910. * @param soundTrackAudioNode the sound track audio node to connect to
  34911. */
  34912. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  34913. /**
  34914. * Transform this sound into a directional source
  34915. * @param coneInnerAngle Size of the inner cone in degree
  34916. * @param coneOuterAngle Size of the outer cone in degree
  34917. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  34918. */
  34919. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  34920. /**
  34921. * Gets or sets the inner angle for the directional cone.
  34922. */
  34923. /**
  34924. * Gets or sets the inner angle for the directional cone.
  34925. */
  34926. directionalConeInnerAngle: number;
  34927. /**
  34928. * Gets or sets the outer angle for the directional cone.
  34929. */
  34930. /**
  34931. * Gets or sets the outer angle for the directional cone.
  34932. */
  34933. directionalConeOuterAngle: number;
  34934. /**
  34935. * Sets the position of the emitter if spatial sound is enabled
  34936. * @param newPosition Defines the new posisiton
  34937. */
  34938. setPosition(newPosition: Vector3): void;
  34939. /**
  34940. * Sets the local direction of the emitter if spatial sound is enabled
  34941. * @param newLocalDirection Defines the new local direction
  34942. */
  34943. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  34944. private _updateDirection;
  34945. /** @hidden */
  34946. updateDistanceFromListener(): void;
  34947. /**
  34948. * Sets a new custom attenuation function for the sound.
  34949. * @param callback Defines the function used for the attenuation
  34950. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34951. */
  34952. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  34953. /**
  34954. * Play the sound
  34955. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  34956. * @param offset (optional) Start the sound setting it at a specific time
  34957. */
  34958. play(time?: number, offset?: number): void;
  34959. private _onended;
  34960. /**
  34961. * Stop the sound
  34962. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  34963. */
  34964. stop(time?: number): void;
  34965. /**
  34966. * Put the sound in pause
  34967. */
  34968. pause(): void;
  34969. /**
  34970. * Sets a dedicated volume for this sounds
  34971. * @param newVolume Define the new volume of the sound
  34972. * @param time Define in how long the sound should be at this value
  34973. */
  34974. setVolume(newVolume: number, time?: number): void;
  34975. /**
  34976. * Set the sound play back rate
  34977. * @param newPlaybackRate Define the playback rate the sound should be played at
  34978. */
  34979. setPlaybackRate(newPlaybackRate: number): void;
  34980. /**
  34981. * Gets the volume of the sound.
  34982. * @returns the volume of the sound
  34983. */
  34984. getVolume(): number;
  34985. /**
  34986. * Attach the sound to a dedicated mesh
  34987. * @param transformNode The transform node to connect the sound with
  34988. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34989. */
  34990. attachToMesh(transformNode: TransformNode): void;
  34991. /**
  34992. * Detach the sound from the previously attached mesh
  34993. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34994. */
  34995. detachFromMesh(): void;
  34996. private _onRegisterAfterWorldMatrixUpdate;
  34997. /**
  34998. * Clone the current sound in the scene.
  34999. * @returns the new sound clone
  35000. */
  35001. clone(): Nullable<Sound>;
  35002. /**
  35003. * Gets the current underlying audio buffer containing the data
  35004. * @returns the audio buffer
  35005. */
  35006. getAudioBuffer(): Nullable<AudioBuffer>;
  35007. /**
  35008. * Serializes the Sound in a JSON representation
  35009. * @returns the JSON representation of the sound
  35010. */
  35011. serialize(): any;
  35012. /**
  35013. * Parse a JSON representation of a sound to innstantiate in a given scene
  35014. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  35015. * @param scene Define the scene the new parsed sound should be created in
  35016. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  35017. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  35018. * @returns the newly parsed sound
  35019. */
  35020. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  35021. }
  35022. }
  35023. declare module "babylonjs/Actions/directAudioActions" {
  35024. import { Action } from "babylonjs/Actions/action";
  35025. import { Condition } from "babylonjs/Actions/condition";
  35026. import { Sound } from "babylonjs/Audio/sound";
  35027. /**
  35028. * This defines an action helpful to play a defined sound on a triggered action.
  35029. */
  35030. export class PlaySoundAction extends Action {
  35031. private _sound;
  35032. /**
  35033. * Instantiate the action
  35034. * @param triggerOptions defines the trigger options
  35035. * @param sound defines the sound to play
  35036. * @param condition defines the trigger related conditions
  35037. */
  35038. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35039. /** @hidden */
  35040. _prepare(): void;
  35041. /**
  35042. * Execute the action and play the sound.
  35043. */
  35044. execute(): void;
  35045. /**
  35046. * Serializes the actions and its related information.
  35047. * @param parent defines the object to serialize in
  35048. * @returns the serialized object
  35049. */
  35050. serialize(parent: any): any;
  35051. }
  35052. /**
  35053. * This defines an action helpful to stop a defined sound on a triggered action.
  35054. */
  35055. export class StopSoundAction extends Action {
  35056. private _sound;
  35057. /**
  35058. * Instantiate the action
  35059. * @param triggerOptions defines the trigger options
  35060. * @param sound defines the sound to stop
  35061. * @param condition defines the trigger related conditions
  35062. */
  35063. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35064. /** @hidden */
  35065. _prepare(): void;
  35066. /**
  35067. * Execute the action and stop the sound.
  35068. */
  35069. execute(): void;
  35070. /**
  35071. * Serializes the actions and its related information.
  35072. * @param parent defines the object to serialize in
  35073. * @returns the serialized object
  35074. */
  35075. serialize(parent: any): any;
  35076. }
  35077. }
  35078. declare module "babylonjs/Actions/interpolateValueAction" {
  35079. import { Action } from "babylonjs/Actions/action";
  35080. import { Condition } from "babylonjs/Actions/condition";
  35081. import { Observable } from "babylonjs/Misc/observable";
  35082. /**
  35083. * This defines an action responsible to change the value of a property
  35084. * by interpolating between its current value and the newly set one once triggered.
  35085. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  35086. */
  35087. export class InterpolateValueAction extends Action {
  35088. /**
  35089. * Defines the path of the property where the value should be interpolated
  35090. */
  35091. propertyPath: string;
  35092. /**
  35093. * Defines the target value at the end of the interpolation.
  35094. */
  35095. value: any;
  35096. /**
  35097. * Defines the time it will take for the property to interpolate to the value.
  35098. */
  35099. duration: number;
  35100. /**
  35101. * Defines if the other scene animations should be stopped when the action has been triggered
  35102. */
  35103. stopOtherAnimations?: boolean;
  35104. /**
  35105. * Defines a callback raised once the interpolation animation has been done.
  35106. */
  35107. onInterpolationDone?: () => void;
  35108. /**
  35109. * Observable triggered once the interpolation animation has been done.
  35110. */
  35111. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  35112. private _target;
  35113. private _effectiveTarget;
  35114. private _property;
  35115. /**
  35116. * Instantiate the action
  35117. * @param triggerOptions defines the trigger options
  35118. * @param target defines the object containing the value to interpolate
  35119. * @param propertyPath defines the path to the property in the target object
  35120. * @param value defines the target value at the end of the interpolation
  35121. * @param duration deines the time it will take for the property to interpolate to the value.
  35122. * @param condition defines the trigger related conditions
  35123. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  35124. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  35125. */
  35126. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  35127. /** @hidden */
  35128. _prepare(): void;
  35129. /**
  35130. * Execute the action starts the value interpolation.
  35131. */
  35132. execute(): void;
  35133. /**
  35134. * Serializes the actions and its related information.
  35135. * @param parent defines the object to serialize in
  35136. * @returns the serialized object
  35137. */
  35138. serialize(parent: any): any;
  35139. }
  35140. }
  35141. declare module "babylonjs/Actions/index" {
  35142. export * from "babylonjs/Actions/action";
  35143. export * from "babylonjs/Actions/actionEvent";
  35144. export * from "babylonjs/Actions/actionManager";
  35145. export * from "babylonjs/Actions/condition";
  35146. export * from "babylonjs/Actions/directActions";
  35147. export * from "babylonjs/Actions/directAudioActions";
  35148. export * from "babylonjs/Actions/interpolateValueAction";
  35149. }
  35150. declare module "babylonjs/Animations/index" {
  35151. export * from "babylonjs/Animations/animatable";
  35152. export * from "babylonjs/Animations/animation";
  35153. export * from "babylonjs/Animations/animationGroup";
  35154. export * from "babylonjs/Animations/animationPropertiesOverride";
  35155. export * from "babylonjs/Animations/easing";
  35156. export * from "babylonjs/Animations/runtimeAnimation";
  35157. export * from "babylonjs/Animations/animationEvent";
  35158. export * from "babylonjs/Animations/animationGroup";
  35159. export * from "babylonjs/Animations/animationKey";
  35160. export * from "babylonjs/Animations/animationRange";
  35161. }
  35162. declare module "babylonjs/Audio/soundTrack" {
  35163. import { Sound } from "babylonjs/Audio/sound";
  35164. import { Analyser } from "babylonjs/Audio/analyser";
  35165. import { Scene } from "babylonjs/scene";
  35166. /**
  35167. * Options allowed during the creation of a sound track.
  35168. */
  35169. export interface ISoundTrackOptions {
  35170. /**
  35171. * The volume the sound track should take during creation
  35172. */
  35173. volume?: number;
  35174. /**
  35175. * Define if the sound track is the main sound track of the scene
  35176. */
  35177. mainTrack?: boolean;
  35178. }
  35179. /**
  35180. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  35181. * It will be also used in a future release to apply effects on a specific track.
  35182. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35183. */
  35184. export class SoundTrack {
  35185. /**
  35186. * The unique identifier of the sound track in the scene.
  35187. */
  35188. id: number;
  35189. /**
  35190. * The list of sounds included in the sound track.
  35191. */
  35192. soundCollection: Array<Sound>;
  35193. private _outputAudioNode;
  35194. private _scene;
  35195. private _isMainTrack;
  35196. private _connectedAnalyser;
  35197. private _options;
  35198. private _isInitialized;
  35199. /**
  35200. * Creates a new sound track.
  35201. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35202. * @param scene Define the scene the sound track belongs to
  35203. * @param options
  35204. */
  35205. constructor(scene: Scene, options?: ISoundTrackOptions);
  35206. private _initializeSoundTrackAudioGraph;
  35207. /**
  35208. * Release the sound track and its associated resources
  35209. */
  35210. dispose(): void;
  35211. /**
  35212. * Adds a sound to this sound track
  35213. * @param sound define the cound to add
  35214. * @ignoreNaming
  35215. */
  35216. AddSound(sound: Sound): void;
  35217. /**
  35218. * Removes a sound to this sound track
  35219. * @param sound define the cound to remove
  35220. * @ignoreNaming
  35221. */
  35222. RemoveSound(sound: Sound): void;
  35223. /**
  35224. * Set a global volume for the full sound track.
  35225. * @param newVolume Define the new volume of the sound track
  35226. */
  35227. setVolume(newVolume: number): void;
  35228. /**
  35229. * Switch the panning model to HRTF:
  35230. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35231. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35232. */
  35233. switchPanningModelToHRTF(): void;
  35234. /**
  35235. * Switch the panning model to Equal Power:
  35236. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35237. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35238. */
  35239. switchPanningModelToEqualPower(): void;
  35240. /**
  35241. * Connect the sound track to an audio analyser allowing some amazing
  35242. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  35243. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  35244. * @param analyser The analyser to connect to the engine
  35245. */
  35246. connectToAnalyser(analyser: Analyser): void;
  35247. }
  35248. }
  35249. declare module "babylonjs/Audio/audioSceneComponent" {
  35250. import { Sound } from "babylonjs/Audio/sound";
  35251. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  35252. import { Nullable } from "babylonjs/types";
  35253. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  35254. import { Scene } from "babylonjs/scene";
  35255. import { AbstractScene } from "babylonjs/abstractScene";
  35256. module "babylonjs/abstractScene" {
  35257. interface AbstractScene {
  35258. /**
  35259. * The list of sounds used in the scene.
  35260. */
  35261. sounds: Nullable<Array<Sound>>;
  35262. }
  35263. }
  35264. module "babylonjs/scene" {
  35265. interface Scene {
  35266. /**
  35267. * @hidden
  35268. * Backing field
  35269. */
  35270. _mainSoundTrack: SoundTrack;
  35271. /**
  35272. * The main sound track played by the scene.
  35273. * It cotains your primary collection of sounds.
  35274. */
  35275. mainSoundTrack: SoundTrack;
  35276. /**
  35277. * The list of sound tracks added to the scene
  35278. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35279. */
  35280. soundTracks: Nullable<Array<SoundTrack>>;
  35281. /**
  35282. * Gets a sound using a given name
  35283. * @param name defines the name to search for
  35284. * @return the found sound or null if not found at all.
  35285. */
  35286. getSoundByName(name: string): Nullable<Sound>;
  35287. /**
  35288. * Gets or sets if audio support is enabled
  35289. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35290. */
  35291. audioEnabled: boolean;
  35292. /**
  35293. * Gets or sets if audio will be output to headphones
  35294. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35295. */
  35296. headphone: boolean;
  35297. }
  35298. }
  35299. /**
  35300. * Defines the sound scene component responsible to manage any sounds
  35301. * in a given scene.
  35302. */
  35303. export class AudioSceneComponent implements ISceneSerializableComponent {
  35304. /**
  35305. * The component name helpfull to identify the component in the list of scene components.
  35306. */
  35307. readonly name: string;
  35308. /**
  35309. * The scene the component belongs to.
  35310. */
  35311. scene: Scene;
  35312. private _audioEnabled;
  35313. /**
  35314. * Gets whether audio is enabled or not.
  35315. * Please use related enable/disable method to switch state.
  35316. */
  35317. readonly audioEnabled: boolean;
  35318. private _headphone;
  35319. /**
  35320. * Gets whether audio is outputing to headphone or not.
  35321. * Please use the according Switch methods to change output.
  35322. */
  35323. readonly headphone: boolean;
  35324. /**
  35325. * Creates a new instance of the component for the given scene
  35326. * @param scene Defines the scene to register the component in
  35327. */
  35328. constructor(scene: Scene);
  35329. /**
  35330. * Registers the component in a given scene
  35331. */
  35332. register(): void;
  35333. /**
  35334. * Rebuilds the elements related to this component in case of
  35335. * context lost for instance.
  35336. */
  35337. rebuild(): void;
  35338. /**
  35339. * Serializes the component data to the specified json object
  35340. * @param serializationObject The object to serialize to
  35341. */
  35342. serialize(serializationObject: any): void;
  35343. /**
  35344. * Adds all the element from the container to the scene
  35345. * @param container the container holding the elements
  35346. */
  35347. addFromContainer(container: AbstractScene): void;
  35348. /**
  35349. * Removes all the elements in the container from the scene
  35350. * @param container contains the elements to remove
  35351. * @param dispose if the removed element should be disposed (default: false)
  35352. */
  35353. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  35354. /**
  35355. * Disposes the component and the associated ressources.
  35356. */
  35357. dispose(): void;
  35358. /**
  35359. * Disables audio in the associated scene.
  35360. */
  35361. disableAudio(): void;
  35362. /**
  35363. * Enables audio in the associated scene.
  35364. */
  35365. enableAudio(): void;
  35366. /**
  35367. * Switch audio to headphone output.
  35368. */
  35369. switchAudioModeForHeadphones(): void;
  35370. /**
  35371. * Switch audio to normal speakers.
  35372. */
  35373. switchAudioModeForNormalSpeakers(): void;
  35374. private _afterRender;
  35375. }
  35376. }
  35377. declare module "babylonjs/Audio/weightedsound" {
  35378. import { Sound } from "babylonjs/Audio/sound";
  35379. /**
  35380. * Wraps one or more Sound objects and selects one with random weight for playback.
  35381. */
  35382. export class WeightedSound {
  35383. /** When true a Sound will be selected and played when the current playing Sound completes. */
  35384. loop: boolean;
  35385. private _coneInnerAngle;
  35386. private _coneOuterAngle;
  35387. private _volume;
  35388. /** A Sound is currently playing. */
  35389. isPlaying: boolean;
  35390. /** A Sound is currently paused. */
  35391. isPaused: boolean;
  35392. private _sounds;
  35393. private _weights;
  35394. private _currentIndex?;
  35395. /**
  35396. * Creates a new WeightedSound from the list of sounds given.
  35397. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  35398. * @param sounds Array of Sounds that will be selected from.
  35399. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  35400. */
  35401. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  35402. /**
  35403. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  35404. */
  35405. /**
  35406. * The size of cone in degress for a directional sound in which there will be no attenuation.
  35407. */
  35408. directionalConeInnerAngle: number;
  35409. /**
  35410. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35411. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35412. */
  35413. /**
  35414. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35415. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35416. */
  35417. directionalConeOuterAngle: number;
  35418. /**
  35419. * Playback volume.
  35420. */
  35421. /**
  35422. * Playback volume.
  35423. */
  35424. volume: number;
  35425. private _onended;
  35426. /**
  35427. * Suspend playback
  35428. */
  35429. pause(): void;
  35430. /**
  35431. * Stop playback
  35432. */
  35433. stop(): void;
  35434. /**
  35435. * Start playback.
  35436. * @param startOffset Position the clip head at a specific time in seconds.
  35437. */
  35438. play(startOffset?: number): void;
  35439. }
  35440. }
  35441. declare module "babylonjs/Audio/index" {
  35442. export * from "babylonjs/Audio/analyser";
  35443. export * from "babylonjs/Audio/audioEngine";
  35444. export * from "babylonjs/Audio/audioSceneComponent";
  35445. export * from "babylonjs/Audio/sound";
  35446. export * from "babylonjs/Audio/soundTrack";
  35447. export * from "babylonjs/Audio/weightedsound";
  35448. }
  35449. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  35450. import { Behavior } from "babylonjs/Behaviors/behavior";
  35451. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35452. import { BackEase } from "babylonjs/Animations/easing";
  35453. /**
  35454. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  35455. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35456. */
  35457. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  35458. /**
  35459. * Gets the name of the behavior.
  35460. */
  35461. readonly name: string;
  35462. /**
  35463. * The easing function used by animations
  35464. */
  35465. static EasingFunction: BackEase;
  35466. /**
  35467. * The easing mode used by animations
  35468. */
  35469. static EasingMode: number;
  35470. /**
  35471. * The duration of the animation, in milliseconds
  35472. */
  35473. transitionDuration: number;
  35474. /**
  35475. * Length of the distance animated by the transition when lower radius is reached
  35476. */
  35477. lowerRadiusTransitionRange: number;
  35478. /**
  35479. * Length of the distance animated by the transition when upper radius is reached
  35480. */
  35481. upperRadiusTransitionRange: number;
  35482. private _autoTransitionRange;
  35483. /**
  35484. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35485. */
  35486. /**
  35487. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35488. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  35489. */
  35490. autoTransitionRange: boolean;
  35491. private _attachedCamera;
  35492. private _onAfterCheckInputsObserver;
  35493. private _onMeshTargetChangedObserver;
  35494. /**
  35495. * Initializes the behavior.
  35496. */
  35497. init(): void;
  35498. /**
  35499. * Attaches the behavior to its arc rotate camera.
  35500. * @param camera Defines the camera to attach the behavior to
  35501. */
  35502. attach(camera: ArcRotateCamera): void;
  35503. /**
  35504. * Detaches the behavior from its current arc rotate camera.
  35505. */
  35506. detach(): void;
  35507. private _radiusIsAnimating;
  35508. private _radiusBounceTransition;
  35509. private _animatables;
  35510. private _cachedWheelPrecision;
  35511. /**
  35512. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  35513. * @param radiusLimit The limit to check against.
  35514. * @return Bool to indicate if at limit.
  35515. */
  35516. private _isRadiusAtLimit;
  35517. /**
  35518. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  35519. * @param radiusDelta The delta by which to animate to. Can be negative.
  35520. */
  35521. private _applyBoundRadiusAnimation;
  35522. /**
  35523. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  35524. */
  35525. protected _clearAnimationLocks(): void;
  35526. /**
  35527. * Stops and removes all animations that have been applied to the camera
  35528. */
  35529. stopAllAnimations(): void;
  35530. }
  35531. }
  35532. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  35533. import { Behavior } from "babylonjs/Behaviors/behavior";
  35534. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35535. import { ExponentialEase } from "babylonjs/Animations/easing";
  35536. import { Nullable } from "babylonjs/types";
  35537. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35538. import { Vector3 } from "babylonjs/Maths/math";
  35539. /**
  35540. * 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.
  35541. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35542. */
  35543. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  35544. /**
  35545. * Gets the name of the behavior.
  35546. */
  35547. readonly name: string;
  35548. private _mode;
  35549. private _radiusScale;
  35550. private _positionScale;
  35551. private _defaultElevation;
  35552. private _elevationReturnTime;
  35553. private _elevationReturnWaitTime;
  35554. private _zoomStopsAnimation;
  35555. private _framingTime;
  35556. /**
  35557. * The easing function used by animations
  35558. */
  35559. static EasingFunction: ExponentialEase;
  35560. /**
  35561. * The easing mode used by animations
  35562. */
  35563. static EasingMode: number;
  35564. /**
  35565. * Sets the current mode used by the behavior
  35566. */
  35567. /**
  35568. * Gets current mode used by the behavior.
  35569. */
  35570. mode: number;
  35571. /**
  35572. * Sets the scale applied to the radius (1 by default)
  35573. */
  35574. /**
  35575. * Gets the scale applied to the radius
  35576. */
  35577. radiusScale: number;
  35578. /**
  35579. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35580. */
  35581. /**
  35582. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35583. */
  35584. positionScale: number;
  35585. /**
  35586. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35587. * behaviour is triggered, in radians.
  35588. */
  35589. /**
  35590. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35591. * behaviour is triggered, in radians.
  35592. */
  35593. defaultElevation: number;
  35594. /**
  35595. * Sets the time (in milliseconds) taken to return to the default beta position.
  35596. * Negative value indicates camera should not return to default.
  35597. */
  35598. /**
  35599. * Gets the time (in milliseconds) taken to return to the default beta position.
  35600. * Negative value indicates camera should not return to default.
  35601. */
  35602. elevationReturnTime: number;
  35603. /**
  35604. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35605. */
  35606. /**
  35607. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35608. */
  35609. elevationReturnWaitTime: number;
  35610. /**
  35611. * Sets the flag that indicates if user zooming should stop animation.
  35612. */
  35613. /**
  35614. * Gets the flag that indicates if user zooming should stop animation.
  35615. */
  35616. zoomStopsAnimation: boolean;
  35617. /**
  35618. * Sets the transition time when framing the mesh, in milliseconds
  35619. */
  35620. /**
  35621. * Gets the transition time when framing the mesh, in milliseconds
  35622. */
  35623. framingTime: number;
  35624. /**
  35625. * Define if the behavior should automatically change the configured
  35626. * camera limits and sensibilities.
  35627. */
  35628. autoCorrectCameraLimitsAndSensibility: boolean;
  35629. private _onPrePointerObservableObserver;
  35630. private _onAfterCheckInputsObserver;
  35631. private _onMeshTargetChangedObserver;
  35632. private _attachedCamera;
  35633. private _isPointerDown;
  35634. private _lastInteractionTime;
  35635. /**
  35636. * Initializes the behavior.
  35637. */
  35638. init(): void;
  35639. /**
  35640. * Attaches the behavior to its arc rotate camera.
  35641. * @param camera Defines the camera to attach the behavior to
  35642. */
  35643. attach(camera: ArcRotateCamera): void;
  35644. /**
  35645. * Detaches the behavior from its current arc rotate camera.
  35646. */
  35647. detach(): void;
  35648. private _animatables;
  35649. private _betaIsAnimating;
  35650. private _betaTransition;
  35651. private _radiusTransition;
  35652. private _vectorTransition;
  35653. /**
  35654. * Targets the given mesh and updates zoom level accordingly.
  35655. * @param mesh The mesh to target.
  35656. * @param radius Optional. If a cached radius position already exists, overrides default.
  35657. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35658. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35659. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35660. */
  35661. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35662. /**
  35663. * Targets the given mesh with its children and updates zoom level accordingly.
  35664. * @param mesh The mesh to target.
  35665. * @param radius Optional. If a cached radius position already exists, overrides default.
  35666. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35667. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35668. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35669. */
  35670. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35671. /**
  35672. * Targets the given meshes with their children and updates zoom level accordingly.
  35673. * @param meshes The mesh to target.
  35674. * @param radius Optional. If a cached radius position already exists, overrides default.
  35675. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35676. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35677. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35678. */
  35679. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35680. /**
  35681. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  35682. * @param minimumWorld Determines the smaller position of the bounding box extend
  35683. * @param maximumWorld Determines the bigger position of the bounding box extend
  35684. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35685. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35686. */
  35687. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35688. /**
  35689. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  35690. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  35691. * frustum width.
  35692. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  35693. * to fully enclose the mesh in the viewing frustum.
  35694. */
  35695. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  35696. /**
  35697. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  35698. * is automatically returned to its default position (expected to be above ground plane).
  35699. */
  35700. private _maintainCameraAboveGround;
  35701. /**
  35702. * Returns the frustum slope based on the canvas ratio and camera FOV
  35703. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  35704. */
  35705. private _getFrustumSlope;
  35706. /**
  35707. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  35708. */
  35709. private _clearAnimationLocks;
  35710. /**
  35711. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35712. */
  35713. private _applyUserInteraction;
  35714. /**
  35715. * Stops and removes all animations that have been applied to the camera
  35716. */
  35717. stopAllAnimations(): void;
  35718. /**
  35719. * Gets a value indicating if the user is moving the camera
  35720. */
  35721. readonly isUserIsMoving: boolean;
  35722. /**
  35723. * The camera can move all the way towards the mesh.
  35724. */
  35725. static IgnoreBoundsSizeMode: number;
  35726. /**
  35727. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  35728. */
  35729. static FitFrustumSidesMode: number;
  35730. }
  35731. }
  35732. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  35733. import { Nullable } from "babylonjs/types";
  35734. import { Camera } from "babylonjs/Cameras/camera";
  35735. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35736. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  35737. /**
  35738. * Base class for Camera Pointer Inputs.
  35739. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  35740. * for example usage.
  35741. */
  35742. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  35743. /**
  35744. * Defines the camera the input is attached to.
  35745. */
  35746. abstract camera: Camera;
  35747. /**
  35748. * Whether keyboard modifier keys are pressed at time of last mouse event.
  35749. */
  35750. protected _altKey: boolean;
  35751. protected _ctrlKey: boolean;
  35752. protected _metaKey: boolean;
  35753. protected _shiftKey: boolean;
  35754. /**
  35755. * Which mouse buttons were pressed at time of last mouse event.
  35756. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  35757. */
  35758. protected _buttonsPressed: number;
  35759. /**
  35760. * Defines the buttons associated with the input to handle camera move.
  35761. */
  35762. buttons: number[];
  35763. /**
  35764. * Attach the input controls to a specific dom element to get the input from.
  35765. * @param element Defines the element the controls should be listened from
  35766. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35767. */
  35768. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35769. /**
  35770. * Detach the current controls from the specified dom element.
  35771. * @param element Defines the element to stop listening the inputs from
  35772. */
  35773. detachControl(element: Nullable<HTMLElement>): void;
  35774. /**
  35775. * Gets the class name of the current input.
  35776. * @returns the class name
  35777. */
  35778. getClassName(): string;
  35779. /**
  35780. * Get the friendly name associated with the input class.
  35781. * @returns the input friendly name
  35782. */
  35783. getSimpleName(): string;
  35784. /**
  35785. * Called on pointer POINTERDOUBLETAP event.
  35786. * Override this method to provide functionality on POINTERDOUBLETAP event.
  35787. */
  35788. protected onDoubleTap(type: string): void;
  35789. /**
  35790. * Called on pointer POINTERMOVE event if only a single touch is active.
  35791. * Override this method to provide functionality.
  35792. */
  35793. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35794. /**
  35795. * Called on pointer POINTERMOVE event if multiple touches are active.
  35796. * Override this method to provide functionality.
  35797. */
  35798. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35799. /**
  35800. * Called on JS contextmenu event.
  35801. * Override this method to provide functionality.
  35802. */
  35803. protected onContextMenu(evt: PointerEvent): void;
  35804. /**
  35805. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35806. * press.
  35807. * Override this method to provide functionality.
  35808. */
  35809. protected onButtonDown(evt: PointerEvent): void;
  35810. /**
  35811. * Called each time a new POINTERUP event occurs. Ie, for each button
  35812. * release.
  35813. * Override this method to provide functionality.
  35814. */
  35815. protected onButtonUp(evt: PointerEvent): void;
  35816. /**
  35817. * Called when window becomes inactive.
  35818. * Override this method to provide functionality.
  35819. */
  35820. protected onLostFocus(): void;
  35821. private _pointerInput;
  35822. private _observer;
  35823. private _onLostFocus;
  35824. private pointA;
  35825. private pointB;
  35826. }
  35827. }
  35828. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  35829. import { Nullable } from "babylonjs/types";
  35830. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35831. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  35832. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  35833. /**
  35834. * Manage the pointers inputs to control an arc rotate camera.
  35835. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35836. */
  35837. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  35838. /**
  35839. * Defines the camera the input is attached to.
  35840. */
  35841. camera: ArcRotateCamera;
  35842. /**
  35843. * Gets the class name of the current input.
  35844. * @returns the class name
  35845. */
  35846. getClassName(): string;
  35847. /**
  35848. * Defines the buttons associated with the input to handle camera move.
  35849. */
  35850. buttons: number[];
  35851. /**
  35852. * Defines the pointer angular sensibility along the X axis or how fast is
  35853. * the camera rotating.
  35854. */
  35855. angularSensibilityX: number;
  35856. /**
  35857. * Defines the pointer angular sensibility along the Y axis or how fast is
  35858. * the camera rotating.
  35859. */
  35860. angularSensibilityY: number;
  35861. /**
  35862. * Defines the pointer pinch precision or how fast is the camera zooming.
  35863. */
  35864. pinchPrecision: number;
  35865. /**
  35866. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  35867. * from 0.
  35868. * It defines the percentage of current camera.radius to use as delta when
  35869. * pinch zoom is used.
  35870. */
  35871. pinchDeltaPercentage: number;
  35872. /**
  35873. * Defines the pointer panning sensibility or how fast is the camera moving.
  35874. */
  35875. panningSensibility: number;
  35876. /**
  35877. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  35878. */
  35879. multiTouchPanning: boolean;
  35880. /**
  35881. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  35882. * zoom (pinch) through multitouch.
  35883. */
  35884. multiTouchPanAndZoom: boolean;
  35885. /**
  35886. * Revers pinch action direction.
  35887. */
  35888. pinchInwards: boolean;
  35889. private _isPanClick;
  35890. private _twoFingerActivityCount;
  35891. private _isPinching;
  35892. /**
  35893. * Called on pointer POINTERMOVE event if only a single touch is active.
  35894. */
  35895. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35896. /**
  35897. * Called on pointer POINTERDOUBLETAP event.
  35898. */
  35899. protected onDoubleTap(type: string): void;
  35900. /**
  35901. * Called on pointer POINTERMOVE event if multiple touches are active.
  35902. */
  35903. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35904. /**
  35905. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35906. * press.
  35907. */
  35908. protected onButtonDown(evt: PointerEvent): void;
  35909. /**
  35910. * Called each time a new POINTERUP event occurs. Ie, for each button
  35911. * release.
  35912. */
  35913. protected onButtonUp(evt: PointerEvent): void;
  35914. /**
  35915. * Called when window becomes inactive.
  35916. */
  35917. protected onLostFocus(): void;
  35918. }
  35919. }
  35920. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  35921. import { Nullable } from "babylonjs/types";
  35922. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35923. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35924. /**
  35925. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  35926. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35927. */
  35928. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  35929. /**
  35930. * Defines the camera the input is attached to.
  35931. */
  35932. camera: ArcRotateCamera;
  35933. /**
  35934. * Defines the list of key codes associated with the up action (increase alpha)
  35935. */
  35936. keysUp: number[];
  35937. /**
  35938. * Defines the list of key codes associated with the down action (decrease alpha)
  35939. */
  35940. keysDown: number[];
  35941. /**
  35942. * Defines the list of key codes associated with the left action (increase beta)
  35943. */
  35944. keysLeft: number[];
  35945. /**
  35946. * Defines the list of key codes associated with the right action (decrease beta)
  35947. */
  35948. keysRight: number[];
  35949. /**
  35950. * Defines the list of key codes associated with the reset action.
  35951. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  35952. */
  35953. keysReset: number[];
  35954. /**
  35955. * Defines the panning sensibility of the inputs.
  35956. * (How fast is the camera paning)
  35957. */
  35958. panningSensibility: number;
  35959. /**
  35960. * Defines the zooming sensibility of the inputs.
  35961. * (How fast is the camera zooming)
  35962. */
  35963. zoomingSensibility: number;
  35964. /**
  35965. * Defines wether maintaining the alt key down switch the movement mode from
  35966. * orientation to zoom.
  35967. */
  35968. useAltToZoom: boolean;
  35969. /**
  35970. * Rotation speed of the camera
  35971. */
  35972. angularSpeed: number;
  35973. private _keys;
  35974. private _ctrlPressed;
  35975. private _altPressed;
  35976. private _onCanvasBlurObserver;
  35977. private _onKeyboardObserver;
  35978. private _engine;
  35979. private _scene;
  35980. /**
  35981. * Attach the input controls to a specific dom element to get the input from.
  35982. * @param element Defines the element the controls should be listened from
  35983. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35984. */
  35985. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35986. /**
  35987. * Detach the current controls from the specified dom element.
  35988. * @param element Defines the element to stop listening the inputs from
  35989. */
  35990. detachControl(element: Nullable<HTMLElement>): void;
  35991. /**
  35992. * Update the current camera state depending on the inputs that have been used this frame.
  35993. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35994. */
  35995. checkInputs(): void;
  35996. /**
  35997. * Gets the class name of the current intput.
  35998. * @returns the class name
  35999. */
  36000. getClassName(): string;
  36001. /**
  36002. * Get the friendly name associated with the input class.
  36003. * @returns the input friendly name
  36004. */
  36005. getSimpleName(): string;
  36006. }
  36007. }
  36008. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  36009. import { Nullable } from "babylonjs/types";
  36010. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36011. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36012. /**
  36013. * Manage the mouse wheel inputs to control an arc rotate camera.
  36014. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36015. */
  36016. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  36017. /**
  36018. * Defines the camera the input is attached to.
  36019. */
  36020. camera: ArcRotateCamera;
  36021. /**
  36022. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36023. */
  36024. wheelPrecision: number;
  36025. /**
  36026. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36027. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36028. */
  36029. wheelDeltaPercentage: number;
  36030. private _wheel;
  36031. private _observer;
  36032. private computeDeltaFromMouseWheelLegacyEvent;
  36033. /**
  36034. * Attach the input controls to a specific dom element to get the input from.
  36035. * @param element Defines the element the controls should be listened from
  36036. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36037. */
  36038. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36039. /**
  36040. * Detach the current controls from the specified dom element.
  36041. * @param element Defines the element to stop listening the inputs from
  36042. */
  36043. detachControl(element: Nullable<HTMLElement>): void;
  36044. /**
  36045. * Gets the class name of the current intput.
  36046. * @returns the class name
  36047. */
  36048. getClassName(): string;
  36049. /**
  36050. * Get the friendly name associated with the input class.
  36051. * @returns the input friendly name
  36052. */
  36053. getSimpleName(): string;
  36054. }
  36055. }
  36056. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  36057. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36058. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  36059. /**
  36060. * Default Inputs manager for the ArcRotateCamera.
  36061. * It groups all the default supported inputs for ease of use.
  36062. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36063. */
  36064. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  36065. /**
  36066. * Instantiates a new ArcRotateCameraInputsManager.
  36067. * @param camera Defines the camera the inputs belong to
  36068. */
  36069. constructor(camera: ArcRotateCamera);
  36070. /**
  36071. * Add mouse wheel input support to the input manager.
  36072. * @returns the current input manager
  36073. */
  36074. addMouseWheel(): ArcRotateCameraInputsManager;
  36075. /**
  36076. * Add pointers input support to the input manager.
  36077. * @returns the current input manager
  36078. */
  36079. addPointers(): ArcRotateCameraInputsManager;
  36080. /**
  36081. * Add keyboard input support to the input manager.
  36082. * @returns the current input manager
  36083. */
  36084. addKeyboard(): ArcRotateCameraInputsManager;
  36085. }
  36086. }
  36087. declare module "babylonjs/Cameras/arcRotateCamera" {
  36088. import { Observable } from "babylonjs/Misc/observable";
  36089. import { Nullable } from "babylonjs/types";
  36090. import { Scene } from "babylonjs/scene";
  36091. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  36092. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36093. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  36094. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  36095. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  36096. import { Camera } from "babylonjs/Cameras/camera";
  36097. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  36098. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  36099. import { Collider } from "babylonjs/Collisions/collider";
  36100. /**
  36101. * This represents an orbital type of camera.
  36102. *
  36103. * 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.
  36104. * 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.
  36105. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  36106. */
  36107. export class ArcRotateCamera extends TargetCamera {
  36108. /**
  36109. * Defines the rotation angle of the camera along the longitudinal axis.
  36110. */
  36111. alpha: number;
  36112. /**
  36113. * Defines the rotation angle of the camera along the latitudinal axis.
  36114. */
  36115. beta: number;
  36116. /**
  36117. * Defines the radius of the camera from it s target point.
  36118. */
  36119. radius: number;
  36120. protected _target: Vector3;
  36121. protected _targetHost: Nullable<AbstractMesh>;
  36122. /**
  36123. * Defines the target point of the camera.
  36124. * The camera looks towards it form the radius distance.
  36125. */
  36126. target: Vector3;
  36127. /**
  36128. * Define the current local position of the camera in the scene
  36129. */
  36130. position: Vector3;
  36131. protected _upVector: Vector3;
  36132. protected _upToYMatrix: Matrix;
  36133. protected _YToUpMatrix: Matrix;
  36134. /**
  36135. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  36136. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  36137. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  36138. */
  36139. upVector: Vector3;
  36140. /**
  36141. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  36142. */
  36143. setMatUp(): void;
  36144. /**
  36145. * Current inertia value on the longitudinal axis.
  36146. * The bigger this number the longer it will take for the camera to stop.
  36147. */
  36148. inertialAlphaOffset: number;
  36149. /**
  36150. * Current inertia value on the latitudinal axis.
  36151. * The bigger this number the longer it will take for the camera to stop.
  36152. */
  36153. inertialBetaOffset: number;
  36154. /**
  36155. * Current inertia value on the radius axis.
  36156. * The bigger this number the longer it will take for the camera to stop.
  36157. */
  36158. inertialRadiusOffset: number;
  36159. /**
  36160. * Minimum allowed angle on the longitudinal axis.
  36161. * This can help limiting how the Camera is able to move in the scene.
  36162. */
  36163. lowerAlphaLimit: Nullable<number>;
  36164. /**
  36165. * Maximum allowed angle on the longitudinal axis.
  36166. * This can help limiting how the Camera is able to move in the scene.
  36167. */
  36168. upperAlphaLimit: Nullable<number>;
  36169. /**
  36170. * Minimum allowed angle on the latitudinal axis.
  36171. * This can help limiting how the Camera is able to move in the scene.
  36172. */
  36173. lowerBetaLimit: number;
  36174. /**
  36175. * Maximum allowed angle on the latitudinal axis.
  36176. * This can help limiting how the Camera is able to move in the scene.
  36177. */
  36178. upperBetaLimit: number;
  36179. /**
  36180. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  36181. * This can help limiting how the Camera is able to move in the scene.
  36182. */
  36183. lowerRadiusLimit: Nullable<number>;
  36184. /**
  36185. * Maximum allowed distance of the camera to the target (The camera can not get further).
  36186. * This can help limiting how the Camera is able to move in the scene.
  36187. */
  36188. upperRadiusLimit: Nullable<number>;
  36189. /**
  36190. * Defines the current inertia value used during panning of the camera along the X axis.
  36191. */
  36192. inertialPanningX: number;
  36193. /**
  36194. * Defines the current inertia value used during panning of the camera along the Y axis.
  36195. */
  36196. inertialPanningY: number;
  36197. /**
  36198. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  36199. * Basically if your fingers moves away from more than this distance you will be considered
  36200. * in pinch mode.
  36201. */
  36202. pinchToPanMaxDistance: number;
  36203. /**
  36204. * Defines the maximum distance the camera can pan.
  36205. * This could help keeping the cammera always in your scene.
  36206. */
  36207. panningDistanceLimit: Nullable<number>;
  36208. /**
  36209. * Defines the target of the camera before paning.
  36210. */
  36211. panningOriginTarget: Vector3;
  36212. /**
  36213. * Defines the value of the inertia used during panning.
  36214. * 0 would mean stop inertia and one would mean no decelleration at all.
  36215. */
  36216. panningInertia: number;
  36217. /**
  36218. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  36219. */
  36220. angularSensibilityX: number;
  36221. /**
  36222. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  36223. */
  36224. angularSensibilityY: number;
  36225. /**
  36226. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  36227. */
  36228. pinchPrecision: number;
  36229. /**
  36230. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  36231. * It will be used instead of pinchDeltaPrecision if different from 0.
  36232. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36233. */
  36234. pinchDeltaPercentage: number;
  36235. /**
  36236. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  36237. */
  36238. panningSensibility: number;
  36239. /**
  36240. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  36241. */
  36242. keysUp: number[];
  36243. /**
  36244. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  36245. */
  36246. keysDown: number[];
  36247. /**
  36248. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  36249. */
  36250. keysLeft: number[];
  36251. /**
  36252. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  36253. */
  36254. keysRight: number[];
  36255. /**
  36256. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36257. */
  36258. wheelPrecision: number;
  36259. /**
  36260. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  36261. * It will be used instead of pinchDeltaPrecision if different from 0.
  36262. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36263. */
  36264. wheelDeltaPercentage: number;
  36265. /**
  36266. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  36267. */
  36268. zoomOnFactor: number;
  36269. /**
  36270. * Defines a screen offset for the camera position.
  36271. */
  36272. targetScreenOffset: Vector2;
  36273. /**
  36274. * Allows the camera to be completely reversed.
  36275. * If false the camera can not arrive upside down.
  36276. */
  36277. allowUpsideDown: boolean;
  36278. /**
  36279. * Define if double tap/click is used to restore the previously saved state of the camera.
  36280. */
  36281. useInputToRestoreState: boolean;
  36282. /** @hidden */
  36283. _viewMatrix: Matrix;
  36284. /** @hidden */
  36285. _useCtrlForPanning: boolean;
  36286. /** @hidden */
  36287. _panningMouseButton: number;
  36288. /**
  36289. * Defines the input associated to the camera.
  36290. */
  36291. inputs: ArcRotateCameraInputsManager;
  36292. /** @hidden */
  36293. _reset: () => void;
  36294. /**
  36295. * Defines the allowed panning axis.
  36296. */
  36297. panningAxis: Vector3;
  36298. protected _localDirection: Vector3;
  36299. protected _transformedDirection: Vector3;
  36300. private _bouncingBehavior;
  36301. /**
  36302. * Gets the bouncing behavior of the camera if it has been enabled.
  36303. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36304. */
  36305. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  36306. /**
  36307. * Defines if the bouncing behavior of the camera is enabled on the camera.
  36308. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36309. */
  36310. useBouncingBehavior: boolean;
  36311. private _framingBehavior;
  36312. /**
  36313. * Gets the framing behavior of the camera if it has been enabled.
  36314. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36315. */
  36316. readonly framingBehavior: Nullable<FramingBehavior>;
  36317. /**
  36318. * Defines if the framing behavior of the camera is enabled on the camera.
  36319. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36320. */
  36321. useFramingBehavior: boolean;
  36322. private _autoRotationBehavior;
  36323. /**
  36324. * Gets the auto rotation behavior of the camera if it has been enabled.
  36325. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36326. */
  36327. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  36328. /**
  36329. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  36330. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36331. */
  36332. useAutoRotationBehavior: boolean;
  36333. /**
  36334. * Observable triggered when the mesh target has been changed on the camera.
  36335. */
  36336. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  36337. /**
  36338. * Event raised when the camera is colliding with a mesh.
  36339. */
  36340. onCollide: (collidedMesh: AbstractMesh) => void;
  36341. /**
  36342. * Defines whether the camera should check collision with the objects oh the scene.
  36343. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  36344. */
  36345. checkCollisions: boolean;
  36346. /**
  36347. * Defines the collision radius of the camera.
  36348. * This simulates a sphere around the camera.
  36349. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36350. */
  36351. collisionRadius: Vector3;
  36352. protected _collider: Collider;
  36353. protected _previousPosition: Vector3;
  36354. protected _collisionVelocity: Vector3;
  36355. protected _newPosition: Vector3;
  36356. protected _previousAlpha: number;
  36357. protected _previousBeta: number;
  36358. protected _previousRadius: number;
  36359. protected _collisionTriggered: boolean;
  36360. protected _targetBoundingCenter: Nullable<Vector3>;
  36361. private _computationVector;
  36362. /**
  36363. * Instantiates a new ArcRotateCamera in a given scene
  36364. * @param name Defines the name of the camera
  36365. * @param alpha Defines the camera rotation along the logitudinal axis
  36366. * @param beta Defines the camera rotation along the latitudinal axis
  36367. * @param radius Defines the camera distance from its target
  36368. * @param target Defines the camera target
  36369. * @param scene Defines the scene the camera belongs to
  36370. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  36371. */
  36372. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36373. /** @hidden */
  36374. _initCache(): void;
  36375. /** @hidden */
  36376. _updateCache(ignoreParentClass?: boolean): void;
  36377. protected _getTargetPosition(): Vector3;
  36378. private _storedAlpha;
  36379. private _storedBeta;
  36380. private _storedRadius;
  36381. private _storedTarget;
  36382. /**
  36383. * Stores the current state of the camera (alpha, beta, radius and target)
  36384. * @returns the camera itself
  36385. */
  36386. storeState(): Camera;
  36387. /**
  36388. * @hidden
  36389. * Restored camera state. You must call storeState() first
  36390. */
  36391. _restoreStateValues(): boolean;
  36392. /** @hidden */
  36393. _isSynchronizedViewMatrix(): boolean;
  36394. /**
  36395. * Attached controls to the current camera.
  36396. * @param element Defines the element the controls should be listened from
  36397. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36398. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  36399. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  36400. */
  36401. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  36402. /**
  36403. * Detach the current controls from the camera.
  36404. * The camera will stop reacting to inputs.
  36405. * @param element Defines the element to stop listening the inputs from
  36406. */
  36407. detachControl(element: HTMLElement): void;
  36408. /** @hidden */
  36409. _checkInputs(): void;
  36410. protected _checkLimits(): void;
  36411. /**
  36412. * Rebuilds angles (alpha, beta) and radius from the give position and target
  36413. */
  36414. rebuildAnglesAndRadius(): void;
  36415. /**
  36416. * Use a position to define the current camera related information like aplha, beta and radius
  36417. * @param position Defines the position to set the camera at
  36418. */
  36419. setPosition(position: Vector3): void;
  36420. /**
  36421. * Defines the target the camera should look at.
  36422. * This will automatically adapt alpha beta and radius to fit within the new target.
  36423. * @param target Defines the new target as a Vector or a mesh
  36424. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  36425. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  36426. */
  36427. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  36428. /** @hidden */
  36429. _getViewMatrix(): Matrix;
  36430. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  36431. /**
  36432. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  36433. * @param meshes Defines the mesh to zoom on
  36434. * @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)
  36435. */
  36436. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  36437. /**
  36438. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  36439. * The target will be changed but the radius
  36440. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  36441. * @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)
  36442. */
  36443. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  36444. min: Vector3;
  36445. max: Vector3;
  36446. distance: number;
  36447. }, doNotUpdateMaxZ?: boolean): void;
  36448. /**
  36449. * @override
  36450. * Override Camera.createRigCamera
  36451. */
  36452. createRigCamera(name: string, cameraIndex: number): Camera;
  36453. /**
  36454. * @hidden
  36455. * @override
  36456. * Override Camera._updateRigCameras
  36457. */
  36458. _updateRigCameras(): void;
  36459. /**
  36460. * Destroy the camera and release the current resources hold by it.
  36461. */
  36462. dispose(): void;
  36463. /**
  36464. * Gets the current object class name.
  36465. * @return the class name
  36466. */
  36467. getClassName(): string;
  36468. }
  36469. }
  36470. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  36471. import { Behavior } from "babylonjs/Behaviors/behavior";
  36472. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36473. /**
  36474. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  36475. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36476. */
  36477. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  36478. /**
  36479. * Gets the name of the behavior.
  36480. */
  36481. readonly name: string;
  36482. private _zoomStopsAnimation;
  36483. private _idleRotationSpeed;
  36484. private _idleRotationWaitTime;
  36485. private _idleRotationSpinupTime;
  36486. /**
  36487. * Sets the flag that indicates if user zooming should stop animation.
  36488. */
  36489. /**
  36490. * Gets the flag that indicates if user zooming should stop animation.
  36491. */
  36492. zoomStopsAnimation: boolean;
  36493. /**
  36494. * Sets the default speed at which the camera rotates around the model.
  36495. */
  36496. /**
  36497. * Gets the default speed at which the camera rotates around the model.
  36498. */
  36499. idleRotationSpeed: number;
  36500. /**
  36501. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  36502. */
  36503. /**
  36504. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  36505. */
  36506. idleRotationWaitTime: number;
  36507. /**
  36508. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36509. */
  36510. /**
  36511. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36512. */
  36513. idleRotationSpinupTime: number;
  36514. /**
  36515. * Gets a value indicating if the camera is currently rotating because of this behavior
  36516. */
  36517. readonly rotationInProgress: boolean;
  36518. private _onPrePointerObservableObserver;
  36519. private _onAfterCheckInputsObserver;
  36520. private _attachedCamera;
  36521. private _isPointerDown;
  36522. private _lastFrameTime;
  36523. private _lastInteractionTime;
  36524. private _cameraRotationSpeed;
  36525. /**
  36526. * Initializes the behavior.
  36527. */
  36528. init(): void;
  36529. /**
  36530. * Attaches the behavior to its arc rotate camera.
  36531. * @param camera Defines the camera to attach the behavior to
  36532. */
  36533. attach(camera: ArcRotateCamera): void;
  36534. /**
  36535. * Detaches the behavior from its current arc rotate camera.
  36536. */
  36537. detach(): void;
  36538. /**
  36539. * Returns true if user is scrolling.
  36540. * @return true if user is scrolling.
  36541. */
  36542. private _userIsZooming;
  36543. private _lastFrameRadius;
  36544. private _shouldAnimationStopForInteraction;
  36545. /**
  36546. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36547. */
  36548. private _applyUserInteraction;
  36549. private _userIsMoving;
  36550. }
  36551. }
  36552. declare module "babylonjs/Behaviors/Cameras/index" {
  36553. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  36554. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  36555. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  36556. }
  36557. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  36558. import { Mesh } from "babylonjs/Meshes/mesh";
  36559. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36560. import { Behavior } from "babylonjs/Behaviors/behavior";
  36561. /**
  36562. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  36563. */
  36564. export class AttachToBoxBehavior implements Behavior<Mesh> {
  36565. private ui;
  36566. /**
  36567. * The name of the behavior
  36568. */
  36569. name: string;
  36570. /**
  36571. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  36572. */
  36573. distanceAwayFromFace: number;
  36574. /**
  36575. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  36576. */
  36577. distanceAwayFromBottomOfFace: number;
  36578. private _faceVectors;
  36579. private _target;
  36580. private _scene;
  36581. private _onRenderObserver;
  36582. private _tmpMatrix;
  36583. private _tmpVector;
  36584. /**
  36585. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  36586. * @param ui The transform node that should be attched to the mesh
  36587. */
  36588. constructor(ui: TransformNode);
  36589. /**
  36590. * Initializes the behavior
  36591. */
  36592. init(): void;
  36593. private _closestFace;
  36594. private _zeroVector;
  36595. private _lookAtTmpMatrix;
  36596. private _lookAtToRef;
  36597. /**
  36598. * Attaches the AttachToBoxBehavior to the passed in mesh
  36599. * @param target The mesh that the specified node will be attached to
  36600. */
  36601. attach(target: Mesh): void;
  36602. /**
  36603. * Detaches the behavior from the mesh
  36604. */
  36605. detach(): void;
  36606. }
  36607. }
  36608. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  36609. import { Behavior } from "babylonjs/Behaviors/behavior";
  36610. import { Mesh } from "babylonjs/Meshes/mesh";
  36611. /**
  36612. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  36613. */
  36614. export class FadeInOutBehavior implements Behavior<Mesh> {
  36615. /**
  36616. * Time in milliseconds to delay before fading in (Default: 0)
  36617. */
  36618. delay: number;
  36619. /**
  36620. * Time in milliseconds for the mesh to fade in (Default: 300)
  36621. */
  36622. fadeInTime: number;
  36623. private _millisecondsPerFrame;
  36624. private _hovered;
  36625. private _hoverValue;
  36626. private _ownerNode;
  36627. /**
  36628. * Instatiates the FadeInOutBehavior
  36629. */
  36630. constructor();
  36631. /**
  36632. * The name of the behavior
  36633. */
  36634. readonly name: string;
  36635. /**
  36636. * Initializes the behavior
  36637. */
  36638. init(): void;
  36639. /**
  36640. * Attaches the fade behavior on the passed in mesh
  36641. * @param ownerNode The mesh that will be faded in/out once attached
  36642. */
  36643. attach(ownerNode: Mesh): void;
  36644. /**
  36645. * Detaches the behavior from the mesh
  36646. */
  36647. detach(): void;
  36648. /**
  36649. * Triggers the mesh to begin fading in or out
  36650. * @param value if the object should fade in or out (true to fade in)
  36651. */
  36652. fadeIn(value: boolean): void;
  36653. private _update;
  36654. private _setAllVisibility;
  36655. }
  36656. }
  36657. declare module "babylonjs/Misc/pivotTools" {
  36658. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36659. /**
  36660. * Class containing a set of static utilities functions for managing Pivots
  36661. * @hidden
  36662. */
  36663. export class PivotTools {
  36664. private static _PivotCached;
  36665. private static _OldPivotPoint;
  36666. private static _PivotTranslation;
  36667. private static _PivotTmpVector;
  36668. /** @hidden */
  36669. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  36670. /** @hidden */
  36671. static _RestorePivotPoint(mesh: AbstractMesh): void;
  36672. }
  36673. }
  36674. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  36675. import { Scene } from "babylonjs/scene";
  36676. import { Vector4, Plane } from "babylonjs/Maths/math";
  36677. import { Mesh } from "babylonjs/Meshes/mesh";
  36678. import { Nullable } from "babylonjs/types";
  36679. /**
  36680. * Class containing static functions to help procedurally build meshes
  36681. */
  36682. export class PlaneBuilder {
  36683. /**
  36684. * Creates a plane mesh
  36685. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  36686. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  36687. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  36688. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  36689. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  36690. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  36691. * @param name defines the name of the mesh
  36692. * @param options defines the options used to create the mesh
  36693. * @param scene defines the hosting scene
  36694. * @returns the plane mesh
  36695. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  36696. */
  36697. static CreatePlane(name: string, options: {
  36698. size?: number;
  36699. width?: number;
  36700. height?: number;
  36701. sideOrientation?: number;
  36702. frontUVs?: Vector4;
  36703. backUVs?: Vector4;
  36704. updatable?: boolean;
  36705. sourcePlane?: Plane;
  36706. }, scene?: Nullable<Scene>): Mesh;
  36707. }
  36708. }
  36709. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  36710. import { Behavior } from "babylonjs/Behaviors/behavior";
  36711. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36712. import { Observable } from "babylonjs/Misc/observable";
  36713. import { Vector3 } from "babylonjs/Maths/math";
  36714. import { Ray } from "babylonjs/Culling/ray";
  36715. import "babylonjs/Meshes/Builders/planeBuilder";
  36716. /**
  36717. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  36718. */
  36719. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  36720. private static _AnyMouseID;
  36721. private _attachedNode;
  36722. private _dragPlane;
  36723. private _scene;
  36724. private _pointerObserver;
  36725. private _beforeRenderObserver;
  36726. private static _planeScene;
  36727. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  36728. /**
  36729. * 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)
  36730. */
  36731. maxDragAngle: number;
  36732. /**
  36733. * @hidden
  36734. */
  36735. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  36736. /**
  36737. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36738. */
  36739. currentDraggingPointerID: number;
  36740. /**
  36741. * The last position where the pointer hit the drag plane in world space
  36742. */
  36743. lastDragPosition: Vector3;
  36744. /**
  36745. * If the behavior is currently in a dragging state
  36746. */
  36747. dragging: boolean;
  36748. /**
  36749. * 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)
  36750. */
  36751. dragDeltaRatio: number;
  36752. /**
  36753. * If the drag plane orientation should be updated during the dragging (Default: true)
  36754. */
  36755. updateDragPlane: boolean;
  36756. private _debugMode;
  36757. private _moving;
  36758. /**
  36759. * Fires each time the attached mesh is dragged with the pointer
  36760. * * delta between last drag position and current drag position in world space
  36761. * * dragDistance along the drag axis
  36762. * * dragPlaneNormal normal of the current drag plane used during the drag
  36763. * * dragPlanePoint in world space where the drag intersects the drag plane
  36764. */
  36765. onDragObservable: Observable<{
  36766. delta: Vector3;
  36767. dragPlanePoint: Vector3;
  36768. dragPlaneNormal: Vector3;
  36769. dragDistance: number;
  36770. pointerId: number;
  36771. }>;
  36772. /**
  36773. * Fires each time a drag begins (eg. mouse down on mesh)
  36774. */
  36775. onDragStartObservable: Observable<{
  36776. dragPlanePoint: Vector3;
  36777. pointerId: number;
  36778. }>;
  36779. /**
  36780. * Fires each time a drag ends (eg. mouse release after drag)
  36781. */
  36782. onDragEndObservable: Observable<{
  36783. dragPlanePoint: Vector3;
  36784. pointerId: number;
  36785. }>;
  36786. /**
  36787. * If the attached mesh should be moved when dragged
  36788. */
  36789. moveAttached: boolean;
  36790. /**
  36791. * If the drag behavior will react to drag events (Default: true)
  36792. */
  36793. enabled: boolean;
  36794. /**
  36795. * If camera controls should be detached during the drag
  36796. */
  36797. detachCameraControls: boolean;
  36798. /**
  36799. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  36800. */
  36801. useObjectOrienationForDragging: boolean;
  36802. private _options;
  36803. /**
  36804. * Creates a pointer drag behavior that can be attached to a mesh
  36805. * @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)
  36806. */
  36807. constructor(options?: {
  36808. dragAxis?: Vector3;
  36809. dragPlaneNormal?: Vector3;
  36810. });
  36811. /**
  36812. * Predicate to determine if it is valid to move the object to a new position when it is moved
  36813. */
  36814. validateDrag: (targetPosition: Vector3) => boolean;
  36815. /**
  36816. * The name of the behavior
  36817. */
  36818. readonly name: string;
  36819. /**
  36820. * Initializes the behavior
  36821. */
  36822. init(): void;
  36823. private _tmpVector;
  36824. private _alternatePickedPoint;
  36825. private _worldDragAxis;
  36826. private _targetPosition;
  36827. private _attachedElement;
  36828. /**
  36829. * Attaches the drag behavior the passed in mesh
  36830. * @param ownerNode The mesh that will be dragged around once attached
  36831. */
  36832. attach(ownerNode: AbstractMesh): void;
  36833. /**
  36834. * Force relase the drag action by code.
  36835. */
  36836. releaseDrag(): void;
  36837. private _startDragRay;
  36838. private _lastPointerRay;
  36839. /**
  36840. * Simulates the start of a pointer drag event on the behavior
  36841. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  36842. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  36843. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  36844. */
  36845. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  36846. private _startDrag;
  36847. private _dragDelta;
  36848. private _moveDrag;
  36849. private _pickWithRayOnDragPlane;
  36850. private _pointA;
  36851. private _pointB;
  36852. private _pointC;
  36853. private _lineA;
  36854. private _lineB;
  36855. private _localAxis;
  36856. private _lookAt;
  36857. private _updateDragPlanePosition;
  36858. /**
  36859. * Detaches the behavior from the mesh
  36860. */
  36861. detach(): void;
  36862. }
  36863. }
  36864. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  36865. import { Mesh } from "babylonjs/Meshes/mesh";
  36866. import { Behavior } from "babylonjs/Behaviors/behavior";
  36867. /**
  36868. * A behavior that when attached to a mesh will allow the mesh to be scaled
  36869. */
  36870. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  36871. private _dragBehaviorA;
  36872. private _dragBehaviorB;
  36873. private _startDistance;
  36874. private _initialScale;
  36875. private _targetScale;
  36876. private _ownerNode;
  36877. private _sceneRenderObserver;
  36878. /**
  36879. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  36880. */
  36881. constructor();
  36882. /**
  36883. * The name of the behavior
  36884. */
  36885. readonly name: string;
  36886. /**
  36887. * Initializes the behavior
  36888. */
  36889. init(): void;
  36890. private _getCurrentDistance;
  36891. /**
  36892. * Attaches the scale behavior the passed in mesh
  36893. * @param ownerNode The mesh that will be scaled around once attached
  36894. */
  36895. attach(ownerNode: Mesh): void;
  36896. /**
  36897. * Detaches the behavior from the mesh
  36898. */
  36899. detach(): void;
  36900. }
  36901. }
  36902. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  36903. import { Behavior } from "babylonjs/Behaviors/behavior";
  36904. import { Mesh } from "babylonjs/Meshes/mesh";
  36905. import { Observable } from "babylonjs/Misc/observable";
  36906. /**
  36907. * 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
  36908. */
  36909. export class SixDofDragBehavior implements Behavior<Mesh> {
  36910. private static _virtualScene;
  36911. private _ownerNode;
  36912. private _sceneRenderObserver;
  36913. private _scene;
  36914. private _targetPosition;
  36915. private _virtualOriginMesh;
  36916. private _virtualDragMesh;
  36917. private _pointerObserver;
  36918. private _moving;
  36919. private _startingOrientation;
  36920. /**
  36921. * 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)
  36922. */
  36923. private zDragFactor;
  36924. /**
  36925. * If the object should rotate to face the drag origin
  36926. */
  36927. rotateDraggedObject: boolean;
  36928. /**
  36929. * If the behavior is currently in a dragging state
  36930. */
  36931. dragging: boolean;
  36932. /**
  36933. * 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)
  36934. */
  36935. dragDeltaRatio: number;
  36936. /**
  36937. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36938. */
  36939. currentDraggingPointerID: number;
  36940. /**
  36941. * If camera controls should be detached during the drag
  36942. */
  36943. detachCameraControls: boolean;
  36944. /**
  36945. * Fires each time a drag starts
  36946. */
  36947. onDragStartObservable: Observable<{}>;
  36948. /**
  36949. * Fires each time a drag ends (eg. mouse release after drag)
  36950. */
  36951. onDragEndObservable: Observable<{}>;
  36952. /**
  36953. * 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
  36954. */
  36955. constructor();
  36956. /**
  36957. * The name of the behavior
  36958. */
  36959. readonly name: string;
  36960. /**
  36961. * Initializes the behavior
  36962. */
  36963. init(): void;
  36964. /**
  36965. * Attaches the scale behavior the passed in mesh
  36966. * @param ownerNode The mesh that will be scaled around once attached
  36967. */
  36968. attach(ownerNode: Mesh): void;
  36969. /**
  36970. * Detaches the behavior from the mesh
  36971. */
  36972. detach(): void;
  36973. }
  36974. }
  36975. declare module "babylonjs/Behaviors/Meshes/index" {
  36976. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  36977. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  36978. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  36979. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  36980. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  36981. }
  36982. declare module "babylonjs/Behaviors/index" {
  36983. export * from "babylonjs/Behaviors/behavior";
  36984. export * from "babylonjs/Behaviors/Cameras/index";
  36985. export * from "babylonjs/Behaviors/Meshes/index";
  36986. }
  36987. declare module "babylonjs/Bones/boneIKController" {
  36988. import { Bone } from "babylonjs/Bones/bone";
  36989. import { Vector3 } from "babylonjs/Maths/math";
  36990. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36991. import { Nullable } from "babylonjs/types";
  36992. /**
  36993. * Class used to apply inverse kinematics to bones
  36994. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  36995. */
  36996. export class BoneIKController {
  36997. private static _tmpVecs;
  36998. private static _tmpQuat;
  36999. private static _tmpMats;
  37000. /**
  37001. * Gets or sets the target mesh
  37002. */
  37003. targetMesh: AbstractMesh;
  37004. /** Gets or sets the mesh used as pole */
  37005. poleTargetMesh: AbstractMesh;
  37006. /**
  37007. * Gets or sets the bone used as pole
  37008. */
  37009. poleTargetBone: Nullable<Bone>;
  37010. /**
  37011. * Gets or sets the target position
  37012. */
  37013. targetPosition: Vector3;
  37014. /**
  37015. * Gets or sets the pole target position
  37016. */
  37017. poleTargetPosition: Vector3;
  37018. /**
  37019. * Gets or sets the pole target local offset
  37020. */
  37021. poleTargetLocalOffset: Vector3;
  37022. /**
  37023. * Gets or sets the pole angle
  37024. */
  37025. poleAngle: number;
  37026. /**
  37027. * Gets or sets the mesh associated with the controller
  37028. */
  37029. mesh: AbstractMesh;
  37030. /**
  37031. * 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)
  37032. */
  37033. slerpAmount: number;
  37034. private _bone1Quat;
  37035. private _bone1Mat;
  37036. private _bone2Ang;
  37037. private _bone1;
  37038. private _bone2;
  37039. private _bone1Length;
  37040. private _bone2Length;
  37041. private _maxAngle;
  37042. private _maxReach;
  37043. private _rightHandedSystem;
  37044. private _bendAxis;
  37045. private _slerping;
  37046. private _adjustRoll;
  37047. /**
  37048. * Gets or sets maximum allowed angle
  37049. */
  37050. maxAngle: number;
  37051. /**
  37052. * Creates a new BoneIKController
  37053. * @param mesh defines the mesh to control
  37054. * @param bone defines the bone to control
  37055. * @param options defines options to set up the controller
  37056. */
  37057. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  37058. targetMesh?: AbstractMesh;
  37059. poleTargetMesh?: AbstractMesh;
  37060. poleTargetBone?: Bone;
  37061. poleTargetLocalOffset?: Vector3;
  37062. poleAngle?: number;
  37063. bendAxis?: Vector3;
  37064. maxAngle?: number;
  37065. slerpAmount?: number;
  37066. });
  37067. private _setMaxAngle;
  37068. /**
  37069. * Force the controller to update the bones
  37070. */
  37071. update(): void;
  37072. }
  37073. }
  37074. declare module "babylonjs/Bones/boneLookController" {
  37075. import { Vector3, Space } from "babylonjs/Maths/math";
  37076. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37077. import { Bone } from "babylonjs/Bones/bone";
  37078. /**
  37079. * Class used to make a bone look toward a point in space
  37080. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  37081. */
  37082. export class BoneLookController {
  37083. private static _tmpVecs;
  37084. private static _tmpQuat;
  37085. private static _tmpMats;
  37086. /**
  37087. * The target Vector3 that the bone will look at
  37088. */
  37089. target: Vector3;
  37090. /**
  37091. * The mesh that the bone is attached to
  37092. */
  37093. mesh: AbstractMesh;
  37094. /**
  37095. * The bone that will be looking to the target
  37096. */
  37097. bone: Bone;
  37098. /**
  37099. * The up axis of the coordinate system that is used when the bone is rotated
  37100. */
  37101. upAxis: Vector3;
  37102. /**
  37103. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  37104. */
  37105. upAxisSpace: Space;
  37106. /**
  37107. * Used to make an adjustment to the yaw of the bone
  37108. */
  37109. adjustYaw: number;
  37110. /**
  37111. * Used to make an adjustment to the pitch of the bone
  37112. */
  37113. adjustPitch: number;
  37114. /**
  37115. * Used to make an adjustment to the roll of the bone
  37116. */
  37117. adjustRoll: number;
  37118. /**
  37119. * 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)
  37120. */
  37121. slerpAmount: number;
  37122. private _minYaw;
  37123. private _maxYaw;
  37124. private _minPitch;
  37125. private _maxPitch;
  37126. private _minYawSin;
  37127. private _minYawCos;
  37128. private _maxYawSin;
  37129. private _maxYawCos;
  37130. private _midYawConstraint;
  37131. private _minPitchTan;
  37132. private _maxPitchTan;
  37133. private _boneQuat;
  37134. private _slerping;
  37135. private _transformYawPitch;
  37136. private _transformYawPitchInv;
  37137. private _firstFrameSkipped;
  37138. private _yawRange;
  37139. private _fowardAxis;
  37140. /**
  37141. * Gets or sets the minimum yaw angle that the bone can look to
  37142. */
  37143. minYaw: number;
  37144. /**
  37145. * Gets or sets the maximum yaw angle that the bone can look to
  37146. */
  37147. maxYaw: number;
  37148. /**
  37149. * Gets or sets the minimum pitch angle that the bone can look to
  37150. */
  37151. minPitch: number;
  37152. /**
  37153. * Gets or sets the maximum pitch angle that the bone can look to
  37154. */
  37155. maxPitch: number;
  37156. /**
  37157. * Create a BoneLookController
  37158. * @param mesh the mesh that the bone belongs to
  37159. * @param bone the bone that will be looking to the target
  37160. * @param target the target Vector3 to look at
  37161. * @param options optional settings:
  37162. * * maxYaw: the maximum angle the bone will yaw to
  37163. * * minYaw: the minimum angle the bone will yaw to
  37164. * * maxPitch: the maximum angle the bone will pitch to
  37165. * * minPitch: the minimum angle the bone will yaw to
  37166. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  37167. * * upAxis: the up axis of the coordinate system
  37168. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  37169. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  37170. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  37171. * * adjustYaw: used to make an adjustment to the yaw of the bone
  37172. * * adjustPitch: used to make an adjustment to the pitch of the bone
  37173. * * adjustRoll: used to make an adjustment to the roll of the bone
  37174. **/
  37175. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  37176. maxYaw?: number;
  37177. minYaw?: number;
  37178. maxPitch?: number;
  37179. minPitch?: number;
  37180. slerpAmount?: number;
  37181. upAxis?: Vector3;
  37182. upAxisSpace?: Space;
  37183. yawAxis?: Vector3;
  37184. pitchAxis?: Vector3;
  37185. adjustYaw?: number;
  37186. adjustPitch?: number;
  37187. adjustRoll?: number;
  37188. });
  37189. /**
  37190. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  37191. */
  37192. update(): void;
  37193. private _getAngleDiff;
  37194. private _getAngleBetween;
  37195. private _isAngleBetween;
  37196. }
  37197. }
  37198. declare module "babylonjs/Bones/index" {
  37199. export * from "babylonjs/Bones/bone";
  37200. export * from "babylonjs/Bones/boneIKController";
  37201. export * from "babylonjs/Bones/boneLookController";
  37202. export * from "babylonjs/Bones/skeleton";
  37203. }
  37204. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  37205. import { Nullable } from "babylonjs/types";
  37206. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37207. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37208. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  37209. /**
  37210. * Manage the gamepad inputs to control an arc rotate camera.
  37211. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37212. */
  37213. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  37214. /**
  37215. * Defines the camera the input is attached to.
  37216. */
  37217. camera: ArcRotateCamera;
  37218. /**
  37219. * Defines the gamepad the input is gathering event from.
  37220. */
  37221. gamepad: Nullable<Gamepad>;
  37222. /**
  37223. * Defines the gamepad rotation sensiblity.
  37224. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37225. */
  37226. gamepadRotationSensibility: number;
  37227. /**
  37228. * Defines the gamepad move sensiblity.
  37229. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37230. */
  37231. gamepadMoveSensibility: number;
  37232. private _onGamepadConnectedObserver;
  37233. private _onGamepadDisconnectedObserver;
  37234. /**
  37235. * Attach the input controls to a specific dom element to get the input from.
  37236. * @param element Defines the element the controls should be listened from
  37237. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37238. */
  37239. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37240. /**
  37241. * Detach the current controls from the specified dom element.
  37242. * @param element Defines the element to stop listening the inputs from
  37243. */
  37244. detachControl(element: Nullable<HTMLElement>): void;
  37245. /**
  37246. * Update the current camera state depending on the inputs that have been used this frame.
  37247. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37248. */
  37249. checkInputs(): void;
  37250. /**
  37251. * Gets the class name of the current intput.
  37252. * @returns the class name
  37253. */
  37254. getClassName(): string;
  37255. /**
  37256. * Get the friendly name associated with the input class.
  37257. * @returns the input friendly name
  37258. */
  37259. getSimpleName(): string;
  37260. }
  37261. }
  37262. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  37263. import { Nullable } from "babylonjs/types";
  37264. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37265. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37266. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  37267. interface ArcRotateCameraInputsManager {
  37268. /**
  37269. * Add orientation input support to the input manager.
  37270. * @returns the current input manager
  37271. */
  37272. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  37273. }
  37274. }
  37275. /**
  37276. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  37277. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37278. */
  37279. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  37280. /**
  37281. * Defines the camera the input is attached to.
  37282. */
  37283. camera: ArcRotateCamera;
  37284. /**
  37285. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  37286. */
  37287. alphaCorrection: number;
  37288. /**
  37289. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  37290. */
  37291. gammaCorrection: number;
  37292. private _alpha;
  37293. private _gamma;
  37294. private _dirty;
  37295. private _deviceOrientationHandler;
  37296. /**
  37297. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  37298. */
  37299. constructor();
  37300. /**
  37301. * Attach the input controls to a specific dom element to get the input from.
  37302. * @param element Defines the element the controls should be listened from
  37303. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37304. */
  37305. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37306. /** @hidden */
  37307. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  37308. /**
  37309. * Update the current camera state depending on the inputs that have been used this frame.
  37310. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37311. */
  37312. checkInputs(): void;
  37313. /**
  37314. * Detach the current controls from the specified dom element.
  37315. * @param element Defines the element to stop listening the inputs from
  37316. */
  37317. detachControl(element: Nullable<HTMLElement>): void;
  37318. /**
  37319. * Gets the class name of the current intput.
  37320. * @returns the class name
  37321. */
  37322. getClassName(): string;
  37323. /**
  37324. * Get the friendly name associated with the input class.
  37325. * @returns the input friendly name
  37326. */
  37327. getSimpleName(): string;
  37328. }
  37329. }
  37330. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  37331. import { Nullable } from "babylonjs/types";
  37332. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37333. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37334. /**
  37335. * Listen to mouse events to control the camera.
  37336. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37337. */
  37338. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  37339. /**
  37340. * Defines the camera the input is attached to.
  37341. */
  37342. camera: FlyCamera;
  37343. /**
  37344. * Defines if touch is enabled. (Default is true.)
  37345. */
  37346. touchEnabled: boolean;
  37347. /**
  37348. * Defines the buttons associated with the input to handle camera rotation.
  37349. */
  37350. buttons: number[];
  37351. /**
  37352. * Assign buttons for Yaw control.
  37353. */
  37354. buttonsYaw: number[];
  37355. /**
  37356. * Assign buttons for Pitch control.
  37357. */
  37358. buttonsPitch: number[];
  37359. /**
  37360. * Assign buttons for Roll control.
  37361. */
  37362. buttonsRoll: number[];
  37363. /**
  37364. * Detect if any button is being pressed while mouse is moved.
  37365. * -1 = Mouse locked.
  37366. * 0 = Left button.
  37367. * 1 = Middle Button.
  37368. * 2 = Right Button.
  37369. */
  37370. activeButton: number;
  37371. /**
  37372. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  37373. * Higher values reduce its sensitivity.
  37374. */
  37375. angularSensibility: number;
  37376. private _mousemoveCallback;
  37377. private _observer;
  37378. private _rollObserver;
  37379. private previousPosition;
  37380. private noPreventDefault;
  37381. private element;
  37382. /**
  37383. * Listen to mouse events to control the camera.
  37384. * @param touchEnabled Define if touch is enabled. (Default is true.)
  37385. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37386. */
  37387. constructor(touchEnabled?: boolean);
  37388. /**
  37389. * Attach the mouse control to the HTML DOM element.
  37390. * @param element Defines the element that listens to the input events.
  37391. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  37392. */
  37393. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37394. /**
  37395. * Detach the current controls from the specified dom element.
  37396. * @param element Defines the element to stop listening the inputs from
  37397. */
  37398. detachControl(element: Nullable<HTMLElement>): void;
  37399. /**
  37400. * Gets the class name of the current input.
  37401. * @returns the class name.
  37402. */
  37403. getClassName(): string;
  37404. /**
  37405. * Get the friendly name associated with the input class.
  37406. * @returns the input's friendly name.
  37407. */
  37408. getSimpleName(): string;
  37409. private _pointerInput;
  37410. private _onMouseMove;
  37411. /**
  37412. * Rotate camera by mouse offset.
  37413. */
  37414. private rotateCamera;
  37415. }
  37416. }
  37417. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  37418. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37419. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37420. /**
  37421. * Default Inputs manager for the FlyCamera.
  37422. * It groups all the default supported inputs for ease of use.
  37423. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37424. */
  37425. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  37426. /**
  37427. * Instantiates a new FlyCameraInputsManager.
  37428. * @param camera Defines the camera the inputs belong to.
  37429. */
  37430. constructor(camera: FlyCamera);
  37431. /**
  37432. * Add keyboard input support to the input manager.
  37433. * @returns the new FlyCameraKeyboardMoveInput().
  37434. */
  37435. addKeyboard(): FlyCameraInputsManager;
  37436. /**
  37437. * Add mouse input support to the input manager.
  37438. * @param touchEnabled Enable touch screen support.
  37439. * @returns the new FlyCameraMouseInput().
  37440. */
  37441. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  37442. }
  37443. }
  37444. declare module "babylonjs/Cameras/flyCamera" {
  37445. import { Scene } from "babylonjs/scene";
  37446. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  37447. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37448. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37449. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  37450. /**
  37451. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37452. * such as in a 3D Space Shooter or a Flight Simulator.
  37453. */
  37454. export class FlyCamera extends TargetCamera {
  37455. /**
  37456. * Define the collision ellipsoid of the camera.
  37457. * This is helpful for simulating a camera body, like a player's body.
  37458. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37459. */
  37460. ellipsoid: Vector3;
  37461. /**
  37462. * Define an offset for the position of the ellipsoid around the camera.
  37463. * This can be helpful if the camera is attached away from the player's body center,
  37464. * such as at its head.
  37465. */
  37466. ellipsoidOffset: Vector3;
  37467. /**
  37468. * Enable or disable collisions of the camera with the rest of the scene objects.
  37469. */
  37470. checkCollisions: boolean;
  37471. /**
  37472. * Enable or disable gravity on the camera.
  37473. */
  37474. applyGravity: boolean;
  37475. /**
  37476. * Define the current direction the camera is moving to.
  37477. */
  37478. cameraDirection: Vector3;
  37479. /**
  37480. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  37481. * This overrides and empties cameraRotation.
  37482. */
  37483. rotationQuaternion: Quaternion;
  37484. /**
  37485. * Track Roll to maintain the wanted Rolling when looking around.
  37486. */
  37487. _trackRoll: number;
  37488. /**
  37489. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  37490. */
  37491. rollCorrect: number;
  37492. /**
  37493. * Mimic a banked turn, Rolling the camera when Yawing.
  37494. * It's recommended to use rollCorrect = 10 for faster banking correction.
  37495. */
  37496. bankedTurn: boolean;
  37497. /**
  37498. * Limit in radians for how much Roll banking will add. (Default: 90°)
  37499. */
  37500. bankedTurnLimit: number;
  37501. /**
  37502. * Value of 0 disables the banked Roll.
  37503. * Value of 1 is equal to the Yaw angle in radians.
  37504. */
  37505. bankedTurnMultiplier: number;
  37506. /**
  37507. * The inputs manager loads all the input sources, such as keyboard and mouse.
  37508. */
  37509. inputs: FlyCameraInputsManager;
  37510. /**
  37511. * Gets the input sensibility for mouse input.
  37512. * Higher values reduce sensitivity.
  37513. */
  37514. /**
  37515. * Sets the input sensibility for a mouse input.
  37516. * Higher values reduce sensitivity.
  37517. */
  37518. angularSensibility: number;
  37519. /**
  37520. * Get the keys for camera movement forward.
  37521. */
  37522. /**
  37523. * Set the keys for camera movement forward.
  37524. */
  37525. keysForward: number[];
  37526. /**
  37527. * Get the keys for camera movement backward.
  37528. */
  37529. keysBackward: number[];
  37530. /**
  37531. * Get the keys for camera movement up.
  37532. */
  37533. /**
  37534. * Set the keys for camera movement up.
  37535. */
  37536. keysUp: number[];
  37537. /**
  37538. * Get the keys for camera movement down.
  37539. */
  37540. /**
  37541. * Set the keys for camera movement down.
  37542. */
  37543. keysDown: number[];
  37544. /**
  37545. * Get the keys for camera movement left.
  37546. */
  37547. /**
  37548. * Set the keys for camera movement left.
  37549. */
  37550. keysLeft: number[];
  37551. /**
  37552. * Set the keys for camera movement right.
  37553. */
  37554. /**
  37555. * Set the keys for camera movement right.
  37556. */
  37557. keysRight: number[];
  37558. /**
  37559. * Event raised when the camera collides with a mesh in the scene.
  37560. */
  37561. onCollide: (collidedMesh: AbstractMesh) => void;
  37562. private _collider;
  37563. private _needMoveForGravity;
  37564. private _oldPosition;
  37565. private _diffPosition;
  37566. private _newPosition;
  37567. /** @hidden */
  37568. _localDirection: Vector3;
  37569. /** @hidden */
  37570. _transformedDirection: Vector3;
  37571. /**
  37572. * Instantiates a FlyCamera.
  37573. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37574. * such as in a 3D Space Shooter or a Flight Simulator.
  37575. * @param name Define the name of the camera in the scene.
  37576. * @param position Define the starting position of the camera in the scene.
  37577. * @param scene Define the scene the camera belongs to.
  37578. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  37579. */
  37580. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37581. /**
  37582. * Attach a control to the HTML DOM element.
  37583. * @param element Defines the element that listens to the input events.
  37584. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  37585. */
  37586. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37587. /**
  37588. * Detach a control from the HTML DOM element.
  37589. * The camera will stop reacting to that input.
  37590. * @param element Defines the element that listens to the input events.
  37591. */
  37592. detachControl(element: HTMLElement): void;
  37593. private _collisionMask;
  37594. /**
  37595. * Get the mask that the camera ignores in collision events.
  37596. */
  37597. /**
  37598. * Set the mask that the camera ignores in collision events.
  37599. */
  37600. collisionMask: number;
  37601. /** @hidden */
  37602. _collideWithWorld(displacement: Vector3): void;
  37603. /** @hidden */
  37604. private _onCollisionPositionChange;
  37605. /** @hidden */
  37606. _checkInputs(): void;
  37607. /** @hidden */
  37608. _decideIfNeedsToMove(): boolean;
  37609. /** @hidden */
  37610. _updatePosition(): void;
  37611. /**
  37612. * Restore the Roll to its target value at the rate specified.
  37613. * @param rate - Higher means slower restoring.
  37614. * @hidden
  37615. */
  37616. restoreRoll(rate: number): void;
  37617. /**
  37618. * Destroy the camera and release the current resources held by it.
  37619. */
  37620. dispose(): void;
  37621. /**
  37622. * Get the current object class name.
  37623. * @returns the class name.
  37624. */
  37625. getClassName(): string;
  37626. }
  37627. }
  37628. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  37629. import { Nullable } from "babylonjs/types";
  37630. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37631. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37632. /**
  37633. * Listen to keyboard events to control the camera.
  37634. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37635. */
  37636. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  37637. /**
  37638. * Defines the camera the input is attached to.
  37639. */
  37640. camera: FlyCamera;
  37641. /**
  37642. * The list of keyboard keys used to control the forward move of the camera.
  37643. */
  37644. keysForward: number[];
  37645. /**
  37646. * The list of keyboard keys used to control the backward move of the camera.
  37647. */
  37648. keysBackward: number[];
  37649. /**
  37650. * The list of keyboard keys used to control the forward move of the camera.
  37651. */
  37652. keysUp: number[];
  37653. /**
  37654. * The list of keyboard keys used to control the backward move of the camera.
  37655. */
  37656. keysDown: number[];
  37657. /**
  37658. * The list of keyboard keys used to control the right strafe move of the camera.
  37659. */
  37660. keysRight: number[];
  37661. /**
  37662. * The list of keyboard keys used to control the left strafe move of the camera.
  37663. */
  37664. keysLeft: number[];
  37665. private _keys;
  37666. private _onCanvasBlurObserver;
  37667. private _onKeyboardObserver;
  37668. private _engine;
  37669. private _scene;
  37670. /**
  37671. * Attach the input controls to a specific dom element to get the input from.
  37672. * @param element Defines the element the controls should be listened from
  37673. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37674. */
  37675. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37676. /**
  37677. * Detach the current controls from the specified dom element.
  37678. * @param element Defines the element to stop listening the inputs from
  37679. */
  37680. detachControl(element: Nullable<HTMLElement>): void;
  37681. /**
  37682. * Gets the class name of the current intput.
  37683. * @returns the class name
  37684. */
  37685. getClassName(): string;
  37686. /** @hidden */
  37687. _onLostFocus(e: FocusEvent): void;
  37688. /**
  37689. * Get the friendly name associated with the input class.
  37690. * @returns the input friendly name
  37691. */
  37692. getSimpleName(): string;
  37693. /**
  37694. * Update the current camera state depending on the inputs that have been used this frame.
  37695. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37696. */
  37697. checkInputs(): void;
  37698. }
  37699. }
  37700. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  37701. import { Nullable } from "babylonjs/types";
  37702. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37703. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37704. /**
  37705. * Manage the mouse wheel inputs to control a follow camera.
  37706. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37707. */
  37708. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  37709. /**
  37710. * Defines the camera the input is attached to.
  37711. */
  37712. camera: FollowCamera;
  37713. /**
  37714. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  37715. */
  37716. axisControlRadius: boolean;
  37717. /**
  37718. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  37719. */
  37720. axisControlHeight: boolean;
  37721. /**
  37722. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  37723. */
  37724. axisControlRotation: boolean;
  37725. /**
  37726. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  37727. * relation to mouseWheel events.
  37728. */
  37729. wheelPrecision: number;
  37730. /**
  37731. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37732. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37733. */
  37734. wheelDeltaPercentage: number;
  37735. private _wheel;
  37736. private _observer;
  37737. /**
  37738. * Attach the input controls to a specific dom element to get the input from.
  37739. * @param element Defines the element the controls should be listened from
  37740. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37741. */
  37742. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37743. /**
  37744. * Detach the current controls from the specified dom element.
  37745. * @param element Defines the element to stop listening the inputs from
  37746. */
  37747. detachControl(element: Nullable<HTMLElement>): void;
  37748. /**
  37749. * Gets the class name of the current intput.
  37750. * @returns the class name
  37751. */
  37752. getClassName(): string;
  37753. /**
  37754. * Get the friendly name associated with the input class.
  37755. * @returns the input friendly name
  37756. */
  37757. getSimpleName(): string;
  37758. }
  37759. }
  37760. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  37761. import { Nullable } from "babylonjs/types";
  37762. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37763. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  37764. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  37765. /**
  37766. * Manage the pointers inputs to control an follow camera.
  37767. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37768. */
  37769. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  37770. /**
  37771. * Defines the camera the input is attached to.
  37772. */
  37773. camera: FollowCamera;
  37774. /**
  37775. * Gets the class name of the current input.
  37776. * @returns the class name
  37777. */
  37778. getClassName(): string;
  37779. /**
  37780. * Defines the pointer angular sensibility along the X axis or how fast is
  37781. * the camera rotating.
  37782. * A negative number will reverse the axis direction.
  37783. */
  37784. angularSensibilityX: number;
  37785. /**
  37786. * Defines the pointer angular sensibility along the Y axis or how fast is
  37787. * the camera rotating.
  37788. * A negative number will reverse the axis direction.
  37789. */
  37790. angularSensibilityY: number;
  37791. /**
  37792. * Defines the pointer pinch precision or how fast is the camera zooming.
  37793. * A negative number will reverse the axis direction.
  37794. */
  37795. pinchPrecision: number;
  37796. /**
  37797. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37798. * from 0.
  37799. * It defines the percentage of current camera.radius to use as delta when
  37800. * pinch zoom is used.
  37801. */
  37802. pinchDeltaPercentage: number;
  37803. /**
  37804. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  37805. */
  37806. axisXControlRadius: boolean;
  37807. /**
  37808. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  37809. */
  37810. axisXControlHeight: boolean;
  37811. /**
  37812. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  37813. */
  37814. axisXControlRotation: boolean;
  37815. /**
  37816. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  37817. */
  37818. axisYControlRadius: boolean;
  37819. /**
  37820. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  37821. */
  37822. axisYControlHeight: boolean;
  37823. /**
  37824. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  37825. */
  37826. axisYControlRotation: boolean;
  37827. /**
  37828. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  37829. */
  37830. axisPinchControlRadius: boolean;
  37831. /**
  37832. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  37833. */
  37834. axisPinchControlHeight: boolean;
  37835. /**
  37836. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  37837. */
  37838. axisPinchControlRotation: boolean;
  37839. /**
  37840. * Log error messages if basic misconfiguration has occurred.
  37841. */
  37842. warningEnable: boolean;
  37843. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37844. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37845. private _warningCounter;
  37846. private _warning;
  37847. }
  37848. }
  37849. declare module "babylonjs/Cameras/followCameraInputsManager" {
  37850. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37851. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37852. /**
  37853. * Default Inputs manager for the FollowCamera.
  37854. * It groups all the default supported inputs for ease of use.
  37855. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37856. */
  37857. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  37858. /**
  37859. * Instantiates a new FollowCameraInputsManager.
  37860. * @param camera Defines the camera the inputs belong to
  37861. */
  37862. constructor(camera: FollowCamera);
  37863. /**
  37864. * Add keyboard input support to the input manager.
  37865. * @returns the current input manager
  37866. */
  37867. addKeyboard(): FollowCameraInputsManager;
  37868. /**
  37869. * Add mouse wheel input support to the input manager.
  37870. * @returns the current input manager
  37871. */
  37872. addMouseWheel(): FollowCameraInputsManager;
  37873. /**
  37874. * Add pointers input support to the input manager.
  37875. * @returns the current input manager
  37876. */
  37877. addPointers(): FollowCameraInputsManager;
  37878. /**
  37879. * Add orientation input support to the input manager.
  37880. * @returns the current input manager
  37881. */
  37882. addVRDeviceOrientation(): FollowCameraInputsManager;
  37883. }
  37884. }
  37885. declare module "babylonjs/Cameras/followCamera" {
  37886. import { Nullable } from "babylonjs/types";
  37887. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37888. import { Scene } from "babylonjs/scene";
  37889. import { Vector3 } from "babylonjs/Maths/math";
  37890. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37891. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  37892. /**
  37893. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  37894. * an arc rotate version arcFollowCamera are available.
  37895. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37896. */
  37897. export class FollowCamera extends TargetCamera {
  37898. /**
  37899. * Distance the follow camera should follow an object at
  37900. */
  37901. radius: number;
  37902. /**
  37903. * Minimum allowed distance of the camera to the axis of rotation
  37904. * (The camera can not get closer).
  37905. * This can help limiting how the Camera is able to move in the scene.
  37906. */
  37907. lowerRadiusLimit: Nullable<number>;
  37908. /**
  37909. * Maximum allowed distance of the camera to the axis of rotation
  37910. * (The camera can not get further).
  37911. * This can help limiting how the Camera is able to move in the scene.
  37912. */
  37913. upperRadiusLimit: Nullable<number>;
  37914. /**
  37915. * Define a rotation offset between the camera and the object it follows
  37916. */
  37917. rotationOffset: number;
  37918. /**
  37919. * Minimum allowed angle to camera position relative to target object.
  37920. * This can help limiting how the Camera is able to move in the scene.
  37921. */
  37922. lowerRotationOffsetLimit: Nullable<number>;
  37923. /**
  37924. * Maximum allowed angle to camera position relative to target object.
  37925. * This can help limiting how the Camera is able to move in the scene.
  37926. */
  37927. upperRotationOffsetLimit: Nullable<number>;
  37928. /**
  37929. * Define a height offset between the camera and the object it follows.
  37930. * It can help following an object from the top (like a car chaing a plane)
  37931. */
  37932. heightOffset: number;
  37933. /**
  37934. * Minimum allowed height of camera position relative to target object.
  37935. * This can help limiting how the Camera is able to move in the scene.
  37936. */
  37937. lowerHeightOffsetLimit: Nullable<number>;
  37938. /**
  37939. * Maximum allowed height of camera position relative to target object.
  37940. * This can help limiting how the Camera is able to move in the scene.
  37941. */
  37942. upperHeightOffsetLimit: Nullable<number>;
  37943. /**
  37944. * Define how fast the camera can accelerate to follow it s target.
  37945. */
  37946. cameraAcceleration: number;
  37947. /**
  37948. * Define the speed limit of the camera following an object.
  37949. */
  37950. maxCameraSpeed: number;
  37951. /**
  37952. * Define the target of the camera.
  37953. */
  37954. lockedTarget: Nullable<AbstractMesh>;
  37955. /**
  37956. * Defines the input associated with the camera.
  37957. */
  37958. inputs: FollowCameraInputsManager;
  37959. /**
  37960. * Instantiates the follow camera.
  37961. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37962. * @param name Define the name of the camera in the scene
  37963. * @param position Define the position of the camera
  37964. * @param scene Define the scene the camera belong to
  37965. * @param lockedTarget Define the target of the camera
  37966. */
  37967. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  37968. private _follow;
  37969. /**
  37970. * Attached controls to the current camera.
  37971. * @param element Defines the element the controls should be listened from
  37972. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37973. */
  37974. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37975. /**
  37976. * Detach the current controls from the camera.
  37977. * The camera will stop reacting to inputs.
  37978. * @param element Defines the element to stop listening the inputs from
  37979. */
  37980. detachControl(element: HTMLElement): void;
  37981. /** @hidden */
  37982. _checkInputs(): void;
  37983. private _checkLimits;
  37984. /**
  37985. * Gets the camera class name.
  37986. * @returns the class name
  37987. */
  37988. getClassName(): string;
  37989. }
  37990. /**
  37991. * Arc Rotate version of the follow camera.
  37992. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  37993. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37994. */
  37995. export class ArcFollowCamera extends TargetCamera {
  37996. /** The longitudinal angle of the camera */
  37997. alpha: number;
  37998. /** The latitudinal angle of the camera */
  37999. beta: number;
  38000. /** The radius of the camera from its target */
  38001. radius: number;
  38002. /** Define the camera target (the messh it should follow) */
  38003. target: Nullable<AbstractMesh>;
  38004. private _cartesianCoordinates;
  38005. /**
  38006. * Instantiates a new ArcFollowCamera
  38007. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38008. * @param name Define the name of the camera
  38009. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  38010. * @param beta Define the rotation angle of the camera around the elevation axis
  38011. * @param radius Define the radius of the camera from its target point
  38012. * @param target Define the target of the camera
  38013. * @param scene Define the scene the camera belongs to
  38014. */
  38015. constructor(name: string,
  38016. /** The longitudinal angle of the camera */
  38017. alpha: number,
  38018. /** The latitudinal angle of the camera */
  38019. beta: number,
  38020. /** The radius of the camera from its target */
  38021. radius: number,
  38022. /** Define the camera target (the messh it should follow) */
  38023. target: Nullable<AbstractMesh>, scene: Scene);
  38024. private _follow;
  38025. /** @hidden */
  38026. _checkInputs(): void;
  38027. /**
  38028. * Returns the class name of the object.
  38029. * It is mostly used internally for serialization purposes.
  38030. */
  38031. getClassName(): string;
  38032. }
  38033. }
  38034. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  38035. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38036. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38037. import { Nullable } from "babylonjs/types";
  38038. /**
  38039. * Manage the keyboard inputs to control the movement of a follow camera.
  38040. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38041. */
  38042. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  38043. /**
  38044. * Defines the camera the input is attached to.
  38045. */
  38046. camera: FollowCamera;
  38047. /**
  38048. * Defines the list of key codes associated with the up action (increase heightOffset)
  38049. */
  38050. keysHeightOffsetIncr: number[];
  38051. /**
  38052. * Defines the list of key codes associated with the down action (decrease heightOffset)
  38053. */
  38054. keysHeightOffsetDecr: number[];
  38055. /**
  38056. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  38057. */
  38058. keysHeightOffsetModifierAlt: boolean;
  38059. /**
  38060. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  38061. */
  38062. keysHeightOffsetModifierCtrl: boolean;
  38063. /**
  38064. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  38065. */
  38066. keysHeightOffsetModifierShift: boolean;
  38067. /**
  38068. * Defines the list of key codes associated with the left action (increase rotationOffset)
  38069. */
  38070. keysRotationOffsetIncr: number[];
  38071. /**
  38072. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  38073. */
  38074. keysRotationOffsetDecr: number[];
  38075. /**
  38076. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  38077. */
  38078. keysRotationOffsetModifierAlt: boolean;
  38079. /**
  38080. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  38081. */
  38082. keysRotationOffsetModifierCtrl: boolean;
  38083. /**
  38084. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  38085. */
  38086. keysRotationOffsetModifierShift: boolean;
  38087. /**
  38088. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  38089. */
  38090. keysRadiusIncr: number[];
  38091. /**
  38092. * Defines the list of key codes associated with the zoom-out action (increase radius)
  38093. */
  38094. keysRadiusDecr: number[];
  38095. /**
  38096. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  38097. */
  38098. keysRadiusModifierAlt: boolean;
  38099. /**
  38100. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  38101. */
  38102. keysRadiusModifierCtrl: boolean;
  38103. /**
  38104. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  38105. */
  38106. keysRadiusModifierShift: boolean;
  38107. /**
  38108. * Defines the rate of change of heightOffset.
  38109. */
  38110. heightSensibility: number;
  38111. /**
  38112. * Defines the rate of change of rotationOffset.
  38113. */
  38114. rotationSensibility: number;
  38115. /**
  38116. * Defines the rate of change of radius.
  38117. */
  38118. radiusSensibility: number;
  38119. private _keys;
  38120. private _ctrlPressed;
  38121. private _altPressed;
  38122. private _shiftPressed;
  38123. private _onCanvasBlurObserver;
  38124. private _onKeyboardObserver;
  38125. private _engine;
  38126. private _scene;
  38127. /**
  38128. * Attach the input controls to a specific dom element to get the input from.
  38129. * @param element Defines the element the controls should be listened from
  38130. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38131. */
  38132. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38133. /**
  38134. * Detach the current controls from the specified dom element.
  38135. * @param element Defines the element to stop listening the inputs from
  38136. */
  38137. detachControl(element: Nullable<HTMLElement>): void;
  38138. /**
  38139. * Update the current camera state depending on the inputs that have been used this frame.
  38140. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38141. */
  38142. checkInputs(): void;
  38143. /**
  38144. * Gets the class name of the current input.
  38145. * @returns the class name
  38146. */
  38147. getClassName(): string;
  38148. /**
  38149. * Get the friendly name associated with the input class.
  38150. * @returns the input friendly name
  38151. */
  38152. getSimpleName(): string;
  38153. /**
  38154. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38155. * allow modification of the heightOffset value.
  38156. */
  38157. private _modifierHeightOffset;
  38158. /**
  38159. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38160. * allow modification of the rotationOffset value.
  38161. */
  38162. private _modifierRotationOffset;
  38163. /**
  38164. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38165. * allow modification of the radius value.
  38166. */
  38167. private _modifierRadius;
  38168. }
  38169. }
  38170. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  38171. import { Nullable } from "babylonjs/types";
  38172. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38173. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38174. import { Observable } from "babylonjs/Misc/observable";
  38175. module "babylonjs/Cameras/freeCameraInputsManager" {
  38176. interface FreeCameraInputsManager {
  38177. /**
  38178. * @hidden
  38179. */
  38180. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  38181. /**
  38182. * Add orientation input support to the input manager.
  38183. * @returns the current input manager
  38184. */
  38185. addDeviceOrientation(): FreeCameraInputsManager;
  38186. }
  38187. }
  38188. /**
  38189. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  38190. * Screen rotation is taken into account.
  38191. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38192. */
  38193. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  38194. private _camera;
  38195. private _screenOrientationAngle;
  38196. private _constantTranform;
  38197. private _screenQuaternion;
  38198. private _alpha;
  38199. private _beta;
  38200. private _gamma;
  38201. /**
  38202. * @hidden
  38203. */
  38204. _onDeviceOrientationChangedObservable: Observable<void>;
  38205. /**
  38206. * Instantiates a new input
  38207. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38208. */
  38209. constructor();
  38210. /**
  38211. * Define the camera controlled by the input.
  38212. */
  38213. camera: FreeCamera;
  38214. /**
  38215. * Attach the input controls to a specific dom element to get the input from.
  38216. * @param element Defines the element the controls should be listened from
  38217. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38218. */
  38219. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38220. private _orientationChanged;
  38221. private _deviceOrientation;
  38222. /**
  38223. * Detach the current controls from the specified dom element.
  38224. * @param element Defines the element to stop listening the inputs from
  38225. */
  38226. detachControl(element: Nullable<HTMLElement>): void;
  38227. /**
  38228. * Update the current camera state depending on the inputs that have been used this frame.
  38229. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38230. */
  38231. checkInputs(): void;
  38232. /**
  38233. * Gets the class name of the current intput.
  38234. * @returns the class name
  38235. */
  38236. getClassName(): string;
  38237. /**
  38238. * Get the friendly name associated with the input class.
  38239. * @returns the input friendly name
  38240. */
  38241. getSimpleName(): string;
  38242. }
  38243. }
  38244. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  38245. import { Nullable } from "babylonjs/types";
  38246. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38247. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38248. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38249. /**
  38250. * Manage the gamepad inputs to control a free camera.
  38251. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38252. */
  38253. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  38254. /**
  38255. * Define the camera the input is attached to.
  38256. */
  38257. camera: FreeCamera;
  38258. /**
  38259. * Define the Gamepad controlling the input
  38260. */
  38261. gamepad: Nullable<Gamepad>;
  38262. /**
  38263. * Defines the gamepad rotation sensiblity.
  38264. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38265. */
  38266. gamepadAngularSensibility: number;
  38267. /**
  38268. * Defines the gamepad move sensiblity.
  38269. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38270. */
  38271. gamepadMoveSensibility: number;
  38272. private _onGamepadConnectedObserver;
  38273. private _onGamepadDisconnectedObserver;
  38274. private _cameraTransform;
  38275. private _deltaTransform;
  38276. private _vector3;
  38277. private _vector2;
  38278. /**
  38279. * Attach the input controls to a specific dom element to get the input from.
  38280. * @param element Defines the element the controls should be listened from
  38281. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38282. */
  38283. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38284. /**
  38285. * Detach the current controls from the specified dom element.
  38286. * @param element Defines the element to stop listening the inputs from
  38287. */
  38288. detachControl(element: Nullable<HTMLElement>): void;
  38289. /**
  38290. * Update the current camera state depending on the inputs that have been used this frame.
  38291. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38292. */
  38293. checkInputs(): void;
  38294. /**
  38295. * Gets the class name of the current intput.
  38296. * @returns the class name
  38297. */
  38298. getClassName(): string;
  38299. /**
  38300. * Get the friendly name associated with the input class.
  38301. * @returns the input friendly name
  38302. */
  38303. getSimpleName(): string;
  38304. }
  38305. }
  38306. declare module "babylonjs/Misc/virtualJoystick" {
  38307. import { Nullable } from "babylonjs/types";
  38308. import { Vector3 } from "babylonjs/Maths/math";
  38309. /**
  38310. * Defines the potential axis of a Joystick
  38311. */
  38312. export enum JoystickAxis {
  38313. /** X axis */
  38314. X = 0,
  38315. /** Y axis */
  38316. Y = 1,
  38317. /** Z axis */
  38318. Z = 2
  38319. }
  38320. /**
  38321. * Class used to define virtual joystick (used in touch mode)
  38322. */
  38323. export class VirtualJoystick {
  38324. /**
  38325. * Gets or sets a boolean indicating that left and right values must be inverted
  38326. */
  38327. reverseLeftRight: boolean;
  38328. /**
  38329. * Gets or sets a boolean indicating that up and down values must be inverted
  38330. */
  38331. reverseUpDown: boolean;
  38332. /**
  38333. * Gets the offset value for the position (ie. the change of the position value)
  38334. */
  38335. deltaPosition: Vector3;
  38336. /**
  38337. * Gets a boolean indicating if the virtual joystick was pressed
  38338. */
  38339. pressed: boolean;
  38340. /**
  38341. * Canvas the virtual joystick will render onto, default z-index of this is 5
  38342. */
  38343. static Canvas: Nullable<HTMLCanvasElement>;
  38344. private static _globalJoystickIndex;
  38345. private static vjCanvasContext;
  38346. private static vjCanvasWidth;
  38347. private static vjCanvasHeight;
  38348. private static halfWidth;
  38349. private _action;
  38350. private _axisTargetedByLeftAndRight;
  38351. private _axisTargetedByUpAndDown;
  38352. private _joystickSensibility;
  38353. private _inversedSensibility;
  38354. private _joystickPointerID;
  38355. private _joystickColor;
  38356. private _joystickPointerPos;
  38357. private _joystickPreviousPointerPos;
  38358. private _joystickPointerStartPos;
  38359. private _deltaJoystickVector;
  38360. private _leftJoystick;
  38361. private _touches;
  38362. private _onPointerDownHandlerRef;
  38363. private _onPointerMoveHandlerRef;
  38364. private _onPointerUpHandlerRef;
  38365. private _onResize;
  38366. /**
  38367. * Creates a new virtual joystick
  38368. * @param leftJoystick defines that the joystick is for left hand (false by default)
  38369. */
  38370. constructor(leftJoystick?: boolean);
  38371. /**
  38372. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  38373. * @param newJoystickSensibility defines the new sensibility
  38374. */
  38375. setJoystickSensibility(newJoystickSensibility: number): void;
  38376. private _onPointerDown;
  38377. private _onPointerMove;
  38378. private _onPointerUp;
  38379. /**
  38380. * Change the color of the virtual joystick
  38381. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  38382. */
  38383. setJoystickColor(newColor: string): void;
  38384. /**
  38385. * Defines a callback to call when the joystick is touched
  38386. * @param action defines the callback
  38387. */
  38388. setActionOnTouch(action: () => any): void;
  38389. /**
  38390. * Defines which axis you'd like to control for left & right
  38391. * @param axis defines the axis to use
  38392. */
  38393. setAxisForLeftRight(axis: JoystickAxis): void;
  38394. /**
  38395. * Defines which axis you'd like to control for up & down
  38396. * @param axis defines the axis to use
  38397. */
  38398. setAxisForUpDown(axis: JoystickAxis): void;
  38399. private _drawVirtualJoystick;
  38400. /**
  38401. * Release internal HTML canvas
  38402. */
  38403. releaseCanvas(): void;
  38404. }
  38405. }
  38406. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  38407. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  38408. import { Nullable } from "babylonjs/types";
  38409. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38410. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38411. module "babylonjs/Cameras/freeCameraInputsManager" {
  38412. interface FreeCameraInputsManager {
  38413. /**
  38414. * Add virtual joystick input support to the input manager.
  38415. * @returns the current input manager
  38416. */
  38417. addVirtualJoystick(): FreeCameraInputsManager;
  38418. }
  38419. }
  38420. /**
  38421. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  38422. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38423. */
  38424. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  38425. /**
  38426. * Defines the camera the input is attached to.
  38427. */
  38428. camera: FreeCamera;
  38429. private _leftjoystick;
  38430. private _rightjoystick;
  38431. /**
  38432. * Gets the left stick of the virtual joystick.
  38433. * @returns The virtual Joystick
  38434. */
  38435. getLeftJoystick(): VirtualJoystick;
  38436. /**
  38437. * Gets the right stick of the virtual joystick.
  38438. * @returns The virtual Joystick
  38439. */
  38440. getRightJoystick(): VirtualJoystick;
  38441. /**
  38442. * Update the current camera state depending on the inputs that have been used this frame.
  38443. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38444. */
  38445. checkInputs(): void;
  38446. /**
  38447. * Attach the input controls to a specific dom element to get the input from.
  38448. * @param element Defines the element the controls should be listened from
  38449. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38450. */
  38451. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38452. /**
  38453. * Detach the current controls from the specified dom element.
  38454. * @param element Defines the element to stop listening the inputs from
  38455. */
  38456. detachControl(element: Nullable<HTMLElement>): void;
  38457. /**
  38458. * Gets the class name of the current intput.
  38459. * @returns the class name
  38460. */
  38461. getClassName(): string;
  38462. /**
  38463. * Get the friendly name associated with the input class.
  38464. * @returns the input friendly name
  38465. */
  38466. getSimpleName(): string;
  38467. }
  38468. }
  38469. declare module "babylonjs/Cameras/Inputs/index" {
  38470. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  38471. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  38472. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  38473. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  38474. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  38475. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  38476. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  38477. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  38478. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  38479. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  38480. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  38481. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  38482. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  38483. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  38484. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  38485. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  38486. }
  38487. declare module "babylonjs/Cameras/touchCamera" {
  38488. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38489. import { Scene } from "babylonjs/scene";
  38490. import { Vector3 } from "babylonjs/Maths/math";
  38491. /**
  38492. * This represents a FPS type of camera controlled by touch.
  38493. * This is like a universal camera minus the Gamepad controls.
  38494. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38495. */
  38496. export class TouchCamera extends FreeCamera {
  38497. /**
  38498. * Defines the touch sensibility for rotation.
  38499. * The higher the faster.
  38500. */
  38501. touchAngularSensibility: number;
  38502. /**
  38503. * Defines the touch sensibility for move.
  38504. * The higher the faster.
  38505. */
  38506. touchMoveSensibility: number;
  38507. /**
  38508. * Instantiates a new touch camera.
  38509. * This represents a FPS type of camera controlled by touch.
  38510. * This is like a universal camera minus the Gamepad controls.
  38511. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38512. * @param name Define the name of the camera in the scene
  38513. * @param position Define the start position of the camera in the scene
  38514. * @param scene Define the scene the camera belongs to
  38515. */
  38516. constructor(name: string, position: Vector3, scene: Scene);
  38517. /**
  38518. * Gets the current object class name.
  38519. * @return the class name
  38520. */
  38521. getClassName(): string;
  38522. /** @hidden */
  38523. _setupInputs(): void;
  38524. }
  38525. }
  38526. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  38527. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38528. import { Scene } from "babylonjs/scene";
  38529. import { Vector3, Axis } from "babylonjs/Maths/math";
  38530. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  38531. /**
  38532. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  38533. * being tilted forward or back and left or right.
  38534. */
  38535. export class DeviceOrientationCamera extends FreeCamera {
  38536. private _initialQuaternion;
  38537. private _quaternionCache;
  38538. private _tmpDragQuaternion;
  38539. /**
  38540. * Creates a new device orientation camera
  38541. * @param name The name of the camera
  38542. * @param position The start position camera
  38543. * @param scene The scene the camera belongs to
  38544. */
  38545. constructor(name: string, position: Vector3, scene: Scene);
  38546. /**
  38547. * @hidden
  38548. * Disabled pointer input on first orientation sensor update (Default: true)
  38549. */
  38550. _disablePointerInputWhenUsingDeviceOrientation: boolean;
  38551. private _dragFactor;
  38552. /**
  38553. * Enabled turning on the y axis when the orientation sensor is active
  38554. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  38555. */
  38556. enableHorizontalDragging(dragFactor?: number): void;
  38557. /**
  38558. * Gets the current instance class name ("DeviceOrientationCamera").
  38559. * This helps avoiding instanceof at run time.
  38560. * @returns the class name
  38561. */
  38562. getClassName(): string;
  38563. /**
  38564. * @hidden
  38565. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  38566. */
  38567. _checkInputs(): void;
  38568. /**
  38569. * Reset the camera to its default orientation on the specified axis only.
  38570. * @param axis The axis to reset
  38571. */
  38572. resetToCurrentRotation(axis?: Axis): void;
  38573. }
  38574. }
  38575. declare module "babylonjs/Gamepads/xboxGamepad" {
  38576. import { Observable } from "babylonjs/Misc/observable";
  38577. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38578. /**
  38579. * Defines supported buttons for XBox360 compatible gamepads
  38580. */
  38581. export enum Xbox360Button {
  38582. /** A */
  38583. A = 0,
  38584. /** B */
  38585. B = 1,
  38586. /** X */
  38587. X = 2,
  38588. /** Y */
  38589. Y = 3,
  38590. /** Start */
  38591. Start = 4,
  38592. /** Back */
  38593. Back = 5,
  38594. /** Left button */
  38595. LB = 6,
  38596. /** Right button */
  38597. RB = 7,
  38598. /** Left stick */
  38599. LeftStick = 8,
  38600. /** Right stick */
  38601. RightStick = 9
  38602. }
  38603. /** Defines values for XBox360 DPad */
  38604. export enum Xbox360Dpad {
  38605. /** Up */
  38606. Up = 0,
  38607. /** Down */
  38608. Down = 1,
  38609. /** Left */
  38610. Left = 2,
  38611. /** Right */
  38612. Right = 3
  38613. }
  38614. /**
  38615. * Defines a XBox360 gamepad
  38616. */
  38617. export class Xbox360Pad extends Gamepad {
  38618. private _leftTrigger;
  38619. private _rightTrigger;
  38620. private _onlefttriggerchanged;
  38621. private _onrighttriggerchanged;
  38622. private _onbuttondown;
  38623. private _onbuttonup;
  38624. private _ondpaddown;
  38625. private _ondpadup;
  38626. /** Observable raised when a button is pressed */
  38627. onButtonDownObservable: Observable<Xbox360Button>;
  38628. /** Observable raised when a button is released */
  38629. onButtonUpObservable: Observable<Xbox360Button>;
  38630. /** Observable raised when a pad is pressed */
  38631. onPadDownObservable: Observable<Xbox360Dpad>;
  38632. /** Observable raised when a pad is released */
  38633. onPadUpObservable: Observable<Xbox360Dpad>;
  38634. private _buttonA;
  38635. private _buttonB;
  38636. private _buttonX;
  38637. private _buttonY;
  38638. private _buttonBack;
  38639. private _buttonStart;
  38640. private _buttonLB;
  38641. private _buttonRB;
  38642. private _buttonLeftStick;
  38643. private _buttonRightStick;
  38644. private _dPadUp;
  38645. private _dPadDown;
  38646. private _dPadLeft;
  38647. private _dPadRight;
  38648. private _isXboxOnePad;
  38649. /**
  38650. * Creates a new XBox360 gamepad object
  38651. * @param id defines the id of this gamepad
  38652. * @param index defines its index
  38653. * @param gamepad defines the internal HTML gamepad object
  38654. * @param xboxOne defines if it is a XBox One gamepad
  38655. */
  38656. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  38657. /**
  38658. * Defines the callback to call when left trigger is pressed
  38659. * @param callback defines the callback to use
  38660. */
  38661. onlefttriggerchanged(callback: (value: number) => void): void;
  38662. /**
  38663. * Defines the callback to call when right trigger is pressed
  38664. * @param callback defines the callback to use
  38665. */
  38666. onrighttriggerchanged(callback: (value: number) => void): void;
  38667. /**
  38668. * Gets the left trigger value
  38669. */
  38670. /**
  38671. * Sets the left trigger value
  38672. */
  38673. leftTrigger: number;
  38674. /**
  38675. * Gets the right trigger value
  38676. */
  38677. /**
  38678. * Sets the right trigger value
  38679. */
  38680. rightTrigger: number;
  38681. /**
  38682. * Defines the callback to call when a button is pressed
  38683. * @param callback defines the callback to use
  38684. */
  38685. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  38686. /**
  38687. * Defines the callback to call when a button is released
  38688. * @param callback defines the callback to use
  38689. */
  38690. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  38691. /**
  38692. * Defines the callback to call when a pad is pressed
  38693. * @param callback defines the callback to use
  38694. */
  38695. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  38696. /**
  38697. * Defines the callback to call when a pad is released
  38698. * @param callback defines the callback to use
  38699. */
  38700. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  38701. private _setButtonValue;
  38702. private _setDPadValue;
  38703. /**
  38704. * Gets the value of the `A` button
  38705. */
  38706. /**
  38707. * Sets the value of the `A` button
  38708. */
  38709. buttonA: number;
  38710. /**
  38711. * Gets the value of the `B` button
  38712. */
  38713. /**
  38714. * Sets the value of the `B` button
  38715. */
  38716. buttonB: number;
  38717. /**
  38718. * Gets the value of the `X` button
  38719. */
  38720. /**
  38721. * Sets the value of the `X` button
  38722. */
  38723. buttonX: number;
  38724. /**
  38725. * Gets the value of the `Y` button
  38726. */
  38727. /**
  38728. * Sets the value of the `Y` button
  38729. */
  38730. buttonY: number;
  38731. /**
  38732. * Gets the value of the `Start` button
  38733. */
  38734. /**
  38735. * Sets the value of the `Start` button
  38736. */
  38737. buttonStart: number;
  38738. /**
  38739. * Gets the value of the `Back` button
  38740. */
  38741. /**
  38742. * Sets the value of the `Back` button
  38743. */
  38744. buttonBack: number;
  38745. /**
  38746. * Gets the value of the `Left` button
  38747. */
  38748. /**
  38749. * Sets the value of the `Left` button
  38750. */
  38751. buttonLB: number;
  38752. /**
  38753. * Gets the value of the `Right` button
  38754. */
  38755. /**
  38756. * Sets the value of the `Right` button
  38757. */
  38758. buttonRB: number;
  38759. /**
  38760. * Gets the value of the Left joystick
  38761. */
  38762. /**
  38763. * Sets the value of the Left joystick
  38764. */
  38765. buttonLeftStick: number;
  38766. /**
  38767. * Gets the value of the Right joystick
  38768. */
  38769. /**
  38770. * Sets the value of the Right joystick
  38771. */
  38772. buttonRightStick: number;
  38773. /**
  38774. * Gets the value of D-pad up
  38775. */
  38776. /**
  38777. * Sets the value of D-pad up
  38778. */
  38779. dPadUp: number;
  38780. /**
  38781. * Gets the value of D-pad down
  38782. */
  38783. /**
  38784. * Sets the value of D-pad down
  38785. */
  38786. dPadDown: number;
  38787. /**
  38788. * Gets the value of D-pad left
  38789. */
  38790. /**
  38791. * Sets the value of D-pad left
  38792. */
  38793. dPadLeft: number;
  38794. /**
  38795. * Gets the value of D-pad right
  38796. */
  38797. /**
  38798. * Sets the value of D-pad right
  38799. */
  38800. dPadRight: number;
  38801. /**
  38802. * Force the gamepad to synchronize with device values
  38803. */
  38804. update(): void;
  38805. /**
  38806. * Disposes the gamepad
  38807. */
  38808. dispose(): void;
  38809. }
  38810. }
  38811. declare module "babylonjs/Gamepads/gamepadManager" {
  38812. import { Observable } from "babylonjs/Misc/observable";
  38813. import { Nullable } from "babylonjs/types";
  38814. import { Scene } from "babylonjs/scene";
  38815. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38816. /**
  38817. * Manager for handling gamepads
  38818. */
  38819. export class GamepadManager {
  38820. private _scene?;
  38821. private _babylonGamepads;
  38822. private _oneGamepadConnected;
  38823. /** @hidden */
  38824. _isMonitoring: boolean;
  38825. private _gamepadEventSupported;
  38826. private _gamepadSupport;
  38827. /**
  38828. * observable to be triggered when the gamepad controller has been connected
  38829. */
  38830. onGamepadConnectedObservable: Observable<Gamepad>;
  38831. /**
  38832. * observable to be triggered when the gamepad controller has been disconnected
  38833. */
  38834. onGamepadDisconnectedObservable: Observable<Gamepad>;
  38835. private _onGamepadConnectedEvent;
  38836. private _onGamepadDisconnectedEvent;
  38837. /**
  38838. * Initializes the gamepad manager
  38839. * @param _scene BabylonJS scene
  38840. */
  38841. constructor(_scene?: Scene | undefined);
  38842. /**
  38843. * The gamepads in the game pad manager
  38844. */
  38845. readonly gamepads: Gamepad[];
  38846. /**
  38847. * Get the gamepad controllers based on type
  38848. * @param type The type of gamepad controller
  38849. * @returns Nullable gamepad
  38850. */
  38851. getGamepadByType(type?: number): Nullable<Gamepad>;
  38852. /**
  38853. * Disposes the gamepad manager
  38854. */
  38855. dispose(): void;
  38856. private _addNewGamepad;
  38857. private _startMonitoringGamepads;
  38858. private _stopMonitoringGamepads;
  38859. /** @hidden */
  38860. _checkGamepadsStatus(): void;
  38861. private _updateGamepadObjects;
  38862. }
  38863. }
  38864. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  38865. import { Nullable } from "babylonjs/types";
  38866. import { Scene } from "babylonjs/scene";
  38867. import { ISceneComponent } from "babylonjs/sceneComponent";
  38868. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  38869. module "babylonjs/scene" {
  38870. interface Scene {
  38871. /** @hidden */
  38872. _gamepadManager: Nullable<GamepadManager>;
  38873. /**
  38874. * Gets the gamepad manager associated with the scene
  38875. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  38876. */
  38877. gamepadManager: GamepadManager;
  38878. }
  38879. }
  38880. module "babylonjs/Cameras/freeCameraInputsManager" {
  38881. /**
  38882. * Interface representing a free camera inputs manager
  38883. */
  38884. interface FreeCameraInputsManager {
  38885. /**
  38886. * Adds gamepad input support to the FreeCameraInputsManager.
  38887. * @returns the FreeCameraInputsManager
  38888. */
  38889. addGamepad(): FreeCameraInputsManager;
  38890. }
  38891. }
  38892. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  38893. /**
  38894. * Interface representing an arc rotate camera inputs manager
  38895. */
  38896. interface ArcRotateCameraInputsManager {
  38897. /**
  38898. * Adds gamepad input support to the ArcRotateCamera InputManager.
  38899. * @returns the camera inputs manager
  38900. */
  38901. addGamepad(): ArcRotateCameraInputsManager;
  38902. }
  38903. }
  38904. /**
  38905. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  38906. */
  38907. export class GamepadSystemSceneComponent implements ISceneComponent {
  38908. /**
  38909. * The component name helpfull to identify the component in the list of scene components.
  38910. */
  38911. readonly name: string;
  38912. /**
  38913. * The scene the component belongs to.
  38914. */
  38915. scene: Scene;
  38916. /**
  38917. * Creates a new instance of the component for the given scene
  38918. * @param scene Defines the scene to register the component in
  38919. */
  38920. constructor(scene: Scene);
  38921. /**
  38922. * Registers the component in a given scene
  38923. */
  38924. register(): void;
  38925. /**
  38926. * Rebuilds the elements related to this component in case of
  38927. * context lost for instance.
  38928. */
  38929. rebuild(): void;
  38930. /**
  38931. * Disposes the component and the associated ressources
  38932. */
  38933. dispose(): void;
  38934. private _beforeCameraUpdate;
  38935. }
  38936. }
  38937. declare module "babylonjs/Cameras/universalCamera" {
  38938. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  38939. import { Scene } from "babylonjs/scene";
  38940. import { Vector3 } from "babylonjs/Maths/math";
  38941. import "babylonjs/Gamepads/gamepadSceneComponent";
  38942. /**
  38943. * 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,
  38944. * which still works and will still be found in many Playgrounds.
  38945. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38946. */
  38947. export class UniversalCamera extends TouchCamera {
  38948. /**
  38949. * Defines the gamepad rotation sensiblity.
  38950. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38951. */
  38952. gamepadAngularSensibility: number;
  38953. /**
  38954. * Defines the gamepad move sensiblity.
  38955. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38956. */
  38957. gamepadMoveSensibility: number;
  38958. /**
  38959. * 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,
  38960. * which still works and will still be found in many Playgrounds.
  38961. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38962. * @param name Define the name of the camera in the scene
  38963. * @param position Define the start position of the camera in the scene
  38964. * @param scene Define the scene the camera belongs to
  38965. */
  38966. constructor(name: string, position: Vector3, scene: Scene);
  38967. /**
  38968. * Gets the current object class name.
  38969. * @return the class name
  38970. */
  38971. getClassName(): string;
  38972. }
  38973. }
  38974. declare module "babylonjs/Cameras/gamepadCamera" {
  38975. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  38976. import { Scene } from "babylonjs/scene";
  38977. import { Vector3 } from "babylonjs/Maths/math";
  38978. /**
  38979. * This represents a FPS type of camera. This is only here for back compat purpose.
  38980. * Please use the UniversalCamera instead as both are identical.
  38981. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38982. */
  38983. export class GamepadCamera extends UniversalCamera {
  38984. /**
  38985. * Instantiates a new Gamepad Camera
  38986. * This represents a FPS type of camera. This is only here for back compat purpose.
  38987. * Please use the UniversalCamera instead as both are identical.
  38988. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38989. * @param name Define the name of the camera in the scene
  38990. * @param position Define the start position of the camera in the scene
  38991. * @param scene Define the scene the camera belongs to
  38992. */
  38993. constructor(name: string, position: Vector3, scene: Scene);
  38994. /**
  38995. * Gets the current object class name.
  38996. * @return the class name
  38997. */
  38998. getClassName(): string;
  38999. }
  39000. }
  39001. declare module "babylonjs/Shaders/pass.fragment" {
  39002. /** @hidden */
  39003. export var passPixelShader: {
  39004. name: string;
  39005. shader: string;
  39006. };
  39007. }
  39008. declare module "babylonjs/Shaders/passCube.fragment" {
  39009. /** @hidden */
  39010. export var passCubePixelShader: {
  39011. name: string;
  39012. shader: string;
  39013. };
  39014. }
  39015. declare module "babylonjs/PostProcesses/passPostProcess" {
  39016. import { Nullable } from "babylonjs/types";
  39017. import { Camera } from "babylonjs/Cameras/camera";
  39018. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  39019. import { Engine } from "babylonjs/Engines/engine";
  39020. import "babylonjs/Shaders/pass.fragment";
  39021. import "babylonjs/Shaders/passCube.fragment";
  39022. /**
  39023. * PassPostProcess which produces an output the same as it's input
  39024. */
  39025. export class PassPostProcess extends PostProcess {
  39026. /**
  39027. * Creates the PassPostProcess
  39028. * @param name The name of the effect.
  39029. * @param options The required width/height ratio to downsize to before computing the render pass.
  39030. * @param camera The camera to apply the render pass to.
  39031. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39032. * @param engine The engine which the post process will be applied. (default: current engine)
  39033. * @param reusable If the post process can be reused on the same frame. (default: false)
  39034. * @param textureType The type of texture to be used when performing the post processing.
  39035. * @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)
  39036. */
  39037. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39038. }
  39039. /**
  39040. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  39041. */
  39042. export class PassCubePostProcess extends PostProcess {
  39043. private _face;
  39044. /**
  39045. * Gets or sets the cube face to display.
  39046. * * 0 is +X
  39047. * * 1 is -X
  39048. * * 2 is +Y
  39049. * * 3 is -Y
  39050. * * 4 is +Z
  39051. * * 5 is -Z
  39052. */
  39053. face: number;
  39054. /**
  39055. * Creates the PassCubePostProcess
  39056. * @param name The name of the effect.
  39057. * @param options The required width/height ratio to downsize to before computing the render pass.
  39058. * @param camera The camera to apply the render pass to.
  39059. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39060. * @param engine The engine which the post process will be applied. (default: current engine)
  39061. * @param reusable If the post process can be reused on the same frame. (default: false)
  39062. * @param textureType The type of texture to be used when performing the post processing.
  39063. * @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)
  39064. */
  39065. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39066. }
  39067. }
  39068. declare module "babylonjs/Shaders/anaglyph.fragment" {
  39069. /** @hidden */
  39070. export var anaglyphPixelShader: {
  39071. name: string;
  39072. shader: string;
  39073. };
  39074. }
  39075. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  39076. import { Engine } from "babylonjs/Engines/engine";
  39077. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  39078. import { Camera } from "babylonjs/Cameras/camera";
  39079. import "babylonjs/Shaders/anaglyph.fragment";
  39080. /**
  39081. * Postprocess used to generate anaglyphic rendering
  39082. */
  39083. export class AnaglyphPostProcess extends PostProcess {
  39084. private _passedProcess;
  39085. /**
  39086. * Creates a new AnaglyphPostProcess
  39087. * @param name defines postprocess name
  39088. * @param options defines creation options or target ratio scale
  39089. * @param rigCameras defines cameras using this postprocess
  39090. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  39091. * @param engine defines hosting engine
  39092. * @param reusable defines if the postprocess will be reused multiple times per frame
  39093. */
  39094. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  39095. }
  39096. }
  39097. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  39098. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  39099. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39100. import { Scene } from "babylonjs/scene";
  39101. import { Vector3 } from "babylonjs/Maths/math";
  39102. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  39103. /**
  39104. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  39105. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39106. */
  39107. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  39108. /**
  39109. * Creates a new AnaglyphArcRotateCamera
  39110. * @param name defines camera name
  39111. * @param alpha defines alpha angle (in radians)
  39112. * @param beta defines beta angle (in radians)
  39113. * @param radius defines radius
  39114. * @param target defines camera target
  39115. * @param interaxialDistance defines distance between each color axis
  39116. * @param scene defines the hosting scene
  39117. */
  39118. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  39119. /**
  39120. * Gets camera class name
  39121. * @returns AnaglyphArcRotateCamera
  39122. */
  39123. getClassName(): string;
  39124. }
  39125. }
  39126. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  39127. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39128. import { Scene } from "babylonjs/scene";
  39129. import { Vector3 } from "babylonjs/Maths/math";
  39130. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  39131. /**
  39132. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  39133. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39134. */
  39135. export class AnaglyphFreeCamera extends FreeCamera {
  39136. /**
  39137. * Creates a new AnaglyphFreeCamera
  39138. * @param name defines camera name
  39139. * @param position defines initial position
  39140. * @param interaxialDistance defines distance between each color axis
  39141. * @param scene defines the hosting scene
  39142. */
  39143. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39144. /**
  39145. * Gets camera class name
  39146. * @returns AnaglyphFreeCamera
  39147. */
  39148. getClassName(): string;
  39149. }
  39150. }
  39151. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  39152. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  39153. import { Scene } from "babylonjs/scene";
  39154. import { Vector3 } from "babylonjs/Maths/math";
  39155. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  39156. /**
  39157. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  39158. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39159. */
  39160. export class AnaglyphGamepadCamera extends GamepadCamera {
  39161. /**
  39162. * Creates a new AnaglyphGamepadCamera
  39163. * @param name defines camera name
  39164. * @param position defines initial position
  39165. * @param interaxialDistance defines distance between each color axis
  39166. * @param scene defines the hosting scene
  39167. */
  39168. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39169. /**
  39170. * Gets camera class name
  39171. * @returns AnaglyphGamepadCamera
  39172. */
  39173. getClassName(): string;
  39174. }
  39175. }
  39176. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  39177. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  39178. import { Scene } from "babylonjs/scene";
  39179. import { Vector3 } from "babylonjs/Maths/math";
  39180. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  39181. /**
  39182. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  39183. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39184. */
  39185. export class AnaglyphUniversalCamera extends UniversalCamera {
  39186. /**
  39187. * Creates a new AnaglyphUniversalCamera
  39188. * @param name defines camera name
  39189. * @param position defines initial position
  39190. * @param interaxialDistance defines distance between each color axis
  39191. * @param scene defines the hosting scene
  39192. */
  39193. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39194. /**
  39195. * Gets camera class name
  39196. * @returns AnaglyphUniversalCamera
  39197. */
  39198. getClassName(): string;
  39199. }
  39200. }
  39201. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  39202. /** @hidden */
  39203. export var stereoscopicInterlacePixelShader: {
  39204. name: string;
  39205. shader: string;
  39206. };
  39207. }
  39208. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  39209. import { Camera } from "babylonjs/Cameras/camera";
  39210. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  39211. import { Engine } from "babylonjs/Engines/engine";
  39212. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  39213. /**
  39214. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  39215. */
  39216. export class StereoscopicInterlacePostProcess extends PostProcess {
  39217. private _stepSize;
  39218. private _passedProcess;
  39219. /**
  39220. * Initializes a StereoscopicInterlacePostProcess
  39221. * @param name The name of the effect.
  39222. * @param rigCameras The rig cameras to be appled to the post process
  39223. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  39224. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39225. * @param engine The engine which the post process will be applied. (default: current engine)
  39226. * @param reusable If the post process can be reused on the same frame. (default: false)
  39227. */
  39228. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  39229. }
  39230. }
  39231. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  39232. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  39233. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39234. import { Scene } from "babylonjs/scene";
  39235. import { Vector3 } from "babylonjs/Maths/math";
  39236. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  39237. /**
  39238. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  39239. * @see http://doc.babylonjs.com/features/cameras
  39240. */
  39241. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  39242. /**
  39243. * Creates a new StereoscopicArcRotateCamera
  39244. * @param name defines camera name
  39245. * @param alpha defines alpha angle (in radians)
  39246. * @param beta defines beta angle (in radians)
  39247. * @param radius defines radius
  39248. * @param target defines camera target
  39249. * @param interaxialDistance defines distance between each color axis
  39250. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39251. * @param scene defines the hosting scene
  39252. */
  39253. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39254. /**
  39255. * Gets camera class name
  39256. * @returns StereoscopicArcRotateCamera
  39257. */
  39258. getClassName(): string;
  39259. }
  39260. }
  39261. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  39262. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39263. import { Scene } from "babylonjs/scene";
  39264. import { Vector3 } from "babylonjs/Maths/math";
  39265. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  39266. /**
  39267. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  39268. * @see http://doc.babylonjs.com/features/cameras
  39269. */
  39270. export class StereoscopicFreeCamera extends FreeCamera {
  39271. /**
  39272. * Creates a new StereoscopicFreeCamera
  39273. * @param name defines camera name
  39274. * @param position defines initial position
  39275. * @param interaxialDistance defines distance between each color axis
  39276. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39277. * @param scene defines the hosting scene
  39278. */
  39279. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39280. /**
  39281. * Gets camera class name
  39282. * @returns StereoscopicFreeCamera
  39283. */
  39284. getClassName(): string;
  39285. }
  39286. }
  39287. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  39288. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  39289. import { Scene } from "babylonjs/scene";
  39290. import { Vector3 } from "babylonjs/Maths/math";
  39291. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  39292. /**
  39293. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  39294. * @see http://doc.babylonjs.com/features/cameras
  39295. */
  39296. export class StereoscopicGamepadCamera extends GamepadCamera {
  39297. /**
  39298. * Creates a new StereoscopicGamepadCamera
  39299. * @param name defines camera name
  39300. * @param position defines initial position
  39301. * @param interaxialDistance defines distance between each color axis
  39302. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39303. * @param scene defines the hosting scene
  39304. */
  39305. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39306. /**
  39307. * Gets camera class name
  39308. * @returns StereoscopicGamepadCamera
  39309. */
  39310. getClassName(): string;
  39311. }
  39312. }
  39313. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  39314. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  39315. import { Scene } from "babylonjs/scene";
  39316. import { Vector3 } from "babylonjs/Maths/math";
  39317. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  39318. /**
  39319. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  39320. * @see http://doc.babylonjs.com/features/cameras
  39321. */
  39322. export class StereoscopicUniversalCamera extends UniversalCamera {
  39323. /**
  39324. * Creates a new StereoscopicUniversalCamera
  39325. * @param name defines camera name
  39326. * @param position defines initial position
  39327. * @param interaxialDistance defines distance between each color axis
  39328. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39329. * @param scene defines the hosting scene
  39330. */
  39331. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39332. /**
  39333. * Gets camera class name
  39334. * @returns StereoscopicUniversalCamera
  39335. */
  39336. getClassName(): string;
  39337. }
  39338. }
  39339. declare module "babylonjs/Cameras/Stereoscopic/index" {
  39340. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  39341. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  39342. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  39343. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  39344. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  39345. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  39346. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  39347. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  39348. }
  39349. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  39350. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39351. import { Scene } from "babylonjs/scene";
  39352. import { Vector3 } from "babylonjs/Maths/math";
  39353. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  39354. /**
  39355. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  39356. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  39357. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  39358. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  39359. */
  39360. export class VirtualJoysticksCamera extends FreeCamera {
  39361. /**
  39362. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  39363. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  39364. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  39365. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  39366. * @param name Define the name of the camera in the scene
  39367. * @param position Define the start position of the camera in the scene
  39368. * @param scene Define the scene the camera belongs to
  39369. */
  39370. constructor(name: string, position: Vector3, scene: Scene);
  39371. /**
  39372. * Gets the current object class name.
  39373. * @return the class name
  39374. */
  39375. getClassName(): string;
  39376. }
  39377. }
  39378. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  39379. import { Matrix } from "babylonjs/Maths/math";
  39380. /**
  39381. * This represents all the required metrics to create a VR camera.
  39382. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  39383. */
  39384. export class VRCameraMetrics {
  39385. /**
  39386. * Define the horizontal resolution off the screen.
  39387. */
  39388. hResolution: number;
  39389. /**
  39390. * Define the vertical resolution off the screen.
  39391. */
  39392. vResolution: number;
  39393. /**
  39394. * Define the horizontal screen size.
  39395. */
  39396. hScreenSize: number;
  39397. /**
  39398. * Define the vertical screen size.
  39399. */
  39400. vScreenSize: number;
  39401. /**
  39402. * Define the vertical screen center position.
  39403. */
  39404. vScreenCenter: number;
  39405. /**
  39406. * Define the distance of the eyes to the screen.
  39407. */
  39408. eyeToScreenDistance: number;
  39409. /**
  39410. * Define the distance between both lenses
  39411. */
  39412. lensSeparationDistance: number;
  39413. /**
  39414. * Define the distance between both viewer's eyes.
  39415. */
  39416. interpupillaryDistance: number;
  39417. /**
  39418. * Define the distortion factor of the VR postprocess.
  39419. * Please, touch with care.
  39420. */
  39421. distortionK: number[];
  39422. /**
  39423. * Define the chromatic aberration correction factors for the VR post process.
  39424. */
  39425. chromaAbCorrection: number[];
  39426. /**
  39427. * Define the scale factor of the post process.
  39428. * The smaller the better but the slower.
  39429. */
  39430. postProcessScaleFactor: number;
  39431. /**
  39432. * Define an offset for the lens center.
  39433. */
  39434. lensCenterOffset: number;
  39435. /**
  39436. * Define if the current vr camera should compensate the distortion of the lense or not.
  39437. */
  39438. compensateDistortion: boolean;
  39439. /**
  39440. * Defines if multiview should be enabled when rendering (Default: false)
  39441. */
  39442. multiviewEnabled: boolean;
  39443. /**
  39444. * Gets the rendering aspect ratio based on the provided resolutions.
  39445. */
  39446. readonly aspectRatio: number;
  39447. /**
  39448. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  39449. */
  39450. readonly aspectRatioFov: number;
  39451. /**
  39452. * @hidden
  39453. */
  39454. readonly leftHMatrix: Matrix;
  39455. /**
  39456. * @hidden
  39457. */
  39458. readonly rightHMatrix: Matrix;
  39459. /**
  39460. * @hidden
  39461. */
  39462. readonly leftPreViewMatrix: Matrix;
  39463. /**
  39464. * @hidden
  39465. */
  39466. readonly rightPreViewMatrix: Matrix;
  39467. /**
  39468. * Get the default VRMetrics based on the most generic setup.
  39469. * @returns the default vr metrics
  39470. */
  39471. static GetDefault(): VRCameraMetrics;
  39472. }
  39473. }
  39474. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  39475. /** @hidden */
  39476. export var vrDistortionCorrectionPixelShader: {
  39477. name: string;
  39478. shader: string;
  39479. };
  39480. }
  39481. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  39482. import { Camera } from "babylonjs/Cameras/camera";
  39483. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39484. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  39485. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  39486. /**
  39487. * VRDistortionCorrectionPostProcess used for mobile VR
  39488. */
  39489. export class VRDistortionCorrectionPostProcess extends PostProcess {
  39490. private _isRightEye;
  39491. private _distortionFactors;
  39492. private _postProcessScaleFactor;
  39493. private _lensCenterOffset;
  39494. private _scaleIn;
  39495. private _scaleFactor;
  39496. private _lensCenter;
  39497. /**
  39498. * Initializes the VRDistortionCorrectionPostProcess
  39499. * @param name The name of the effect.
  39500. * @param camera The camera to apply the render pass to.
  39501. * @param isRightEye If this is for the right eye distortion
  39502. * @param vrMetrics All the required metrics for the VR camera
  39503. */
  39504. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  39505. }
  39506. }
  39507. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  39508. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  39509. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39510. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39511. import { Scene } from "babylonjs/scene";
  39512. import { Vector3 } from "babylonjs/Maths/math";
  39513. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  39514. import "babylonjs/Cameras/RigModes/vrRigMode";
  39515. /**
  39516. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  39517. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39518. */
  39519. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  39520. /**
  39521. * Creates a new VRDeviceOrientationArcRotateCamera
  39522. * @param name defines camera name
  39523. * @param alpha defines the camera rotation along the logitudinal axis
  39524. * @param beta defines the camera rotation along the latitudinal axis
  39525. * @param radius defines the camera distance from its target
  39526. * @param target defines the camera target
  39527. * @param scene defines the scene the camera belongs to
  39528. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39529. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39530. */
  39531. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39532. /**
  39533. * Gets camera class name
  39534. * @returns VRDeviceOrientationArcRotateCamera
  39535. */
  39536. getClassName(): string;
  39537. }
  39538. }
  39539. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  39540. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  39541. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39542. import { Scene } from "babylonjs/scene";
  39543. import { Vector3 } from "babylonjs/Maths/math";
  39544. import "babylonjs/Cameras/RigModes/vrRigMode";
  39545. /**
  39546. * Camera used to simulate VR rendering (based on FreeCamera)
  39547. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39548. */
  39549. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  39550. /**
  39551. * Creates a new VRDeviceOrientationFreeCamera
  39552. * @param name defines camera name
  39553. * @param position defines the start position of the camera
  39554. * @param scene defines the scene the camera belongs to
  39555. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39556. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39557. */
  39558. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39559. /**
  39560. * Gets camera class name
  39561. * @returns VRDeviceOrientationFreeCamera
  39562. */
  39563. getClassName(): string;
  39564. }
  39565. }
  39566. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  39567. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  39568. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39569. import { Scene } from "babylonjs/scene";
  39570. import { Vector3 } from "babylonjs/Maths/math";
  39571. import "babylonjs/Gamepads/gamepadSceneComponent";
  39572. /**
  39573. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  39574. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39575. */
  39576. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  39577. /**
  39578. * Creates a new VRDeviceOrientationGamepadCamera
  39579. * @param name defines camera name
  39580. * @param position defines the start position of the camera
  39581. * @param scene defines the scene the camera belongs to
  39582. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39583. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39584. */
  39585. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39586. /**
  39587. * Gets camera class name
  39588. * @returns VRDeviceOrientationGamepadCamera
  39589. */
  39590. getClassName(): string;
  39591. }
  39592. }
  39593. declare module "babylonjs/Materials/pushMaterial" {
  39594. import { Nullable } from "babylonjs/types";
  39595. import { Scene } from "babylonjs/scene";
  39596. import { Matrix } from "babylonjs/Maths/math";
  39597. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39598. import { Mesh } from "babylonjs/Meshes/mesh";
  39599. import { Material } from "babylonjs/Materials/material";
  39600. import { Effect } from "babylonjs/Materials/effect";
  39601. /**
  39602. * Base class of materials working in push mode in babylon JS
  39603. * @hidden
  39604. */
  39605. export class PushMaterial extends Material {
  39606. protected _activeEffect: Effect;
  39607. protected _normalMatrix: Matrix;
  39608. /**
  39609. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  39610. * This means that the material can keep using a previous shader while a new one is being compiled.
  39611. * This is mostly used when shader parallel compilation is supported (true by default)
  39612. */
  39613. allowShaderHotSwapping: boolean;
  39614. constructor(name: string, scene: Scene);
  39615. getEffect(): Effect;
  39616. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  39617. /**
  39618. * Binds the given world matrix to the active effect
  39619. *
  39620. * @param world the matrix to bind
  39621. */
  39622. bindOnlyWorldMatrix(world: Matrix): void;
  39623. /**
  39624. * Binds the given normal matrix to the active effect
  39625. *
  39626. * @param normalMatrix the matrix to bind
  39627. */
  39628. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  39629. bind(world: Matrix, mesh?: Mesh): void;
  39630. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  39631. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  39632. }
  39633. }
  39634. declare module "babylonjs/Materials/materialFlags" {
  39635. /**
  39636. * This groups all the flags used to control the materials channel.
  39637. */
  39638. export class MaterialFlags {
  39639. private static _DiffuseTextureEnabled;
  39640. /**
  39641. * Are diffuse textures enabled in the application.
  39642. */
  39643. static DiffuseTextureEnabled: boolean;
  39644. private static _AmbientTextureEnabled;
  39645. /**
  39646. * Are ambient textures enabled in the application.
  39647. */
  39648. static AmbientTextureEnabled: boolean;
  39649. private static _OpacityTextureEnabled;
  39650. /**
  39651. * Are opacity textures enabled in the application.
  39652. */
  39653. static OpacityTextureEnabled: boolean;
  39654. private static _ReflectionTextureEnabled;
  39655. /**
  39656. * Are reflection textures enabled in the application.
  39657. */
  39658. static ReflectionTextureEnabled: boolean;
  39659. private static _EmissiveTextureEnabled;
  39660. /**
  39661. * Are emissive textures enabled in the application.
  39662. */
  39663. static EmissiveTextureEnabled: boolean;
  39664. private static _SpecularTextureEnabled;
  39665. /**
  39666. * Are specular textures enabled in the application.
  39667. */
  39668. static SpecularTextureEnabled: boolean;
  39669. private static _BumpTextureEnabled;
  39670. /**
  39671. * Are bump textures enabled in the application.
  39672. */
  39673. static BumpTextureEnabled: boolean;
  39674. private static _LightmapTextureEnabled;
  39675. /**
  39676. * Are lightmap textures enabled in the application.
  39677. */
  39678. static LightmapTextureEnabled: boolean;
  39679. private static _RefractionTextureEnabled;
  39680. /**
  39681. * Are refraction textures enabled in the application.
  39682. */
  39683. static RefractionTextureEnabled: boolean;
  39684. private static _ColorGradingTextureEnabled;
  39685. /**
  39686. * Are color grading textures enabled in the application.
  39687. */
  39688. static ColorGradingTextureEnabled: boolean;
  39689. private static _FresnelEnabled;
  39690. /**
  39691. * Are fresnels enabled in the application.
  39692. */
  39693. static FresnelEnabled: boolean;
  39694. private static _ClearCoatTextureEnabled;
  39695. /**
  39696. * Are clear coat textures enabled in the application.
  39697. */
  39698. static ClearCoatTextureEnabled: boolean;
  39699. private static _ClearCoatBumpTextureEnabled;
  39700. /**
  39701. * Are clear coat bump textures enabled in the application.
  39702. */
  39703. static ClearCoatBumpTextureEnabled: boolean;
  39704. private static _ClearCoatTintTextureEnabled;
  39705. /**
  39706. * Are clear coat tint textures enabled in the application.
  39707. */
  39708. static ClearCoatTintTextureEnabled: boolean;
  39709. private static _SheenTextureEnabled;
  39710. /**
  39711. * Are sheen textures enabled in the application.
  39712. */
  39713. static SheenTextureEnabled: boolean;
  39714. private static _AnisotropicTextureEnabled;
  39715. /**
  39716. * Are anisotropic textures enabled in the application.
  39717. */
  39718. static AnisotropicTextureEnabled: boolean;
  39719. private static _ThicknessTextureEnabled;
  39720. /**
  39721. * Are thickness textures enabled in the application.
  39722. */
  39723. static ThicknessTextureEnabled: boolean;
  39724. }
  39725. }
  39726. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  39727. /** @hidden */
  39728. export var defaultFragmentDeclaration: {
  39729. name: string;
  39730. shader: string;
  39731. };
  39732. }
  39733. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  39734. /** @hidden */
  39735. export var defaultUboDeclaration: {
  39736. name: string;
  39737. shader: string;
  39738. };
  39739. }
  39740. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  39741. /** @hidden */
  39742. export var lightFragmentDeclaration: {
  39743. name: string;
  39744. shader: string;
  39745. };
  39746. }
  39747. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  39748. /** @hidden */
  39749. export var lightUboDeclaration: {
  39750. name: string;
  39751. shader: string;
  39752. };
  39753. }
  39754. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  39755. /** @hidden */
  39756. export var lightsFragmentFunctions: {
  39757. name: string;
  39758. shader: string;
  39759. };
  39760. }
  39761. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  39762. /** @hidden */
  39763. export var shadowsFragmentFunctions: {
  39764. name: string;
  39765. shader: string;
  39766. };
  39767. }
  39768. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  39769. /** @hidden */
  39770. export var fresnelFunction: {
  39771. name: string;
  39772. shader: string;
  39773. };
  39774. }
  39775. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  39776. /** @hidden */
  39777. export var reflectionFunction: {
  39778. name: string;
  39779. shader: string;
  39780. };
  39781. }
  39782. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  39783. /** @hidden */
  39784. export var bumpFragmentFunctions: {
  39785. name: string;
  39786. shader: string;
  39787. };
  39788. }
  39789. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  39790. /** @hidden */
  39791. export var logDepthDeclaration: {
  39792. name: string;
  39793. shader: string;
  39794. };
  39795. }
  39796. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  39797. /** @hidden */
  39798. export var bumpFragment: {
  39799. name: string;
  39800. shader: string;
  39801. };
  39802. }
  39803. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  39804. /** @hidden */
  39805. export var depthPrePass: {
  39806. name: string;
  39807. shader: string;
  39808. };
  39809. }
  39810. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  39811. /** @hidden */
  39812. export var lightFragment: {
  39813. name: string;
  39814. shader: string;
  39815. };
  39816. }
  39817. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  39818. /** @hidden */
  39819. export var logDepthFragment: {
  39820. name: string;
  39821. shader: string;
  39822. };
  39823. }
  39824. declare module "babylonjs/Shaders/default.fragment" {
  39825. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  39826. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  39827. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  39828. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  39829. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  39830. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  39831. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  39832. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  39833. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  39834. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  39835. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  39836. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  39837. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  39838. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  39839. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  39840. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  39841. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  39842. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  39843. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  39844. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  39845. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  39846. /** @hidden */
  39847. export var defaultPixelShader: {
  39848. name: string;
  39849. shader: string;
  39850. };
  39851. }
  39852. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  39853. /** @hidden */
  39854. export var defaultVertexDeclaration: {
  39855. name: string;
  39856. shader: string;
  39857. };
  39858. }
  39859. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  39860. /** @hidden */
  39861. export var bumpVertexDeclaration: {
  39862. name: string;
  39863. shader: string;
  39864. };
  39865. }
  39866. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  39867. /** @hidden */
  39868. export var bumpVertex: {
  39869. name: string;
  39870. shader: string;
  39871. };
  39872. }
  39873. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  39874. /** @hidden */
  39875. export var fogVertex: {
  39876. name: string;
  39877. shader: string;
  39878. };
  39879. }
  39880. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  39881. /** @hidden */
  39882. export var shadowsVertex: {
  39883. name: string;
  39884. shader: string;
  39885. };
  39886. }
  39887. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  39888. /** @hidden */
  39889. export var pointCloudVertex: {
  39890. name: string;
  39891. shader: string;
  39892. };
  39893. }
  39894. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  39895. /** @hidden */
  39896. export var logDepthVertex: {
  39897. name: string;
  39898. shader: string;
  39899. };
  39900. }
  39901. declare module "babylonjs/Shaders/default.vertex" {
  39902. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  39903. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  39904. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  39905. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  39906. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  39907. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  39908. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  39909. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  39910. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  39911. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  39912. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  39913. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  39914. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  39915. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  39916. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  39917. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  39918. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  39919. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  39920. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  39921. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  39922. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  39923. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  39924. /** @hidden */
  39925. export var defaultVertexShader: {
  39926. name: string;
  39927. shader: string;
  39928. };
  39929. }
  39930. declare module "babylonjs/Materials/standardMaterial" {
  39931. import { SmartArray } from "babylonjs/Misc/smartArray";
  39932. import { IAnimatable } from "babylonjs/Misc/tools";
  39933. import { Nullable } from "babylonjs/types";
  39934. import { Scene } from "babylonjs/scene";
  39935. import { Matrix, Color3 } from "babylonjs/Maths/math";
  39936. import { SubMesh } from "babylonjs/Meshes/subMesh";
  39937. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39938. import { Mesh } from "babylonjs/Meshes/mesh";
  39939. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  39940. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  39941. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  39942. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  39943. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  39944. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  39945. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  39946. import "babylonjs/Shaders/default.fragment";
  39947. import "babylonjs/Shaders/default.vertex";
  39948. /** @hidden */
  39949. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  39950. MAINUV1: boolean;
  39951. MAINUV2: boolean;
  39952. DIFFUSE: boolean;
  39953. DIFFUSEDIRECTUV: number;
  39954. AMBIENT: boolean;
  39955. AMBIENTDIRECTUV: number;
  39956. OPACITY: boolean;
  39957. OPACITYDIRECTUV: number;
  39958. OPACITYRGB: boolean;
  39959. REFLECTION: boolean;
  39960. EMISSIVE: boolean;
  39961. EMISSIVEDIRECTUV: number;
  39962. SPECULAR: boolean;
  39963. SPECULARDIRECTUV: number;
  39964. BUMP: boolean;
  39965. BUMPDIRECTUV: number;
  39966. PARALLAX: boolean;
  39967. PARALLAXOCCLUSION: boolean;
  39968. SPECULAROVERALPHA: boolean;
  39969. CLIPPLANE: boolean;
  39970. CLIPPLANE2: boolean;
  39971. CLIPPLANE3: boolean;
  39972. CLIPPLANE4: boolean;
  39973. ALPHATEST: boolean;
  39974. DEPTHPREPASS: boolean;
  39975. ALPHAFROMDIFFUSE: boolean;
  39976. POINTSIZE: boolean;
  39977. FOG: boolean;
  39978. SPECULARTERM: boolean;
  39979. DIFFUSEFRESNEL: boolean;
  39980. OPACITYFRESNEL: boolean;
  39981. REFLECTIONFRESNEL: boolean;
  39982. REFRACTIONFRESNEL: boolean;
  39983. EMISSIVEFRESNEL: boolean;
  39984. FRESNEL: boolean;
  39985. NORMAL: boolean;
  39986. UV1: boolean;
  39987. UV2: boolean;
  39988. VERTEXCOLOR: boolean;
  39989. VERTEXALPHA: boolean;
  39990. NUM_BONE_INFLUENCERS: number;
  39991. BonesPerMesh: number;
  39992. BONETEXTURE: boolean;
  39993. INSTANCES: boolean;
  39994. GLOSSINESS: boolean;
  39995. ROUGHNESS: boolean;
  39996. EMISSIVEASILLUMINATION: boolean;
  39997. LINKEMISSIVEWITHDIFFUSE: boolean;
  39998. REFLECTIONFRESNELFROMSPECULAR: boolean;
  39999. LIGHTMAP: boolean;
  40000. LIGHTMAPDIRECTUV: number;
  40001. OBJECTSPACE_NORMALMAP: boolean;
  40002. USELIGHTMAPASSHADOWMAP: boolean;
  40003. REFLECTIONMAP_3D: boolean;
  40004. REFLECTIONMAP_SPHERICAL: boolean;
  40005. REFLECTIONMAP_PLANAR: boolean;
  40006. REFLECTIONMAP_CUBIC: boolean;
  40007. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  40008. REFLECTIONMAP_PROJECTION: boolean;
  40009. REFLECTIONMAP_SKYBOX: boolean;
  40010. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  40011. REFLECTIONMAP_EXPLICIT: boolean;
  40012. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  40013. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  40014. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  40015. INVERTCUBICMAP: boolean;
  40016. LOGARITHMICDEPTH: boolean;
  40017. REFRACTION: boolean;
  40018. REFRACTIONMAP_3D: boolean;
  40019. REFLECTIONOVERALPHA: boolean;
  40020. TWOSIDEDLIGHTING: boolean;
  40021. SHADOWFLOAT: boolean;
  40022. MORPHTARGETS: boolean;
  40023. MORPHTARGETS_NORMAL: boolean;
  40024. MORPHTARGETS_TANGENT: boolean;
  40025. NUM_MORPH_INFLUENCERS: number;
  40026. NONUNIFORMSCALING: boolean;
  40027. PREMULTIPLYALPHA: boolean;
  40028. IMAGEPROCESSING: boolean;
  40029. VIGNETTE: boolean;
  40030. VIGNETTEBLENDMODEMULTIPLY: boolean;
  40031. VIGNETTEBLENDMODEOPAQUE: boolean;
  40032. TONEMAPPING: boolean;
  40033. TONEMAPPING_ACES: boolean;
  40034. CONTRAST: boolean;
  40035. COLORCURVES: boolean;
  40036. COLORGRADING: boolean;
  40037. COLORGRADING3D: boolean;
  40038. SAMPLER3DGREENDEPTH: boolean;
  40039. SAMPLER3DBGRMAP: boolean;
  40040. IMAGEPROCESSINGPOSTPROCESS: boolean;
  40041. MULTIVIEW: boolean;
  40042. /**
  40043. * If the reflection texture on this material is in linear color space
  40044. * @hidden
  40045. */
  40046. IS_REFLECTION_LINEAR: boolean;
  40047. /**
  40048. * If the refraction texture on this material is in linear color space
  40049. * @hidden
  40050. */
  40051. IS_REFRACTION_LINEAR: boolean;
  40052. EXPOSURE: boolean;
  40053. constructor();
  40054. setReflectionMode(modeToEnable: string): void;
  40055. }
  40056. /**
  40057. * This is the default material used in Babylon. It is the best trade off between quality
  40058. * and performances.
  40059. * @see http://doc.babylonjs.com/babylon101/materials
  40060. */
  40061. export class StandardMaterial extends PushMaterial {
  40062. private _diffuseTexture;
  40063. /**
  40064. * The basic texture of the material as viewed under a light.
  40065. */
  40066. diffuseTexture: Nullable<BaseTexture>;
  40067. private _ambientTexture;
  40068. /**
  40069. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  40070. */
  40071. ambientTexture: Nullable<BaseTexture>;
  40072. private _opacityTexture;
  40073. /**
  40074. * Define the transparency of the material from a texture.
  40075. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  40076. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  40077. */
  40078. opacityTexture: Nullable<BaseTexture>;
  40079. private _reflectionTexture;
  40080. /**
  40081. * Define the texture used to display the reflection.
  40082. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40083. */
  40084. reflectionTexture: Nullable<BaseTexture>;
  40085. private _emissiveTexture;
  40086. /**
  40087. * Define texture of the material as if self lit.
  40088. * This will be mixed in the final result even in the absence of light.
  40089. */
  40090. emissiveTexture: Nullable<BaseTexture>;
  40091. private _specularTexture;
  40092. /**
  40093. * Define how the color and intensity of the highlight given by the light in the material.
  40094. */
  40095. specularTexture: Nullable<BaseTexture>;
  40096. private _bumpTexture;
  40097. /**
  40098. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  40099. * 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.
  40100. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  40101. */
  40102. bumpTexture: Nullable<BaseTexture>;
  40103. private _lightmapTexture;
  40104. /**
  40105. * Complex lighting can be computationally expensive to compute at runtime.
  40106. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  40107. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  40108. */
  40109. lightmapTexture: Nullable<BaseTexture>;
  40110. private _refractionTexture;
  40111. /**
  40112. * Define the texture used to display the refraction.
  40113. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40114. */
  40115. refractionTexture: Nullable<BaseTexture>;
  40116. /**
  40117. * The color of the material lit by the environmental background lighting.
  40118. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  40119. */
  40120. ambientColor: Color3;
  40121. /**
  40122. * The basic color of the material as viewed under a light.
  40123. */
  40124. diffuseColor: Color3;
  40125. /**
  40126. * Define how the color and intensity of the highlight given by the light in the material.
  40127. */
  40128. specularColor: Color3;
  40129. /**
  40130. * Define the color of the material as if self lit.
  40131. * This will be mixed in the final result even in the absence of light.
  40132. */
  40133. emissiveColor: Color3;
  40134. /**
  40135. * Defines how sharp are the highlights in the material.
  40136. * The bigger the value the sharper giving a more glossy feeling to the result.
  40137. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  40138. */
  40139. specularPower: number;
  40140. private _useAlphaFromDiffuseTexture;
  40141. /**
  40142. * Does the transparency come from the diffuse texture alpha channel.
  40143. */
  40144. useAlphaFromDiffuseTexture: boolean;
  40145. private _useEmissiveAsIllumination;
  40146. /**
  40147. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  40148. */
  40149. useEmissiveAsIllumination: boolean;
  40150. private _linkEmissiveWithDiffuse;
  40151. /**
  40152. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  40153. * the emissive level when the final color is close to one.
  40154. */
  40155. linkEmissiveWithDiffuse: boolean;
  40156. private _useSpecularOverAlpha;
  40157. /**
  40158. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  40159. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  40160. */
  40161. useSpecularOverAlpha: boolean;
  40162. private _useReflectionOverAlpha;
  40163. /**
  40164. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  40165. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  40166. */
  40167. useReflectionOverAlpha: boolean;
  40168. private _disableLighting;
  40169. /**
  40170. * Does lights from the scene impacts this material.
  40171. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  40172. */
  40173. disableLighting: boolean;
  40174. private _useObjectSpaceNormalMap;
  40175. /**
  40176. * Allows using an object space normal map (instead of tangent space).
  40177. */
  40178. useObjectSpaceNormalMap: boolean;
  40179. private _useParallax;
  40180. /**
  40181. * Is parallax enabled or not.
  40182. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40183. */
  40184. useParallax: boolean;
  40185. private _useParallaxOcclusion;
  40186. /**
  40187. * Is parallax occlusion enabled or not.
  40188. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  40189. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40190. */
  40191. useParallaxOcclusion: boolean;
  40192. /**
  40193. * 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.
  40194. */
  40195. parallaxScaleBias: number;
  40196. private _roughness;
  40197. /**
  40198. * Helps to define how blurry the reflections should appears in the material.
  40199. */
  40200. roughness: number;
  40201. /**
  40202. * In case of refraction, define the value of the indice of refraction.
  40203. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40204. */
  40205. indexOfRefraction: number;
  40206. /**
  40207. * Invert the refraction texture alongside the y axis.
  40208. * It can be useful with procedural textures or probe for instance.
  40209. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40210. */
  40211. invertRefractionY: boolean;
  40212. /**
  40213. * Defines the alpha limits in alpha test mode.
  40214. */
  40215. alphaCutOff: number;
  40216. private _useLightmapAsShadowmap;
  40217. /**
  40218. * In case of light mapping, define whether the map contains light or shadow informations.
  40219. */
  40220. useLightmapAsShadowmap: boolean;
  40221. private _diffuseFresnelParameters;
  40222. /**
  40223. * Define the diffuse fresnel parameters of the material.
  40224. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40225. */
  40226. diffuseFresnelParameters: FresnelParameters;
  40227. private _opacityFresnelParameters;
  40228. /**
  40229. * Define the opacity fresnel parameters of the material.
  40230. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40231. */
  40232. opacityFresnelParameters: FresnelParameters;
  40233. private _reflectionFresnelParameters;
  40234. /**
  40235. * Define the reflection fresnel parameters of the material.
  40236. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40237. */
  40238. reflectionFresnelParameters: FresnelParameters;
  40239. private _refractionFresnelParameters;
  40240. /**
  40241. * Define the refraction fresnel parameters of the material.
  40242. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40243. */
  40244. refractionFresnelParameters: FresnelParameters;
  40245. private _emissiveFresnelParameters;
  40246. /**
  40247. * Define the emissive fresnel parameters of the material.
  40248. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40249. */
  40250. emissiveFresnelParameters: FresnelParameters;
  40251. private _useReflectionFresnelFromSpecular;
  40252. /**
  40253. * If true automatically deducts the fresnels values from the material specularity.
  40254. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40255. */
  40256. useReflectionFresnelFromSpecular: boolean;
  40257. private _useGlossinessFromSpecularMapAlpha;
  40258. /**
  40259. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  40260. */
  40261. useGlossinessFromSpecularMapAlpha: boolean;
  40262. private _maxSimultaneousLights;
  40263. /**
  40264. * Defines the maximum number of lights that can be used in the material
  40265. */
  40266. maxSimultaneousLights: number;
  40267. private _invertNormalMapX;
  40268. /**
  40269. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  40270. */
  40271. invertNormalMapX: boolean;
  40272. private _invertNormalMapY;
  40273. /**
  40274. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  40275. */
  40276. invertNormalMapY: boolean;
  40277. private _twoSidedLighting;
  40278. /**
  40279. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  40280. */
  40281. twoSidedLighting: boolean;
  40282. /**
  40283. * Default configuration related to image processing available in the standard Material.
  40284. */
  40285. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40286. /**
  40287. * Gets the image processing configuration used either in this material.
  40288. */
  40289. /**
  40290. * Sets the Default image processing configuration used either in the this material.
  40291. *
  40292. * If sets to null, the scene one is in use.
  40293. */
  40294. imageProcessingConfiguration: ImageProcessingConfiguration;
  40295. /**
  40296. * Keep track of the image processing observer to allow dispose and replace.
  40297. */
  40298. private _imageProcessingObserver;
  40299. /**
  40300. * Attaches a new image processing configuration to the Standard Material.
  40301. * @param configuration
  40302. */
  40303. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  40304. /**
  40305. * Gets wether the color curves effect is enabled.
  40306. */
  40307. /**
  40308. * Sets wether the color curves effect is enabled.
  40309. */
  40310. cameraColorCurvesEnabled: boolean;
  40311. /**
  40312. * Gets wether the color grading effect is enabled.
  40313. */
  40314. /**
  40315. * Gets wether the color grading effect is enabled.
  40316. */
  40317. cameraColorGradingEnabled: boolean;
  40318. /**
  40319. * Gets wether tonemapping is enabled or not.
  40320. */
  40321. /**
  40322. * Sets wether tonemapping is enabled or not
  40323. */
  40324. cameraToneMappingEnabled: boolean;
  40325. /**
  40326. * The camera exposure used on this material.
  40327. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40328. * This corresponds to a photographic exposure.
  40329. */
  40330. /**
  40331. * The camera exposure used on this material.
  40332. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40333. * This corresponds to a photographic exposure.
  40334. */
  40335. cameraExposure: number;
  40336. /**
  40337. * Gets The camera contrast used on this material.
  40338. */
  40339. /**
  40340. * Sets The camera contrast used on this material.
  40341. */
  40342. cameraContrast: number;
  40343. /**
  40344. * Gets the Color Grading 2D Lookup Texture.
  40345. */
  40346. /**
  40347. * Sets the Color Grading 2D Lookup Texture.
  40348. */
  40349. cameraColorGradingTexture: Nullable<BaseTexture>;
  40350. /**
  40351. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40352. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40353. * 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;
  40354. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40355. */
  40356. /**
  40357. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40358. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40359. * 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;
  40360. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40361. */
  40362. cameraColorCurves: Nullable<ColorCurves>;
  40363. /**
  40364. * Custom callback helping to override the default shader used in the material.
  40365. */
  40366. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  40367. protected _renderTargets: SmartArray<RenderTargetTexture>;
  40368. protected _worldViewProjectionMatrix: Matrix;
  40369. protected _globalAmbientColor: Color3;
  40370. protected _useLogarithmicDepth: boolean;
  40371. /**
  40372. * Instantiates a new standard material.
  40373. * This is the default material used in Babylon. It is the best trade off between quality
  40374. * and performances.
  40375. * @see http://doc.babylonjs.com/babylon101/materials
  40376. * @param name Define the name of the material in the scene
  40377. * @param scene Define the scene the material belong to
  40378. */
  40379. constructor(name: string, scene: Scene);
  40380. /**
  40381. * Gets a boolean indicating that current material needs to register RTT
  40382. */
  40383. readonly hasRenderTargetTextures: boolean;
  40384. /**
  40385. * Gets the current class name of the material e.g. "StandardMaterial"
  40386. * Mainly use in serialization.
  40387. * @returns the class name
  40388. */
  40389. getClassName(): string;
  40390. /**
  40391. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  40392. * You can try switching to logarithmic depth.
  40393. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  40394. */
  40395. useLogarithmicDepth: boolean;
  40396. /**
  40397. * Specifies if the material will require alpha blending
  40398. * @returns a boolean specifying if alpha blending is needed
  40399. */
  40400. needAlphaBlending(): boolean;
  40401. /**
  40402. * Specifies if this material should be rendered in alpha test mode
  40403. * @returns a boolean specifying if an alpha test is needed.
  40404. */
  40405. needAlphaTesting(): boolean;
  40406. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  40407. /**
  40408. * Get the texture used for alpha test purpose.
  40409. * @returns the diffuse texture in case of the standard material.
  40410. */
  40411. getAlphaTestTexture(): Nullable<BaseTexture>;
  40412. /**
  40413. * Get if the submesh is ready to be used and all its information available.
  40414. * Child classes can use it to update shaders
  40415. * @param mesh defines the mesh to check
  40416. * @param subMesh defines which submesh to check
  40417. * @param useInstances specifies that instances should be used
  40418. * @returns a boolean indicating that the submesh is ready or not
  40419. */
  40420. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  40421. /**
  40422. * Builds the material UBO layouts.
  40423. * Used internally during the effect preparation.
  40424. */
  40425. buildUniformLayout(): void;
  40426. /**
  40427. * Unbinds the material from the mesh
  40428. */
  40429. unbind(): void;
  40430. /**
  40431. * Binds the submesh to this material by preparing the effect and shader to draw
  40432. * @param world defines the world transformation matrix
  40433. * @param mesh defines the mesh containing the submesh
  40434. * @param subMesh defines the submesh to bind the material to
  40435. */
  40436. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  40437. /**
  40438. * Get the list of animatables in the material.
  40439. * @returns the list of animatables object used in the material
  40440. */
  40441. getAnimatables(): IAnimatable[];
  40442. /**
  40443. * Gets the active textures from the material
  40444. * @returns an array of textures
  40445. */
  40446. getActiveTextures(): BaseTexture[];
  40447. /**
  40448. * Specifies if the material uses a texture
  40449. * @param texture defines the texture to check against the material
  40450. * @returns a boolean specifying if the material uses the texture
  40451. */
  40452. hasTexture(texture: BaseTexture): boolean;
  40453. /**
  40454. * Disposes the material
  40455. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  40456. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  40457. */
  40458. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  40459. /**
  40460. * Makes a duplicate of the material, and gives it a new name
  40461. * @param name defines the new name for the duplicated material
  40462. * @returns the cloned material
  40463. */
  40464. clone(name: string): StandardMaterial;
  40465. /**
  40466. * Serializes this material in a JSON representation
  40467. * @returns the serialized material object
  40468. */
  40469. serialize(): any;
  40470. /**
  40471. * Creates a standard material from parsed material data
  40472. * @param source defines the JSON representation of the material
  40473. * @param scene defines the hosting scene
  40474. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  40475. * @returns a new standard material
  40476. */
  40477. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  40478. /**
  40479. * Are diffuse textures enabled in the application.
  40480. */
  40481. static DiffuseTextureEnabled: boolean;
  40482. /**
  40483. * Are ambient textures enabled in the application.
  40484. */
  40485. static AmbientTextureEnabled: boolean;
  40486. /**
  40487. * Are opacity textures enabled in the application.
  40488. */
  40489. static OpacityTextureEnabled: boolean;
  40490. /**
  40491. * Are reflection textures enabled in the application.
  40492. */
  40493. static ReflectionTextureEnabled: boolean;
  40494. /**
  40495. * Are emissive textures enabled in the application.
  40496. */
  40497. static EmissiveTextureEnabled: boolean;
  40498. /**
  40499. * Are specular textures enabled in the application.
  40500. */
  40501. static SpecularTextureEnabled: boolean;
  40502. /**
  40503. * Are bump textures enabled in the application.
  40504. */
  40505. static BumpTextureEnabled: boolean;
  40506. /**
  40507. * Are lightmap textures enabled in the application.
  40508. */
  40509. static LightmapTextureEnabled: boolean;
  40510. /**
  40511. * Are refraction textures enabled in the application.
  40512. */
  40513. static RefractionTextureEnabled: boolean;
  40514. /**
  40515. * Are color grading textures enabled in the application.
  40516. */
  40517. static ColorGradingTextureEnabled: boolean;
  40518. /**
  40519. * Are fresnels enabled in the application.
  40520. */
  40521. static FresnelEnabled: boolean;
  40522. }
  40523. }
  40524. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  40525. import { Scene } from "babylonjs/scene";
  40526. import { Texture } from "babylonjs/Materials/Textures/texture";
  40527. /**
  40528. * A class extending Texture allowing drawing on a texture
  40529. * @see http://doc.babylonjs.com/how_to/dynamictexture
  40530. */
  40531. export class DynamicTexture extends Texture {
  40532. private _generateMipMaps;
  40533. private _canvas;
  40534. private _context;
  40535. private _engine;
  40536. /**
  40537. * Creates a DynamicTexture
  40538. * @param name defines the name of the texture
  40539. * @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
  40540. * @param scene defines the scene where you want the texture
  40541. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  40542. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  40543. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  40544. */
  40545. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  40546. /**
  40547. * Get the current class name of the texture useful for serialization or dynamic coding.
  40548. * @returns "DynamicTexture"
  40549. */
  40550. getClassName(): string;
  40551. /**
  40552. * Gets the current state of canRescale
  40553. */
  40554. readonly canRescale: boolean;
  40555. private _recreate;
  40556. /**
  40557. * Scales the texture
  40558. * @param ratio the scale factor to apply to both width and height
  40559. */
  40560. scale(ratio: number): void;
  40561. /**
  40562. * Resizes the texture
  40563. * @param width the new width
  40564. * @param height the new height
  40565. */
  40566. scaleTo(width: number, height: number): void;
  40567. /**
  40568. * Gets the context of the canvas used by the texture
  40569. * @returns the canvas context of the dynamic texture
  40570. */
  40571. getContext(): CanvasRenderingContext2D;
  40572. /**
  40573. * Clears the texture
  40574. */
  40575. clear(): void;
  40576. /**
  40577. * Updates the texture
  40578. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  40579. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  40580. */
  40581. update(invertY?: boolean, premulAlpha?: boolean): void;
  40582. /**
  40583. * Draws text onto the texture
  40584. * @param text defines the text to be drawn
  40585. * @param x defines the placement of the text from the left
  40586. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  40587. * @param font defines the font to be used with font-style, font-size, font-name
  40588. * @param color defines the color used for the text
  40589. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  40590. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  40591. * @param update defines whether texture is immediately update (default is true)
  40592. */
  40593. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  40594. /**
  40595. * Clones the texture
  40596. * @returns the clone of the texture.
  40597. */
  40598. clone(): DynamicTexture;
  40599. /**
  40600. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  40601. * @returns a serialized dynamic texture object
  40602. */
  40603. serialize(): any;
  40604. /** @hidden */
  40605. _rebuild(): void;
  40606. }
  40607. }
  40608. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  40609. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  40610. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  40611. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  40612. /** @hidden */
  40613. export var imageProcessingPixelShader: {
  40614. name: string;
  40615. shader: string;
  40616. };
  40617. }
  40618. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  40619. import { Nullable } from "babylonjs/types";
  40620. import { Color4 } from "babylonjs/Maths/math";
  40621. import { Camera } from "babylonjs/Cameras/camera";
  40622. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  40623. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  40624. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  40625. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40626. import { Engine } from "babylonjs/Engines/engine";
  40627. import "babylonjs/Shaders/imageProcessing.fragment";
  40628. import "babylonjs/Shaders/postprocess.vertex";
  40629. /**
  40630. * ImageProcessingPostProcess
  40631. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  40632. */
  40633. export class ImageProcessingPostProcess extends PostProcess {
  40634. /**
  40635. * Default configuration related to image processing available in the PBR Material.
  40636. */
  40637. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40638. /**
  40639. * Gets the image processing configuration used either in this material.
  40640. */
  40641. /**
  40642. * Sets the Default image processing configuration used either in the this material.
  40643. *
  40644. * If sets to null, the scene one is in use.
  40645. */
  40646. imageProcessingConfiguration: ImageProcessingConfiguration;
  40647. /**
  40648. * Keep track of the image processing observer to allow dispose and replace.
  40649. */
  40650. private _imageProcessingObserver;
  40651. /**
  40652. * Attaches a new image processing configuration to the PBR Material.
  40653. * @param configuration
  40654. */
  40655. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  40656. /**
  40657. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40658. */
  40659. /**
  40660. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40661. */
  40662. colorCurves: Nullable<ColorCurves>;
  40663. /**
  40664. * Gets wether the color curves effect is enabled.
  40665. */
  40666. /**
  40667. * Sets wether the color curves effect is enabled.
  40668. */
  40669. colorCurvesEnabled: boolean;
  40670. /**
  40671. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40672. */
  40673. /**
  40674. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40675. */
  40676. colorGradingTexture: Nullable<BaseTexture>;
  40677. /**
  40678. * Gets wether the color grading effect is enabled.
  40679. */
  40680. /**
  40681. * Gets wether the color grading effect is enabled.
  40682. */
  40683. colorGradingEnabled: boolean;
  40684. /**
  40685. * Gets exposure used in the effect.
  40686. */
  40687. /**
  40688. * Sets exposure used in the effect.
  40689. */
  40690. exposure: number;
  40691. /**
  40692. * Gets wether tonemapping is enabled or not.
  40693. */
  40694. /**
  40695. * Sets wether tonemapping is enabled or not
  40696. */
  40697. toneMappingEnabled: boolean;
  40698. /**
  40699. * Gets the type of tone mapping effect.
  40700. */
  40701. /**
  40702. * Sets the type of tone mapping effect.
  40703. */
  40704. toneMappingType: number;
  40705. /**
  40706. * Gets contrast used in the effect.
  40707. */
  40708. /**
  40709. * Sets contrast used in the effect.
  40710. */
  40711. contrast: number;
  40712. /**
  40713. * Gets Vignette stretch size.
  40714. */
  40715. /**
  40716. * Sets Vignette stretch size.
  40717. */
  40718. vignetteStretch: number;
  40719. /**
  40720. * Gets Vignette centre X Offset.
  40721. */
  40722. /**
  40723. * Sets Vignette centre X Offset.
  40724. */
  40725. vignetteCentreX: number;
  40726. /**
  40727. * Gets Vignette centre Y Offset.
  40728. */
  40729. /**
  40730. * Sets Vignette centre Y Offset.
  40731. */
  40732. vignetteCentreY: number;
  40733. /**
  40734. * Gets Vignette weight or intensity of the vignette effect.
  40735. */
  40736. /**
  40737. * Sets Vignette weight or intensity of the vignette effect.
  40738. */
  40739. vignetteWeight: number;
  40740. /**
  40741. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40742. * if vignetteEnabled is set to true.
  40743. */
  40744. /**
  40745. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40746. * if vignetteEnabled is set to true.
  40747. */
  40748. vignetteColor: Color4;
  40749. /**
  40750. * Gets Camera field of view used by the Vignette effect.
  40751. */
  40752. /**
  40753. * Sets Camera field of view used by the Vignette effect.
  40754. */
  40755. vignetteCameraFov: number;
  40756. /**
  40757. * Gets the vignette blend mode allowing different kind of effect.
  40758. */
  40759. /**
  40760. * Sets the vignette blend mode allowing different kind of effect.
  40761. */
  40762. vignetteBlendMode: number;
  40763. /**
  40764. * Gets wether the vignette effect is enabled.
  40765. */
  40766. /**
  40767. * Sets wether the vignette effect is enabled.
  40768. */
  40769. vignetteEnabled: boolean;
  40770. private _fromLinearSpace;
  40771. /**
  40772. * Gets wether the input of the processing is in Gamma or Linear Space.
  40773. */
  40774. /**
  40775. * Sets wether the input of the processing is in Gamma or Linear Space.
  40776. */
  40777. fromLinearSpace: boolean;
  40778. /**
  40779. * Defines cache preventing GC.
  40780. */
  40781. private _defines;
  40782. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  40783. /**
  40784. * "ImageProcessingPostProcess"
  40785. * @returns "ImageProcessingPostProcess"
  40786. */
  40787. getClassName(): string;
  40788. protected _updateParameters(): void;
  40789. dispose(camera?: Camera): void;
  40790. }
  40791. }
  40792. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  40793. import { Scene } from "babylonjs/scene";
  40794. import { Color3 } from "babylonjs/Maths/math";
  40795. import { Mesh } from "babylonjs/Meshes/mesh";
  40796. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  40797. import { Nullable } from "babylonjs/types";
  40798. /**
  40799. * Class containing static functions to help procedurally build meshes
  40800. */
  40801. export class GroundBuilder {
  40802. /**
  40803. * Creates a ground mesh
  40804. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  40805. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  40806. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40807. * @param name defines the name of the mesh
  40808. * @param options defines the options used to create the mesh
  40809. * @param scene defines the hosting scene
  40810. * @returns the ground mesh
  40811. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  40812. */
  40813. static CreateGround(name: string, options: {
  40814. width?: number;
  40815. height?: number;
  40816. subdivisions?: number;
  40817. subdivisionsX?: number;
  40818. subdivisionsY?: number;
  40819. updatable?: boolean;
  40820. }, scene: any): Mesh;
  40821. /**
  40822. * Creates a tiled ground mesh
  40823. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  40824. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  40825. * * 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
  40826. * * 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
  40827. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40828. * @param name defines the name of the mesh
  40829. * @param options defines the options used to create the mesh
  40830. * @param scene defines the hosting scene
  40831. * @returns the tiled ground mesh
  40832. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  40833. */
  40834. static CreateTiledGround(name: string, options: {
  40835. xmin: number;
  40836. zmin: number;
  40837. xmax: number;
  40838. zmax: number;
  40839. subdivisions?: {
  40840. w: number;
  40841. h: number;
  40842. };
  40843. precision?: {
  40844. w: number;
  40845. h: number;
  40846. };
  40847. updatable?: boolean;
  40848. }, scene?: Nullable<Scene>): Mesh;
  40849. /**
  40850. * Creates a ground mesh from a height map
  40851. * * The parameter `url` sets the URL of the height map image resource.
  40852. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  40853. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  40854. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  40855. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  40856. * * 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.
  40857. * * 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).
  40858. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  40859. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40860. * @param name defines the name of the mesh
  40861. * @param url defines the url to the height map
  40862. * @param options defines the options used to create the mesh
  40863. * @param scene defines the hosting scene
  40864. * @returns the ground mesh
  40865. * @see https://doc.babylonjs.com/babylon101/height_map
  40866. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  40867. */
  40868. static CreateGroundFromHeightMap(name: string, url: string, options: {
  40869. width?: number;
  40870. height?: number;
  40871. subdivisions?: number;
  40872. minHeight?: number;
  40873. maxHeight?: number;
  40874. colorFilter?: Color3;
  40875. alphaFilter?: number;
  40876. updatable?: boolean;
  40877. onReady?: (mesh: GroundMesh) => void;
  40878. }, scene?: Nullable<Scene>): GroundMesh;
  40879. }
  40880. }
  40881. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  40882. import { Vector4 } from "babylonjs/Maths/math";
  40883. import { Mesh } from "babylonjs/Meshes/mesh";
  40884. /**
  40885. * Class containing static functions to help procedurally build meshes
  40886. */
  40887. export class TorusBuilder {
  40888. /**
  40889. * Creates a torus mesh
  40890. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  40891. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  40892. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  40893. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40894. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40895. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40896. * @param name defines the name of the mesh
  40897. * @param options defines the options used to create the mesh
  40898. * @param scene defines the hosting scene
  40899. * @returns the torus mesh
  40900. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  40901. */
  40902. static CreateTorus(name: string, options: {
  40903. diameter?: number;
  40904. thickness?: number;
  40905. tessellation?: number;
  40906. updatable?: boolean;
  40907. sideOrientation?: number;
  40908. frontUVs?: Vector4;
  40909. backUVs?: Vector4;
  40910. }, scene: any): Mesh;
  40911. }
  40912. }
  40913. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  40914. import { Color4, Vector4 } from "babylonjs/Maths/math";
  40915. import { Mesh } from "babylonjs/Meshes/mesh";
  40916. /**
  40917. * Class containing static functions to help procedurally build meshes
  40918. */
  40919. export class CylinderBuilder {
  40920. /**
  40921. * Creates a cylinder or a cone mesh
  40922. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  40923. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  40924. * * 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.
  40925. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  40926. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  40927. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  40928. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  40929. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  40930. * * 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).
  40931. * * 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
  40932. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  40933. * * 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
  40934. * * 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.
  40935. * * If `enclose` is false, a ring surface is one element.
  40936. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  40937. * * 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
  40938. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40939. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40940. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40941. * @param name defines the name of the mesh
  40942. * @param options defines the options used to create the mesh
  40943. * @param scene defines the hosting scene
  40944. * @returns the cylinder mesh
  40945. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  40946. */
  40947. static CreateCylinder(name: string, options: {
  40948. height?: number;
  40949. diameterTop?: number;
  40950. diameterBottom?: number;
  40951. diameter?: number;
  40952. tessellation?: number;
  40953. subdivisions?: number;
  40954. arc?: number;
  40955. faceColors?: Color4[];
  40956. faceUV?: Vector4[];
  40957. updatable?: boolean;
  40958. hasRings?: boolean;
  40959. enclose?: boolean;
  40960. sideOrientation?: number;
  40961. frontUVs?: Vector4;
  40962. backUVs?: Vector4;
  40963. }, scene: any): Mesh;
  40964. }
  40965. }
  40966. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  40967. import { Observable } from "babylonjs/Misc/observable";
  40968. import { Nullable } from "babylonjs/types";
  40969. import { Camera } from "babylonjs/Cameras/camera";
  40970. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  40971. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  40972. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  40973. import { Scene } from "babylonjs/scene";
  40974. import { Vector3, Color3 } from "babylonjs/Maths/math";
  40975. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  40976. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40977. import { Mesh } from "babylonjs/Meshes/mesh";
  40978. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  40979. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40980. import "babylonjs/Meshes/Builders/groundBuilder";
  40981. import "babylonjs/Meshes/Builders/torusBuilder";
  40982. import "babylonjs/Meshes/Builders/cylinderBuilder";
  40983. import "babylonjs/Gamepads/gamepadSceneComponent";
  40984. import "babylonjs/Animations/animatable";
  40985. /**
  40986. * Options to modify the vr teleportation behavior.
  40987. */
  40988. export interface VRTeleportationOptions {
  40989. /**
  40990. * The name of the mesh which should be used as the teleportation floor. (default: null)
  40991. */
  40992. floorMeshName?: string;
  40993. /**
  40994. * A list of meshes to be used as the teleportation floor. (default: empty)
  40995. */
  40996. floorMeshes?: Mesh[];
  40997. }
  40998. /**
  40999. * Options to modify the vr experience helper's behavior.
  41000. */
  41001. export interface VRExperienceHelperOptions extends WebVROptions {
  41002. /**
  41003. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  41004. */
  41005. createDeviceOrientationCamera?: boolean;
  41006. /**
  41007. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  41008. */
  41009. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  41010. /**
  41011. * Uses the main button on the controller to toggle the laser casted. (default: true)
  41012. */
  41013. laserToggle?: boolean;
  41014. /**
  41015. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  41016. */
  41017. floorMeshes?: Mesh[];
  41018. /**
  41019. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  41020. */
  41021. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  41022. }
  41023. /**
  41024. * Event containing information after VR has been entered
  41025. */
  41026. export class OnAfterEnteringVRObservableEvent {
  41027. /**
  41028. * If entering vr was successful
  41029. */
  41030. success: boolean;
  41031. }
  41032. /**
  41033. * Helps to quickly add VR support to an existing scene.
  41034. * See http://doc.babylonjs.com/how_to/webvr_helper
  41035. */
  41036. export class VRExperienceHelper {
  41037. /** Options to modify the vr experience helper's behavior. */
  41038. webVROptions: VRExperienceHelperOptions;
  41039. private _scene;
  41040. private _position;
  41041. private _btnVR;
  41042. private _btnVRDisplayed;
  41043. private _webVRsupported;
  41044. private _webVRready;
  41045. private _webVRrequesting;
  41046. private _webVRpresenting;
  41047. private _hasEnteredVR;
  41048. private _fullscreenVRpresenting;
  41049. private _canvas;
  41050. private _webVRCamera;
  41051. private _vrDeviceOrientationCamera;
  41052. private _deviceOrientationCamera;
  41053. private _existingCamera;
  41054. private _onKeyDown;
  41055. private _onVrDisplayPresentChange;
  41056. private _onVRDisplayChanged;
  41057. private _onVRRequestPresentStart;
  41058. private _onVRRequestPresentComplete;
  41059. /**
  41060. * Observable raised right before entering VR.
  41061. */
  41062. onEnteringVRObservable: Observable<VRExperienceHelper>;
  41063. /**
  41064. * Observable raised when entering VR has completed.
  41065. */
  41066. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  41067. /**
  41068. * Observable raised when exiting VR.
  41069. */
  41070. onExitingVRObservable: Observable<VRExperienceHelper>;
  41071. /**
  41072. * Observable raised when controller mesh is loaded.
  41073. */
  41074. onControllerMeshLoadedObservable: Observable<WebVRController>;
  41075. /** Return this.onEnteringVRObservable
  41076. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  41077. */
  41078. readonly onEnteringVR: Observable<VRExperienceHelper>;
  41079. /** Return this.onExitingVRObservable
  41080. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  41081. */
  41082. readonly onExitingVR: Observable<VRExperienceHelper>;
  41083. /** Return this.onControllerMeshLoadedObservable
  41084. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  41085. */
  41086. readonly onControllerMeshLoaded: Observable<WebVRController>;
  41087. private _rayLength;
  41088. private _useCustomVRButton;
  41089. private _teleportationRequested;
  41090. private _teleportActive;
  41091. private _floorMeshName;
  41092. private _floorMeshesCollection;
  41093. private _rotationAllowed;
  41094. private _teleportBackwardsVector;
  41095. private _teleportationTarget;
  41096. private _isDefaultTeleportationTarget;
  41097. private _postProcessMove;
  41098. private _teleportationFillColor;
  41099. private _teleportationBorderColor;
  41100. private _rotationAngle;
  41101. private _haloCenter;
  41102. private _cameraGazer;
  41103. private _padSensibilityUp;
  41104. private _padSensibilityDown;
  41105. private _leftController;
  41106. private _rightController;
  41107. /**
  41108. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  41109. */
  41110. onNewMeshSelected: Observable<AbstractMesh>;
  41111. /**
  41112. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  41113. */
  41114. onNewMeshPicked: Observable<PickingInfo>;
  41115. private _circleEase;
  41116. /**
  41117. * Observable raised before camera teleportation
  41118. */
  41119. onBeforeCameraTeleport: Observable<Vector3>;
  41120. /**
  41121. * Observable raised after camera teleportation
  41122. */
  41123. onAfterCameraTeleport: Observable<Vector3>;
  41124. /**
  41125. * Observable raised when current selected mesh gets unselected
  41126. */
  41127. onSelectedMeshUnselected: Observable<AbstractMesh>;
  41128. private _raySelectionPredicate;
  41129. /**
  41130. * To be optionaly changed by user to define custom ray selection
  41131. */
  41132. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  41133. /**
  41134. * To be optionaly changed by user to define custom selection logic (after ray selection)
  41135. */
  41136. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  41137. /**
  41138. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  41139. */
  41140. teleportationEnabled: boolean;
  41141. private _defaultHeight;
  41142. private _teleportationInitialized;
  41143. private _interactionsEnabled;
  41144. private _interactionsRequested;
  41145. private _displayGaze;
  41146. private _displayLaserPointer;
  41147. /**
  41148. * The mesh used to display where the user is going to teleport.
  41149. */
  41150. /**
  41151. * Sets the mesh to be used to display where the user is going to teleport.
  41152. */
  41153. teleportationTarget: Mesh;
  41154. /**
  41155. * 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
  41156. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  41157. * See http://doc.babylonjs.com/resources/baking_transformations
  41158. */
  41159. gazeTrackerMesh: Mesh;
  41160. /**
  41161. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  41162. */
  41163. updateGazeTrackerScale: boolean;
  41164. /**
  41165. * If the gaze trackers color should be updated when selecting meshes
  41166. */
  41167. updateGazeTrackerColor: boolean;
  41168. /**
  41169. * The gaze tracking mesh corresponding to the left controller
  41170. */
  41171. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  41172. /**
  41173. * The gaze tracking mesh corresponding to the right controller
  41174. */
  41175. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  41176. /**
  41177. * If the ray of the gaze should be displayed.
  41178. */
  41179. /**
  41180. * Sets if the ray of the gaze should be displayed.
  41181. */
  41182. displayGaze: boolean;
  41183. /**
  41184. * If the ray of the LaserPointer should be displayed.
  41185. */
  41186. /**
  41187. * Sets if the ray of the LaserPointer should be displayed.
  41188. */
  41189. displayLaserPointer: boolean;
  41190. /**
  41191. * The deviceOrientationCamera used as the camera when not in VR.
  41192. */
  41193. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  41194. /**
  41195. * Based on the current WebVR support, returns the current VR camera used.
  41196. */
  41197. readonly currentVRCamera: Nullable<Camera>;
  41198. /**
  41199. * The webVRCamera which is used when in VR.
  41200. */
  41201. readonly webVRCamera: WebVRFreeCamera;
  41202. /**
  41203. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  41204. */
  41205. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  41206. private readonly _teleportationRequestInitiated;
  41207. /**
  41208. * Defines wether or not Pointer lock should be requested when switching to
  41209. * full screen.
  41210. */
  41211. requestPointerLockOnFullScreen: boolean;
  41212. /**
  41213. * Instantiates a VRExperienceHelper.
  41214. * Helps to quickly add VR support to an existing scene.
  41215. * @param scene The scene the VRExperienceHelper belongs to.
  41216. * @param webVROptions Options to modify the vr experience helper's behavior.
  41217. */
  41218. constructor(scene: Scene,
  41219. /** Options to modify the vr experience helper's behavior. */
  41220. webVROptions?: VRExperienceHelperOptions);
  41221. private _onDefaultMeshLoaded;
  41222. private _onResize;
  41223. private _onFullscreenChange;
  41224. /**
  41225. * Gets a value indicating if we are currently in VR mode.
  41226. */
  41227. readonly isInVRMode: boolean;
  41228. private onVrDisplayPresentChange;
  41229. private onVRDisplayChanged;
  41230. private moveButtonToBottomRight;
  41231. private displayVRButton;
  41232. private updateButtonVisibility;
  41233. private _cachedAngularSensibility;
  41234. /**
  41235. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  41236. * Otherwise, will use the fullscreen API.
  41237. */
  41238. enterVR(): void;
  41239. /**
  41240. * Attempt to exit VR, or fullscreen.
  41241. */
  41242. exitVR(): void;
  41243. /**
  41244. * The position of the vr experience helper.
  41245. */
  41246. /**
  41247. * Sets the position of the vr experience helper.
  41248. */
  41249. position: Vector3;
  41250. /**
  41251. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  41252. */
  41253. enableInteractions(): void;
  41254. private readonly _noControllerIsActive;
  41255. private beforeRender;
  41256. private _isTeleportationFloor;
  41257. /**
  41258. * Adds a floor mesh to be used for teleportation.
  41259. * @param floorMesh the mesh to be used for teleportation.
  41260. */
  41261. addFloorMesh(floorMesh: Mesh): void;
  41262. /**
  41263. * Removes a floor mesh from being used for teleportation.
  41264. * @param floorMesh the mesh to be removed.
  41265. */
  41266. removeFloorMesh(floorMesh: Mesh): void;
  41267. /**
  41268. * Enables interactions and teleportation using the VR controllers and gaze.
  41269. * @param vrTeleportationOptions options to modify teleportation behavior.
  41270. */
  41271. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  41272. private _onNewGamepadConnected;
  41273. private _tryEnableInteractionOnController;
  41274. private _onNewGamepadDisconnected;
  41275. private _enableInteractionOnController;
  41276. private _checkTeleportWithRay;
  41277. private _checkRotate;
  41278. private _checkTeleportBackwards;
  41279. private _enableTeleportationOnController;
  41280. private _createTeleportationCircles;
  41281. private _displayTeleportationTarget;
  41282. private _hideTeleportationTarget;
  41283. private _rotateCamera;
  41284. private _moveTeleportationSelectorTo;
  41285. private _workingVector;
  41286. private _workingQuaternion;
  41287. private _workingMatrix;
  41288. /**
  41289. * Teleports the users feet to the desired location
  41290. * @param location The location where the user's feet should be placed
  41291. */
  41292. teleportCamera(location: Vector3): void;
  41293. private _convertNormalToDirectionOfRay;
  41294. private _castRayAndSelectObject;
  41295. private _notifySelectedMeshUnselected;
  41296. /**
  41297. * Sets the color of the laser ray from the vr controllers.
  41298. * @param color new color for the ray.
  41299. */
  41300. changeLaserColor(color: Color3): void;
  41301. /**
  41302. * Sets the color of the ray from the vr headsets gaze.
  41303. * @param color new color for the ray.
  41304. */
  41305. changeGazeColor(color: Color3): void;
  41306. /**
  41307. * Exits VR and disposes of the vr experience helper
  41308. */
  41309. dispose(): void;
  41310. /**
  41311. * Gets the name of the VRExperienceHelper class
  41312. * @returns "VRExperienceHelper"
  41313. */
  41314. getClassName(): string;
  41315. }
  41316. }
  41317. declare module "babylonjs/Cameras/VR/index" {
  41318. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  41319. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  41320. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  41321. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  41322. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  41323. export * from "babylonjs/Cameras/VR/webVRCamera";
  41324. }
  41325. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  41326. import { Observable } from "babylonjs/Misc/observable";
  41327. import { Nullable } from "babylonjs/types";
  41328. import { IDisposable, Scene } from "babylonjs/scene";
  41329. import { Vector3 } from "babylonjs/Maths/math";
  41330. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  41331. import { Ray } from "babylonjs/Culling/ray";
  41332. /**
  41333. * Manages an XRSession
  41334. * @see https://doc.babylonjs.com/how_to/webxr
  41335. */
  41336. export class WebXRSessionManager implements IDisposable {
  41337. private scene;
  41338. /**
  41339. * Fires every time a new xrFrame arrives which can be used to update the camera
  41340. */
  41341. onXRFrameObservable: Observable<any>;
  41342. /**
  41343. * Fires when the xr session is ended either by the device or manually done
  41344. */
  41345. onXRSessionEnded: Observable<any>;
  41346. /** @hidden */
  41347. _xrSession: XRSession;
  41348. /** @hidden */
  41349. _frameOfReference: XRFrameOfReference;
  41350. /** @hidden */
  41351. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  41352. /** @hidden */
  41353. _currentXRFrame: Nullable<XRFrame>;
  41354. private _xrNavigator;
  41355. private _xrDevice;
  41356. private _tmpMatrix;
  41357. /**
  41358. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  41359. * @param scene The scene which the session should be created for
  41360. */
  41361. constructor(scene: Scene);
  41362. /**
  41363. * Initializes the manager
  41364. * After initialization enterXR can be called to start an XR session
  41365. * @returns Promise which resolves after it is initialized
  41366. */
  41367. initializeAsync(): Promise<void>;
  41368. /**
  41369. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  41370. * @param sessionCreationOptions xr options to create the session with
  41371. * @param frameOfReferenceType option to configure how the xr pose is expressed
  41372. * @returns Promise which resolves after it enters XR
  41373. */
  41374. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  41375. /**
  41376. * Stops the xrSession and restores the renderloop
  41377. * @returns Promise which resolves after it exits XR
  41378. */
  41379. exitXRAsync(): Promise<void>;
  41380. /**
  41381. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  41382. * @param ray ray to cast into the environment
  41383. * @returns Promise which resolves with a collision point in the environment if it exists
  41384. */
  41385. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  41386. /**
  41387. * Checks if a session would be supported for the creation options specified
  41388. * @param options creation options to check if they are supported
  41389. * @returns true if supported
  41390. */
  41391. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  41392. /**
  41393. * @hidden
  41394. * Converts the render layer of xrSession to a render target
  41395. * @param session session to create render target for
  41396. * @param scene scene the new render target should be created for
  41397. */
  41398. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  41399. /**
  41400. * Disposes of the session manager
  41401. */
  41402. dispose(): void;
  41403. }
  41404. }
  41405. declare module "babylonjs/Cameras/XR/webXRCamera" {
  41406. import { Scene } from "babylonjs/scene";
  41407. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41408. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  41409. /**
  41410. * WebXR Camera which holds the views for the xrSession
  41411. * @see https://doc.babylonjs.com/how_to/webxr
  41412. */
  41413. export class WebXRCamera extends FreeCamera {
  41414. private static _TmpMatrix;
  41415. /**
  41416. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  41417. * @param name the name of the camera
  41418. * @param scene the scene to add the camera to
  41419. */
  41420. constructor(name: string, scene: Scene);
  41421. private _updateNumberOfRigCameras;
  41422. /** @hidden */
  41423. _updateForDualEyeDebugging(pupilDistance?: number): void;
  41424. /**
  41425. * Updates the cameras position from the current pose information of the XR session
  41426. * @param xrSessionManager the session containing pose information
  41427. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  41428. */
  41429. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  41430. }
  41431. }
  41432. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  41433. import { Nullable } from "babylonjs/types";
  41434. import { Observable } from "babylonjs/Misc/observable";
  41435. import { IDisposable, Scene } from "babylonjs/scene";
  41436. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  41437. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41438. import { Ray } from "babylonjs/Culling/ray";
  41439. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  41440. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  41441. /**
  41442. * States of the webXR experience
  41443. */
  41444. export enum WebXRState {
  41445. /**
  41446. * Transitioning to being in XR mode
  41447. */
  41448. ENTERING_XR = 0,
  41449. /**
  41450. * Transitioning to non XR mode
  41451. */
  41452. EXITING_XR = 1,
  41453. /**
  41454. * In XR mode and presenting
  41455. */
  41456. IN_XR = 2,
  41457. /**
  41458. * Not entered XR mode
  41459. */
  41460. NOT_IN_XR = 3
  41461. }
  41462. /**
  41463. * Helper class used to enable XR
  41464. * @see https://doc.babylonjs.com/how_to/webxr
  41465. */
  41466. export class WebXRExperienceHelper implements IDisposable {
  41467. private scene;
  41468. /**
  41469. * 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
  41470. */
  41471. container: AbstractMesh;
  41472. /**
  41473. * Camera used to render xr content
  41474. */
  41475. camera: WebXRCamera;
  41476. /**
  41477. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  41478. */
  41479. state: WebXRState;
  41480. private _setState;
  41481. private static _TmpVector;
  41482. /**
  41483. * Fires when the state of the experience helper has changed
  41484. */
  41485. onStateChangedObservable: Observable<WebXRState>;
  41486. /** @hidden */
  41487. _sessionManager: WebXRSessionManager;
  41488. private _nonVRCamera;
  41489. private _originalSceneAutoClear;
  41490. private _supported;
  41491. /**
  41492. * Creates the experience helper
  41493. * @param scene the scene to attach the experience helper to
  41494. * @returns a promise for the experience helper
  41495. */
  41496. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  41497. /**
  41498. * Creates a WebXRExperienceHelper
  41499. * @param scene The scene the helper should be created in
  41500. */
  41501. private constructor();
  41502. /**
  41503. * Exits XR mode and returns the scene to its original state
  41504. * @returns promise that resolves after xr mode has exited
  41505. */
  41506. exitXRAsync(): Promise<void>;
  41507. /**
  41508. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  41509. * @param sessionCreationOptions options for the XR session
  41510. * @param frameOfReference frame of reference of the XR session
  41511. * @returns promise that resolves after xr mode has entered
  41512. */
  41513. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  41514. /**
  41515. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  41516. * @param ray ray to cast into the environment
  41517. * @returns Promise which resolves with a collision point in the environment if it exists
  41518. */
  41519. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  41520. /**
  41521. * Updates the global position of the camera by moving the camera's container
  41522. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  41523. * @param position The desired global position of the camera
  41524. */
  41525. setPositionOfCameraUsingContainer(position: Vector3): void;
  41526. /**
  41527. * Rotates the xr camera by rotating the camera's container around the camera's position
  41528. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  41529. * @param rotation the desired quaternion rotation to apply to the camera
  41530. */
  41531. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  41532. /**
  41533. * Checks if the creation options are supported by the xr session
  41534. * @param options creation options
  41535. * @returns true if supported
  41536. */
  41537. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  41538. /**
  41539. * Disposes of the experience helper
  41540. */
  41541. dispose(): void;
  41542. }
  41543. }
  41544. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  41545. import { Nullable } from "babylonjs/types";
  41546. import { Observable } from "babylonjs/Misc/observable";
  41547. import { IDisposable, Scene } from "babylonjs/scene";
  41548. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41549. /**
  41550. * Button which can be used to enter a different mode of XR
  41551. */
  41552. export class WebXREnterExitUIButton {
  41553. /** button element */
  41554. element: HTMLElement;
  41555. /** XR initialization options for the button */
  41556. initializationOptions: XRSessionCreationOptions;
  41557. /**
  41558. * Creates a WebXREnterExitUIButton
  41559. * @param element button element
  41560. * @param initializationOptions XR initialization options for the button
  41561. */
  41562. constructor(
  41563. /** button element */
  41564. element: HTMLElement,
  41565. /** XR initialization options for the button */
  41566. initializationOptions: XRSessionCreationOptions);
  41567. /**
  41568. * Overwritable function which can be used to update the button's visuals when the state changes
  41569. * @param activeButton the current active button in the UI
  41570. */
  41571. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  41572. }
  41573. /**
  41574. * Options to create the webXR UI
  41575. */
  41576. export class WebXREnterExitUIOptions {
  41577. /**
  41578. * Context to enter xr with
  41579. */
  41580. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  41581. /**
  41582. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  41583. */
  41584. customButtons?: Array<WebXREnterExitUIButton>;
  41585. }
  41586. /**
  41587. * UI to allow the user to enter/exit XR mode
  41588. */
  41589. export class WebXREnterExitUI implements IDisposable {
  41590. private scene;
  41591. private _overlay;
  41592. private _buttons;
  41593. private _activeButton;
  41594. /**
  41595. * Fired every time the active button is changed.
  41596. *
  41597. * When xr is entered via a button that launches xr that button will be the callback parameter
  41598. *
  41599. * When exiting xr the callback parameter will be null)
  41600. */
  41601. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  41602. /**
  41603. * Creates UI to allow the user to enter/exit XR mode
  41604. * @param scene the scene to add the ui to
  41605. * @param helper the xr experience helper to enter/exit xr with
  41606. * @param options options to configure the UI
  41607. * @returns the created ui
  41608. */
  41609. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  41610. private constructor();
  41611. private _updateButtons;
  41612. /**
  41613. * Disposes of the object
  41614. */
  41615. dispose(): void;
  41616. }
  41617. }
  41618. declare module "babylonjs/Cameras/XR/webXRInput" {
  41619. import { IDisposable, Scene } from "babylonjs/scene";
  41620. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41621. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41622. /**
  41623. * Represents an XR input
  41624. */
  41625. export class WebXRController {
  41626. /**
  41627. * 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
  41628. */
  41629. grip?: AbstractMesh;
  41630. /**
  41631. * Pointer which can be used to select objects or attach a visible laser to
  41632. */
  41633. pointer: AbstractMesh;
  41634. /**
  41635. * Creates the controller
  41636. * @see https://doc.babylonjs.com/how_to/webxr
  41637. * @param scene the scene which the controller should be associated to
  41638. */
  41639. constructor(scene: Scene);
  41640. /**
  41641. * Disposes of the object
  41642. */
  41643. dispose(): void;
  41644. }
  41645. /**
  41646. * XR input used to track XR inputs such as controllers/rays
  41647. */
  41648. export class WebXRInput implements IDisposable {
  41649. private helper;
  41650. /**
  41651. * XR controllers being tracked
  41652. */
  41653. controllers: Array<WebXRController>;
  41654. private _tmpMatrix;
  41655. private _frameObserver;
  41656. /**
  41657. * Initializes the WebXRInput
  41658. * @param helper experience helper which the input should be created for
  41659. */
  41660. constructor(helper: WebXRExperienceHelper);
  41661. /**
  41662. * Disposes of the object
  41663. */
  41664. dispose(): void;
  41665. }
  41666. }
  41667. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  41668. import { Nullable } from "babylonjs/types";
  41669. import { IDisposable } from "babylonjs/scene";
  41670. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41671. /**
  41672. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  41673. */
  41674. export class WebXRManagedOutputCanvas implements IDisposable {
  41675. private _canvas;
  41676. /**
  41677. * xrpresent context of the canvas which can be used to display/mirror xr content
  41678. */
  41679. canvasContext: Nullable<WebGLRenderingContext>;
  41680. /**
  41681. * Initializes the canvas to be added/removed upon entering/exiting xr
  41682. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  41683. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  41684. */
  41685. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  41686. /**
  41687. * Disposes of the object
  41688. */
  41689. dispose(): void;
  41690. private _setManagedOutputCanvas;
  41691. private _addCanvas;
  41692. private _removeCanvas;
  41693. }
  41694. }
  41695. declare module "babylonjs/Cameras/XR/index" {
  41696. export * from "babylonjs/Cameras/XR/webXRCamera";
  41697. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  41698. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41699. export * from "babylonjs/Cameras/XR/webXRInput";
  41700. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  41701. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  41702. }
  41703. declare module "babylonjs/Cameras/RigModes/index" {
  41704. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  41705. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  41706. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  41707. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  41708. }
  41709. declare module "babylonjs/Cameras/index" {
  41710. export * from "babylonjs/Cameras/Inputs/index";
  41711. export * from "babylonjs/Cameras/cameraInputsManager";
  41712. export * from "babylonjs/Cameras/camera";
  41713. export * from "babylonjs/Cameras/targetCamera";
  41714. export * from "babylonjs/Cameras/freeCamera";
  41715. export * from "babylonjs/Cameras/freeCameraInputsManager";
  41716. export * from "babylonjs/Cameras/touchCamera";
  41717. export * from "babylonjs/Cameras/arcRotateCamera";
  41718. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  41719. export * from "babylonjs/Cameras/deviceOrientationCamera";
  41720. export * from "babylonjs/Cameras/flyCamera";
  41721. export * from "babylonjs/Cameras/flyCameraInputsManager";
  41722. export * from "babylonjs/Cameras/followCamera";
  41723. export * from "babylonjs/Cameras/gamepadCamera";
  41724. export * from "babylonjs/Cameras/Stereoscopic/index";
  41725. export * from "babylonjs/Cameras/universalCamera";
  41726. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  41727. export * from "babylonjs/Cameras/VR/index";
  41728. export * from "babylonjs/Cameras/XR/index";
  41729. export * from "babylonjs/Cameras/RigModes/index";
  41730. }
  41731. declare module "babylonjs/Collisions/index" {
  41732. export * from "babylonjs/Collisions/collider";
  41733. export * from "babylonjs/Collisions/collisionCoordinator";
  41734. export * from "babylonjs/Collisions/pickingInfo";
  41735. export * from "babylonjs/Collisions/intersectionInfo";
  41736. export * from "babylonjs/Collisions/meshCollisionData";
  41737. }
  41738. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  41739. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  41740. import { Vector3, Plane } from "babylonjs/Maths/math";
  41741. import { Ray } from "babylonjs/Culling/ray";
  41742. /**
  41743. * Contains an array of blocks representing the octree
  41744. */
  41745. export interface IOctreeContainer<T> {
  41746. /**
  41747. * Blocks within the octree
  41748. */
  41749. blocks: Array<OctreeBlock<T>>;
  41750. }
  41751. /**
  41752. * Class used to store a cell in an octree
  41753. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41754. */
  41755. export class OctreeBlock<T> {
  41756. /**
  41757. * Gets the content of the current block
  41758. */
  41759. entries: T[];
  41760. /**
  41761. * Gets the list of block children
  41762. */
  41763. blocks: Array<OctreeBlock<T>>;
  41764. private _depth;
  41765. private _maxDepth;
  41766. private _capacity;
  41767. private _minPoint;
  41768. private _maxPoint;
  41769. private _boundingVectors;
  41770. private _creationFunc;
  41771. /**
  41772. * Creates a new block
  41773. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  41774. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  41775. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41776. * @param depth defines the current depth of this block in the octree
  41777. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  41778. * @param creationFunc defines a callback to call when an element is added to the block
  41779. */
  41780. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  41781. /**
  41782. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41783. */
  41784. readonly capacity: number;
  41785. /**
  41786. * Gets the minimum vector (in world space) of the block's bounding box
  41787. */
  41788. readonly minPoint: Vector3;
  41789. /**
  41790. * Gets the maximum vector (in world space) of the block's bounding box
  41791. */
  41792. readonly maxPoint: Vector3;
  41793. /**
  41794. * Add a new element to this block
  41795. * @param entry defines the element to add
  41796. */
  41797. addEntry(entry: T): void;
  41798. /**
  41799. * Remove an element from this block
  41800. * @param entry defines the element to remove
  41801. */
  41802. removeEntry(entry: T): void;
  41803. /**
  41804. * Add an array of elements to this block
  41805. * @param entries defines the array of elements to add
  41806. */
  41807. addEntries(entries: T[]): void;
  41808. /**
  41809. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  41810. * @param frustumPlanes defines the frustum planes to test
  41811. * @param selection defines the array to store current content if selection is positive
  41812. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41813. */
  41814. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41815. /**
  41816. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  41817. * @param sphereCenter defines the bounding sphere center
  41818. * @param sphereRadius defines the bounding sphere radius
  41819. * @param selection defines the array to store current content if selection is positive
  41820. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41821. */
  41822. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41823. /**
  41824. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  41825. * @param ray defines the ray to test with
  41826. * @param selection defines the array to store current content if selection is positive
  41827. */
  41828. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  41829. /**
  41830. * Subdivide the content into child blocks (this block will then be empty)
  41831. */
  41832. createInnerBlocks(): void;
  41833. /**
  41834. * @hidden
  41835. */
  41836. 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;
  41837. }
  41838. }
  41839. declare module "babylonjs/Culling/Octrees/octree" {
  41840. import { SmartArray } from "babylonjs/Misc/smartArray";
  41841. import { Vector3, Plane } from "babylonjs/Maths/math";
  41842. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41843. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41844. import { Ray } from "babylonjs/Culling/ray";
  41845. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  41846. /**
  41847. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  41848. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41849. */
  41850. export class Octree<T> {
  41851. /** Defines the maximum depth (sub-levels) for your octree. Default value is 2, which means 8 8 8 = 512 blocks :) (This parameter takes precedence over capacity.) */
  41852. maxDepth: number;
  41853. /**
  41854. * Blocks within the octree containing objects
  41855. */
  41856. blocks: Array<OctreeBlock<T>>;
  41857. /**
  41858. * Content stored in the octree
  41859. */
  41860. dynamicContent: T[];
  41861. private _maxBlockCapacity;
  41862. private _selectionContent;
  41863. private _creationFunc;
  41864. /**
  41865. * Creates a octree
  41866. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41867. * @param creationFunc function to be used to instatiate the octree
  41868. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  41869. * @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.)
  41870. */
  41871. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  41872. /** 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.) */
  41873. maxDepth?: number);
  41874. /**
  41875. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  41876. * @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);
  41877. * @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);
  41878. * @param entries meshes to be added to the octree blocks
  41879. */
  41880. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  41881. /**
  41882. * Adds a mesh to the octree
  41883. * @param entry Mesh to add to the octree
  41884. */
  41885. addMesh(entry: T): void;
  41886. /**
  41887. * Remove an element from the octree
  41888. * @param entry defines the element to remove
  41889. */
  41890. removeMesh(entry: T): void;
  41891. /**
  41892. * Selects an array of meshes within the frustum
  41893. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  41894. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  41895. * @returns array of meshes within the frustum
  41896. */
  41897. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  41898. /**
  41899. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  41900. * @param sphereCenter defines the bounding sphere center
  41901. * @param sphereRadius defines the bounding sphere radius
  41902. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41903. * @returns an array of objects that intersect the sphere
  41904. */
  41905. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  41906. /**
  41907. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  41908. * @param ray defines the ray to test with
  41909. * @returns array of intersected objects
  41910. */
  41911. intersectsRay(ray: Ray): SmartArray<T>;
  41912. /**
  41913. * Adds a mesh into the octree block if it intersects the block
  41914. */
  41915. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  41916. /**
  41917. * Adds a submesh into the octree block if it intersects the block
  41918. */
  41919. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  41920. }
  41921. }
  41922. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  41923. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  41924. import { Scene } from "babylonjs/scene";
  41925. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41926. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41927. import { Ray } from "babylonjs/Culling/ray";
  41928. import { Octree } from "babylonjs/Culling/Octrees/octree";
  41929. import { Collider } from "babylonjs/Collisions/collider";
  41930. module "babylonjs/scene" {
  41931. interface Scene {
  41932. /**
  41933. * @hidden
  41934. * Backing Filed
  41935. */
  41936. _selectionOctree: Octree<AbstractMesh>;
  41937. /**
  41938. * Gets the octree used to boost mesh selection (picking)
  41939. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41940. */
  41941. selectionOctree: Octree<AbstractMesh>;
  41942. /**
  41943. * Creates or updates the octree used to boost selection (picking)
  41944. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41945. * @param maxCapacity defines the maximum capacity per leaf
  41946. * @param maxDepth defines the maximum depth of the octree
  41947. * @returns an octree of AbstractMesh
  41948. */
  41949. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  41950. }
  41951. }
  41952. module "babylonjs/Meshes/abstractMesh" {
  41953. interface AbstractMesh {
  41954. /**
  41955. * @hidden
  41956. * Backing Field
  41957. */
  41958. _submeshesOctree: Octree<SubMesh>;
  41959. /**
  41960. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  41961. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  41962. * @param maxCapacity defines the maximum size of each block (64 by default)
  41963. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  41964. * @returns the new octree
  41965. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  41966. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41967. */
  41968. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  41969. }
  41970. }
  41971. /**
  41972. * Defines the octree scene component responsible to manage any octrees
  41973. * in a given scene.
  41974. */
  41975. export class OctreeSceneComponent {
  41976. /**
  41977. * The component name help to identify the component in the list of scene components.
  41978. */
  41979. readonly name: string;
  41980. /**
  41981. * The scene the component belongs to.
  41982. */
  41983. scene: Scene;
  41984. /**
  41985. * Indicates if the meshes have been checked to make sure they are isEnabled()
  41986. */
  41987. readonly checksIsEnabled: boolean;
  41988. /**
  41989. * Creates a new instance of the component for the given scene
  41990. * @param scene Defines the scene to register the component in
  41991. */
  41992. constructor(scene: Scene);
  41993. /**
  41994. * Registers the component in a given scene
  41995. */
  41996. register(): void;
  41997. /**
  41998. * Return the list of active meshes
  41999. * @returns the list of active meshes
  42000. */
  42001. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  42002. /**
  42003. * Return the list of active sub meshes
  42004. * @param mesh The mesh to get the candidates sub meshes from
  42005. * @returns the list of active sub meshes
  42006. */
  42007. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  42008. private _tempRay;
  42009. /**
  42010. * Return the list of sub meshes intersecting with a given local ray
  42011. * @param mesh defines the mesh to find the submesh for
  42012. * @param localRay defines the ray in local space
  42013. * @returns the list of intersecting sub meshes
  42014. */
  42015. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  42016. /**
  42017. * Return the list of sub meshes colliding with a collider
  42018. * @param mesh defines the mesh to find the submesh for
  42019. * @param collider defines the collider to evaluate the collision against
  42020. * @returns the list of colliding sub meshes
  42021. */
  42022. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  42023. /**
  42024. * Rebuilds the elements related to this component in case of
  42025. * context lost for instance.
  42026. */
  42027. rebuild(): void;
  42028. /**
  42029. * Disposes the component and the associated ressources.
  42030. */
  42031. dispose(): void;
  42032. }
  42033. }
  42034. declare module "babylonjs/Culling/Octrees/index" {
  42035. export * from "babylonjs/Culling/Octrees/octree";
  42036. export * from "babylonjs/Culling/Octrees/octreeBlock";
  42037. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  42038. }
  42039. declare module "babylonjs/Culling/index" {
  42040. export * from "babylonjs/Culling/boundingBox";
  42041. export * from "babylonjs/Culling/boundingInfo";
  42042. export * from "babylonjs/Culling/boundingSphere";
  42043. export * from "babylonjs/Culling/Octrees/index";
  42044. export * from "babylonjs/Culling/ray";
  42045. }
  42046. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  42047. import { IDisposable, Scene } from "babylonjs/scene";
  42048. import { Nullable } from "babylonjs/types";
  42049. import { Observable } from "babylonjs/Misc/observable";
  42050. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42051. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  42052. /**
  42053. * Renders a layer on top of an existing scene
  42054. */
  42055. export class UtilityLayerRenderer implements IDisposable {
  42056. /** the original scene that will be rendered on top of */
  42057. originalScene: Scene;
  42058. private _pointerCaptures;
  42059. private _lastPointerEvents;
  42060. private static _DefaultUtilityLayer;
  42061. private static _DefaultKeepDepthUtilityLayer;
  42062. private _sharedGizmoLight;
  42063. /**
  42064. * @hidden
  42065. * Light which used by gizmos to get light shading
  42066. */
  42067. _getSharedGizmoLight(): HemisphericLight;
  42068. /**
  42069. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  42070. */
  42071. pickUtilitySceneFirst: boolean;
  42072. /**
  42073. * 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)
  42074. */
  42075. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  42076. /**
  42077. * 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)
  42078. */
  42079. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  42080. /**
  42081. * The scene that is rendered on top of the original scene
  42082. */
  42083. utilityLayerScene: Scene;
  42084. /**
  42085. * If the utility layer should automatically be rendered on top of existing scene
  42086. */
  42087. shouldRender: boolean;
  42088. /**
  42089. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  42090. */
  42091. onlyCheckPointerDownEvents: boolean;
  42092. /**
  42093. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  42094. */
  42095. processAllEvents: boolean;
  42096. /**
  42097. * Observable raised when the pointer move from the utility layer scene to the main scene
  42098. */
  42099. onPointerOutObservable: Observable<number>;
  42100. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  42101. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  42102. private _afterRenderObserver;
  42103. private _sceneDisposeObserver;
  42104. private _originalPointerObserver;
  42105. /**
  42106. * Instantiates a UtilityLayerRenderer
  42107. * @param originalScene the original scene that will be rendered on top of
  42108. * @param handleEvents boolean indicating if the utility layer should handle events
  42109. */
  42110. constructor(
  42111. /** the original scene that will be rendered on top of */
  42112. originalScene: Scene, handleEvents?: boolean);
  42113. private _notifyObservers;
  42114. /**
  42115. * Renders the utility layers scene on top of the original scene
  42116. */
  42117. render(): void;
  42118. /**
  42119. * Disposes of the renderer
  42120. */
  42121. dispose(): void;
  42122. private _updateCamera;
  42123. }
  42124. }
  42125. declare module "babylonjs/Gizmos/gizmo" {
  42126. import { Nullable } from "babylonjs/types";
  42127. import { IDisposable } from "babylonjs/scene";
  42128. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42129. import { Mesh } from "babylonjs/Meshes/mesh";
  42130. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42131. /**
  42132. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  42133. */
  42134. export class Gizmo implements IDisposable {
  42135. /** The utility layer the gizmo will be added to */
  42136. gizmoLayer: UtilityLayerRenderer;
  42137. /**
  42138. * The root mesh of the gizmo
  42139. */
  42140. _rootMesh: Mesh;
  42141. private _attachedMesh;
  42142. /**
  42143. * Ratio for the scale of the gizmo (Default: 1)
  42144. */
  42145. scaleRatio: number;
  42146. /**
  42147. * If a custom mesh has been set (Default: false)
  42148. */
  42149. protected _customMeshSet: boolean;
  42150. /**
  42151. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  42152. * * When set, interactions will be enabled
  42153. */
  42154. attachedMesh: Nullable<AbstractMesh>;
  42155. /**
  42156. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  42157. * @param mesh The mesh to replace the default mesh of the gizmo
  42158. */
  42159. setCustomMesh(mesh: Mesh): void;
  42160. /**
  42161. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  42162. */
  42163. updateGizmoRotationToMatchAttachedMesh: boolean;
  42164. /**
  42165. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  42166. */
  42167. updateGizmoPositionToMatchAttachedMesh: boolean;
  42168. /**
  42169. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  42170. */
  42171. protected _updateScale: boolean;
  42172. protected _interactionsEnabled: boolean;
  42173. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42174. private _beforeRenderObserver;
  42175. private _tempVector;
  42176. /**
  42177. * Creates a gizmo
  42178. * @param gizmoLayer The utility layer the gizmo will be added to
  42179. */
  42180. constructor(
  42181. /** The utility layer the gizmo will be added to */
  42182. gizmoLayer?: UtilityLayerRenderer);
  42183. /**
  42184. * Updates the gizmo to match the attached mesh's position/rotation
  42185. */
  42186. protected _update(): void;
  42187. /**
  42188. * Disposes of the gizmo
  42189. */
  42190. dispose(): void;
  42191. }
  42192. }
  42193. declare module "babylonjs/Gizmos/axisDragGizmo" {
  42194. import { Observable } from "babylonjs/Misc/observable";
  42195. import { Nullable } from "babylonjs/types";
  42196. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42197. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42198. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42199. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  42200. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42201. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42202. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  42203. import { Scene } from "babylonjs/scene";
  42204. /**
  42205. * Single axis drag gizmo
  42206. */
  42207. export class AxisDragGizmo extends Gizmo {
  42208. /**
  42209. * Drag behavior responsible for the gizmos dragging interactions
  42210. */
  42211. dragBehavior: PointerDragBehavior;
  42212. private _pointerObserver;
  42213. /**
  42214. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42215. */
  42216. snapDistance: number;
  42217. /**
  42218. * Event that fires each time the gizmo snaps to a new location.
  42219. * * snapDistance is the the change in distance
  42220. */
  42221. onSnapObservable: Observable<{
  42222. snapDistance: number;
  42223. }>;
  42224. /** @hidden */
  42225. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  42226. /** @hidden */
  42227. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  42228. /**
  42229. * Creates an AxisDragGizmo
  42230. * @param gizmoLayer The utility layer the gizmo will be added to
  42231. * @param dragAxis The axis which the gizmo will be able to drag on
  42232. * @param color The color of the gizmo
  42233. */
  42234. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  42235. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42236. /**
  42237. * Disposes of the gizmo
  42238. */
  42239. dispose(): void;
  42240. }
  42241. }
  42242. declare module "babylonjs/Debug/axesViewer" {
  42243. import { Vector3 } from "babylonjs/Maths/math";
  42244. import { Nullable } from "babylonjs/types";
  42245. import { Scene } from "babylonjs/scene";
  42246. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42247. /**
  42248. * The Axes viewer will show 3 axes in a specific point in space
  42249. */
  42250. export class AxesViewer {
  42251. private _xAxis;
  42252. private _yAxis;
  42253. private _zAxis;
  42254. private _scaleLinesFactor;
  42255. private _instanced;
  42256. /**
  42257. * Gets the hosting scene
  42258. */
  42259. scene: Scene;
  42260. /**
  42261. * Gets or sets a number used to scale line length
  42262. */
  42263. scaleLines: number;
  42264. /** Gets the node hierarchy used to render x-axis */
  42265. readonly xAxis: TransformNode;
  42266. /** Gets the node hierarchy used to render y-axis */
  42267. readonly yAxis: TransformNode;
  42268. /** Gets the node hierarchy used to render z-axis */
  42269. readonly zAxis: TransformNode;
  42270. /**
  42271. * Creates a new AxesViewer
  42272. * @param scene defines the hosting scene
  42273. * @param scaleLines defines a number used to scale line length (1 by default)
  42274. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  42275. * @param xAxis defines the node hierarchy used to render the x-axis
  42276. * @param yAxis defines the node hierarchy used to render the y-axis
  42277. * @param zAxis defines the node hierarchy used to render the z-axis
  42278. */
  42279. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  42280. /**
  42281. * Force the viewer to update
  42282. * @param position defines the position of the viewer
  42283. * @param xaxis defines the x axis of the viewer
  42284. * @param yaxis defines the y axis of the viewer
  42285. * @param zaxis defines the z axis of the viewer
  42286. */
  42287. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  42288. /**
  42289. * Creates an instance of this axes viewer.
  42290. * @returns a new axes viewer with instanced meshes
  42291. */
  42292. createInstance(): AxesViewer;
  42293. /** Releases resources */
  42294. dispose(): void;
  42295. private static _SetRenderingGroupId;
  42296. }
  42297. }
  42298. declare module "babylonjs/Debug/boneAxesViewer" {
  42299. import { Nullable } from "babylonjs/types";
  42300. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  42301. import { Vector3 } from "babylonjs/Maths/math";
  42302. import { Mesh } from "babylonjs/Meshes/mesh";
  42303. import { Bone } from "babylonjs/Bones/bone";
  42304. import { Scene } from "babylonjs/scene";
  42305. /**
  42306. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  42307. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  42308. */
  42309. export class BoneAxesViewer extends AxesViewer {
  42310. /**
  42311. * Gets or sets the target mesh where to display the axes viewer
  42312. */
  42313. mesh: Nullable<Mesh>;
  42314. /**
  42315. * Gets or sets the target bone where to display the axes viewer
  42316. */
  42317. bone: Nullable<Bone>;
  42318. /** Gets current position */
  42319. pos: Vector3;
  42320. /** Gets direction of X axis */
  42321. xaxis: Vector3;
  42322. /** Gets direction of Y axis */
  42323. yaxis: Vector3;
  42324. /** Gets direction of Z axis */
  42325. zaxis: Vector3;
  42326. /**
  42327. * Creates a new BoneAxesViewer
  42328. * @param scene defines the hosting scene
  42329. * @param bone defines the target bone
  42330. * @param mesh defines the target mesh
  42331. * @param scaleLines defines a scaling factor for line length (1 by default)
  42332. */
  42333. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  42334. /**
  42335. * Force the viewer to update
  42336. */
  42337. update(): void;
  42338. /** Releases resources */
  42339. dispose(): void;
  42340. }
  42341. }
  42342. declare module "babylonjs/Debug/debugLayer" {
  42343. import { Observable } from "babylonjs/Misc/observable";
  42344. import { Scene } from "babylonjs/scene";
  42345. /**
  42346. * Interface used to define scene explorer extensibility option
  42347. */
  42348. export interface IExplorerExtensibilityOption {
  42349. /**
  42350. * Define the option label
  42351. */
  42352. label: string;
  42353. /**
  42354. * Defines the action to execute on click
  42355. */
  42356. action: (entity: any) => void;
  42357. }
  42358. /**
  42359. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  42360. */
  42361. export interface IExplorerExtensibilityGroup {
  42362. /**
  42363. * Defines a predicate to test if a given type mut be extended
  42364. */
  42365. predicate: (entity: any) => boolean;
  42366. /**
  42367. * Gets the list of options added to a type
  42368. */
  42369. entries: IExplorerExtensibilityOption[];
  42370. }
  42371. /**
  42372. * Interface used to define the options to use to create the Inspector
  42373. */
  42374. export interface IInspectorOptions {
  42375. /**
  42376. * Display in overlay mode (default: false)
  42377. */
  42378. overlay?: boolean;
  42379. /**
  42380. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  42381. */
  42382. globalRoot?: HTMLElement;
  42383. /**
  42384. * Display the Scene explorer
  42385. */
  42386. showExplorer?: boolean;
  42387. /**
  42388. * Display the property inspector
  42389. */
  42390. showInspector?: boolean;
  42391. /**
  42392. * Display in embed mode (both panes on the right)
  42393. */
  42394. embedMode?: boolean;
  42395. /**
  42396. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  42397. */
  42398. handleResize?: boolean;
  42399. /**
  42400. * Allow the panes to popup (default: true)
  42401. */
  42402. enablePopup?: boolean;
  42403. /**
  42404. * Allow the panes to be closed by users (default: true)
  42405. */
  42406. enableClose?: boolean;
  42407. /**
  42408. * Optional list of extensibility entries
  42409. */
  42410. explorerExtensibility?: IExplorerExtensibilityGroup[];
  42411. /**
  42412. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  42413. */
  42414. inspectorURL?: string;
  42415. }
  42416. module "babylonjs/scene" {
  42417. interface Scene {
  42418. /**
  42419. * @hidden
  42420. * Backing field
  42421. */
  42422. _debugLayer: DebugLayer;
  42423. /**
  42424. * Gets the debug layer (aka Inspector) associated with the scene
  42425. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42426. */
  42427. debugLayer: DebugLayer;
  42428. }
  42429. }
  42430. /**
  42431. * The debug layer (aka Inspector) is the go to tool in order to better understand
  42432. * what is happening in your scene
  42433. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42434. */
  42435. export class DebugLayer {
  42436. /**
  42437. * Define the url to get the inspector script from.
  42438. * By default it uses the babylonjs CDN.
  42439. * @ignoreNaming
  42440. */
  42441. static InspectorURL: string;
  42442. private _scene;
  42443. private BJSINSPECTOR;
  42444. /**
  42445. * Observable triggered when a property is changed through the inspector.
  42446. */
  42447. onPropertyChangedObservable: Observable<{
  42448. object: any;
  42449. property: string;
  42450. value: any;
  42451. initialValue: any;
  42452. }>;
  42453. /**
  42454. * Instantiates a new debug layer.
  42455. * The debug layer (aka Inspector) is the go to tool in order to better understand
  42456. * what is happening in your scene
  42457. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42458. * @param scene Defines the scene to inspect
  42459. */
  42460. constructor(scene: Scene);
  42461. /** Creates the inspector window. */
  42462. private _createInspector;
  42463. /**
  42464. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  42465. * @param entity defines the entity to select
  42466. * @param lineContainerTitle defines the specific block to highlight
  42467. */
  42468. select(entity: any, lineContainerTitle?: string): void;
  42469. /** Get the inspector from bundle or global */
  42470. private _getGlobalInspector;
  42471. /**
  42472. * Get if the inspector is visible or not.
  42473. * @returns true if visible otherwise, false
  42474. */
  42475. isVisible(): boolean;
  42476. /**
  42477. * Hide the inspector and close its window.
  42478. */
  42479. hide(): void;
  42480. /**
  42481. * Launch the debugLayer.
  42482. * @param config Define the configuration of the inspector
  42483. * @return a promise fulfilled when the debug layer is visible
  42484. */
  42485. show(config?: IInspectorOptions): Promise<DebugLayer>;
  42486. }
  42487. }
  42488. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  42489. import { Nullable } from "babylonjs/types";
  42490. import { Scene } from "babylonjs/scene";
  42491. import { Vector4, Color4 } from "babylonjs/Maths/math";
  42492. import { Mesh } from "babylonjs/Meshes/mesh";
  42493. /**
  42494. * Class containing static functions to help procedurally build meshes
  42495. */
  42496. export class BoxBuilder {
  42497. /**
  42498. * Creates a box mesh
  42499. * * The parameter `size` sets the size (float) of each box side (default 1)
  42500. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  42501. * * 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)
  42502. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  42503. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42504. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42505. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42506. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  42507. * @param name defines the name of the mesh
  42508. * @param options defines the options used to create the mesh
  42509. * @param scene defines the hosting scene
  42510. * @returns the box mesh
  42511. */
  42512. static CreateBox(name: string, options: {
  42513. size?: number;
  42514. width?: number;
  42515. height?: number;
  42516. depth?: number;
  42517. faceUV?: Vector4[];
  42518. faceColors?: Color4[];
  42519. sideOrientation?: number;
  42520. frontUVs?: Vector4;
  42521. backUVs?: Vector4;
  42522. wrap?: boolean;
  42523. topBaseAt?: number;
  42524. bottomBaseAt?: number;
  42525. updatable?: boolean;
  42526. }, scene?: Nullable<Scene>): Mesh;
  42527. }
  42528. }
  42529. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  42530. import { Vector4 } from "babylonjs/Maths/math";
  42531. import { Mesh } from "babylonjs/Meshes/mesh";
  42532. /**
  42533. * Class containing static functions to help procedurally build meshes
  42534. */
  42535. export class SphereBuilder {
  42536. /**
  42537. * Creates a sphere mesh
  42538. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  42539. * * 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`)
  42540. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  42541. * * 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
  42542. * * 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)
  42543. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42544. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42545. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42546. * @param name defines the name of the mesh
  42547. * @param options defines the options used to create the mesh
  42548. * @param scene defines the hosting scene
  42549. * @returns the sphere mesh
  42550. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  42551. */
  42552. static CreateSphere(name: string, options: {
  42553. segments?: number;
  42554. diameter?: number;
  42555. diameterX?: number;
  42556. diameterY?: number;
  42557. diameterZ?: number;
  42558. arc?: number;
  42559. slice?: number;
  42560. sideOrientation?: number;
  42561. frontUVs?: Vector4;
  42562. backUVs?: Vector4;
  42563. updatable?: boolean;
  42564. }, scene: any): Mesh;
  42565. }
  42566. }
  42567. declare module "babylonjs/Debug/physicsViewer" {
  42568. import { Nullable } from "babylonjs/types";
  42569. import { Scene } from "babylonjs/scene";
  42570. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42571. import { Mesh } from "babylonjs/Meshes/mesh";
  42572. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  42573. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  42574. /**
  42575. * Used to show the physics impostor around the specific mesh
  42576. */
  42577. export class PhysicsViewer {
  42578. /** @hidden */
  42579. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  42580. /** @hidden */
  42581. protected _meshes: Array<Nullable<AbstractMesh>>;
  42582. /** @hidden */
  42583. protected _scene: Nullable<Scene>;
  42584. /** @hidden */
  42585. protected _numMeshes: number;
  42586. /** @hidden */
  42587. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  42588. private _renderFunction;
  42589. private _utilityLayer;
  42590. private _debugBoxMesh;
  42591. private _debugSphereMesh;
  42592. private _debugCylinderMesh;
  42593. private _debugMaterial;
  42594. private _debugMeshMeshes;
  42595. /**
  42596. * Creates a new PhysicsViewer
  42597. * @param scene defines the hosting scene
  42598. */
  42599. constructor(scene: Scene);
  42600. /** @hidden */
  42601. protected _updateDebugMeshes(): void;
  42602. /**
  42603. * Renders a specified physic impostor
  42604. * @param impostor defines the impostor to render
  42605. * @param targetMesh defines the mesh represented by the impostor
  42606. * @returns the new debug mesh used to render the impostor
  42607. */
  42608. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  42609. /**
  42610. * Hides a specified physic impostor
  42611. * @param impostor defines the impostor to hide
  42612. */
  42613. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  42614. private _getDebugMaterial;
  42615. private _getDebugBoxMesh;
  42616. private _getDebugSphereMesh;
  42617. private _getDebugCylinderMesh;
  42618. private _getDebugMeshMesh;
  42619. private _getDebugMesh;
  42620. /** Releases all resources */
  42621. dispose(): void;
  42622. }
  42623. }
  42624. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  42625. import { Vector3, Color4 } from "babylonjs/Maths/math";
  42626. import { Nullable } from "babylonjs/types";
  42627. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  42628. import { Scene } from "babylonjs/scene";
  42629. /**
  42630. * Class containing static functions to help procedurally build meshes
  42631. */
  42632. export class LinesBuilder {
  42633. /**
  42634. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  42635. * * 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
  42636. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  42637. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  42638. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  42639. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  42640. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  42641. * * 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
  42642. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  42643. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42644. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  42645. * @param name defines the name of the new line system
  42646. * @param options defines the options used to create the line system
  42647. * @param scene defines the hosting scene
  42648. * @returns a new line system mesh
  42649. */
  42650. static CreateLineSystem(name: string, options: {
  42651. lines: Vector3[][];
  42652. updatable?: boolean;
  42653. instance?: Nullable<LinesMesh>;
  42654. colors?: Nullable<Color4[][]>;
  42655. useVertexAlpha?: boolean;
  42656. }, scene: Nullable<Scene>): LinesMesh;
  42657. /**
  42658. * Creates a line mesh
  42659. * 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
  42660. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  42661. * * The parameter `points` is an array successive Vector3
  42662. * * 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
  42663. * * The optional parameter `colors` is an array of successive Color4, one per line point
  42664. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  42665. * * When updating an instance, remember that only point positions can change, not the number of points
  42666. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42667. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  42668. * @param name defines the name of the new line system
  42669. * @param options defines the options used to create the line system
  42670. * @param scene defines the hosting scene
  42671. * @returns a new line mesh
  42672. */
  42673. static CreateLines(name: string, options: {
  42674. points: Vector3[];
  42675. updatable?: boolean;
  42676. instance?: Nullable<LinesMesh>;
  42677. colors?: Color4[];
  42678. useVertexAlpha?: boolean;
  42679. }, scene?: Nullable<Scene>): LinesMesh;
  42680. /**
  42681. * Creates a dashed line mesh
  42682. * * 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
  42683. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  42684. * * The parameter `points` is an array successive Vector3
  42685. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  42686. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  42687. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  42688. * * 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
  42689. * * When updating an instance, remember that only point positions can change, not the number of points
  42690. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42691. * @param name defines the name of the mesh
  42692. * @param options defines the options used to create the mesh
  42693. * @param scene defines the hosting scene
  42694. * @returns the dashed line mesh
  42695. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  42696. */
  42697. static CreateDashedLines(name: string, options: {
  42698. points: Vector3[];
  42699. dashSize?: number;
  42700. gapSize?: number;
  42701. dashNb?: number;
  42702. updatable?: boolean;
  42703. instance?: LinesMesh;
  42704. }, scene?: Nullable<Scene>): LinesMesh;
  42705. }
  42706. }
  42707. declare module "babylonjs/Debug/rayHelper" {
  42708. import { Nullable } from "babylonjs/types";
  42709. import { Ray } from "babylonjs/Culling/ray";
  42710. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42711. import { Scene } from "babylonjs/scene";
  42712. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42713. import "babylonjs/Meshes/Builders/linesBuilder";
  42714. /**
  42715. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  42716. * in order to better appreciate the issue one might have.
  42717. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  42718. */
  42719. export class RayHelper {
  42720. /**
  42721. * Defines the ray we are currently tryin to visualize.
  42722. */
  42723. ray: Nullable<Ray>;
  42724. private _renderPoints;
  42725. private _renderLine;
  42726. private _renderFunction;
  42727. private _scene;
  42728. private _updateToMeshFunction;
  42729. private _attachedToMesh;
  42730. private _meshSpaceDirection;
  42731. private _meshSpaceOrigin;
  42732. /**
  42733. * Helper function to create a colored helper in a scene in one line.
  42734. * @param ray Defines the ray we are currently tryin to visualize
  42735. * @param scene Defines the scene the ray is used in
  42736. * @param color Defines the color we want to see the ray in
  42737. * @returns The newly created ray helper.
  42738. */
  42739. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  42740. /**
  42741. * Instantiate a new ray helper.
  42742. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  42743. * in order to better appreciate the issue one might have.
  42744. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  42745. * @param ray Defines the ray we are currently tryin to visualize
  42746. */
  42747. constructor(ray: Ray);
  42748. /**
  42749. * Shows the ray we are willing to debug.
  42750. * @param scene Defines the scene the ray needs to be rendered in
  42751. * @param color Defines the color the ray needs to be rendered in
  42752. */
  42753. show(scene: Scene, color?: Color3): void;
  42754. /**
  42755. * Hides the ray we are debugging.
  42756. */
  42757. hide(): void;
  42758. private _render;
  42759. /**
  42760. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  42761. * @param mesh Defines the mesh we want the helper attached to
  42762. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  42763. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  42764. * @param length Defines the length of the ray
  42765. */
  42766. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  42767. /**
  42768. * Detach the ray helper from the mesh it has previously been attached to.
  42769. */
  42770. detachFromMesh(): void;
  42771. private _updateToMesh;
  42772. /**
  42773. * Dispose the helper and release its associated resources.
  42774. */
  42775. dispose(): void;
  42776. }
  42777. }
  42778. declare module "babylonjs/Debug/skeletonViewer" {
  42779. import { Color3 } from "babylonjs/Maths/math";
  42780. import { Scene } from "babylonjs/scene";
  42781. import { Nullable } from "babylonjs/types";
  42782. import { Skeleton } from "babylonjs/Bones/skeleton";
  42783. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42784. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  42785. /**
  42786. * Class used to render a debug view of a given skeleton
  42787. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  42788. */
  42789. export class SkeletonViewer {
  42790. /** defines the skeleton to render */
  42791. skeleton: Skeleton;
  42792. /** defines the mesh attached to the skeleton */
  42793. mesh: AbstractMesh;
  42794. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  42795. autoUpdateBonesMatrices: boolean;
  42796. /** defines the rendering group id to use with the viewer */
  42797. renderingGroupId: number;
  42798. /** Gets or sets the color used to render the skeleton */
  42799. color: Color3;
  42800. private _scene;
  42801. private _debugLines;
  42802. private _debugMesh;
  42803. private _isEnabled;
  42804. private _renderFunction;
  42805. private _utilityLayer;
  42806. /**
  42807. * Returns the mesh used to render the bones
  42808. */
  42809. readonly debugMesh: Nullable<LinesMesh>;
  42810. /**
  42811. * Creates a new SkeletonViewer
  42812. * @param skeleton defines the skeleton to render
  42813. * @param mesh defines the mesh attached to the skeleton
  42814. * @param scene defines the hosting scene
  42815. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  42816. * @param renderingGroupId defines the rendering group id to use with the viewer
  42817. */
  42818. constructor(
  42819. /** defines the skeleton to render */
  42820. skeleton: Skeleton,
  42821. /** defines the mesh attached to the skeleton */
  42822. mesh: AbstractMesh, scene: Scene,
  42823. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  42824. autoUpdateBonesMatrices?: boolean,
  42825. /** defines the rendering group id to use with the viewer */
  42826. renderingGroupId?: number);
  42827. /** Gets or sets a boolean indicating if the viewer is enabled */
  42828. isEnabled: boolean;
  42829. private _getBonePosition;
  42830. private _getLinesForBonesWithLength;
  42831. private _getLinesForBonesNoLength;
  42832. /** Update the viewer to sync with current skeleton state */
  42833. update(): void;
  42834. /** Release associated resources */
  42835. dispose(): void;
  42836. }
  42837. }
  42838. declare module "babylonjs/Debug/index" {
  42839. export * from "babylonjs/Debug/axesViewer";
  42840. export * from "babylonjs/Debug/boneAxesViewer";
  42841. export * from "babylonjs/Debug/debugLayer";
  42842. export * from "babylonjs/Debug/physicsViewer";
  42843. export * from "babylonjs/Debug/rayHelper";
  42844. export * from "babylonjs/Debug/skeletonViewer";
  42845. }
  42846. declare module "babylonjs/Engines/nullEngine" {
  42847. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  42848. import { Scene } from "babylonjs/scene";
  42849. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  42850. import { Engine } from "babylonjs/Engines/engine";
  42851. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  42852. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  42853. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  42854. import { Effect } from "babylonjs/Materials/effect";
  42855. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  42856. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  42857. /**
  42858. * Options to create the null engine
  42859. */
  42860. export class NullEngineOptions {
  42861. /**
  42862. * Render width (Default: 512)
  42863. */
  42864. renderWidth: number;
  42865. /**
  42866. * Render height (Default: 256)
  42867. */
  42868. renderHeight: number;
  42869. /**
  42870. * Texture size (Default: 512)
  42871. */
  42872. textureSize: number;
  42873. /**
  42874. * If delta time between frames should be constant
  42875. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42876. */
  42877. deterministicLockstep: boolean;
  42878. /**
  42879. * Maximum about of steps between frames (Default: 4)
  42880. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42881. */
  42882. lockstepMaxSteps: number;
  42883. }
  42884. /**
  42885. * The null engine class provides support for headless version of babylon.js.
  42886. * This can be used in server side scenario or for testing purposes
  42887. */
  42888. export class NullEngine extends Engine {
  42889. private _options;
  42890. /**
  42891. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42892. */
  42893. isDeterministicLockStep(): boolean;
  42894. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  42895. getLockstepMaxSteps(): number;
  42896. /**
  42897. * Sets hardware scaling, used to save performance if needed
  42898. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  42899. */
  42900. getHardwareScalingLevel(): number;
  42901. constructor(options?: NullEngineOptions);
  42902. createVertexBuffer(vertices: FloatArray): DataBuffer;
  42903. createIndexBuffer(indices: IndicesArray): DataBuffer;
  42904. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  42905. getRenderWidth(useScreen?: boolean): number;
  42906. getRenderHeight(useScreen?: boolean): number;
  42907. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  42908. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  42909. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  42910. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  42911. bindSamplers(effect: Effect): void;
  42912. enableEffect(effect: Effect): void;
  42913. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  42914. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  42915. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  42916. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  42917. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  42918. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  42919. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  42920. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  42921. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  42922. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  42923. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  42924. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  42925. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  42926. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  42927. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  42928. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  42929. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  42930. setFloat(uniform: WebGLUniformLocation, value: number): void;
  42931. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  42932. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  42933. setBool(uniform: WebGLUniformLocation, bool: number): void;
  42934. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  42935. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  42936. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  42937. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  42938. bindBuffers(vertexBuffers: {
  42939. [key: string]: VertexBuffer;
  42940. }, indexBuffer: DataBuffer, effect: Effect): void;
  42941. wipeCaches(bruteForce?: boolean): void;
  42942. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  42943. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  42944. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  42945. /** @hidden */
  42946. _createTexture(): WebGLTexture;
  42947. /** @hidden */
  42948. _releaseTexture(texture: InternalTexture): void;
  42949. 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;
  42950. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  42951. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  42952. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  42953. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  42954. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  42955. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  42956. areAllEffectsReady(): boolean;
  42957. /**
  42958. * @hidden
  42959. * Get the current error code of the webGL context
  42960. * @returns the error code
  42961. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  42962. */
  42963. getError(): number;
  42964. /** @hidden */
  42965. _getUnpackAlignement(): number;
  42966. /** @hidden */
  42967. _unpackFlipY(value: boolean): void;
  42968. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  42969. /**
  42970. * Updates a dynamic vertex buffer.
  42971. * @param vertexBuffer the vertex buffer to update
  42972. * @param data the data used to update the vertex buffer
  42973. * @param byteOffset the byte offset of the data (optional)
  42974. * @param byteLength the byte length of the data (optional)
  42975. */
  42976. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  42977. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  42978. /** @hidden */
  42979. _bindTexture(channel: number, texture: InternalTexture): void;
  42980. /** @hidden */
  42981. _releaseBuffer(buffer: DataBuffer): boolean;
  42982. releaseEffects(): void;
  42983. displayLoadingUI(): void;
  42984. hideLoadingUI(): void;
  42985. /** @hidden */
  42986. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42987. /** @hidden */
  42988. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42989. /** @hidden */
  42990. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42991. /** @hidden */
  42992. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  42993. }
  42994. }
  42995. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  42996. import { Nullable, int } from "babylonjs/types";
  42997. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  42998. /** @hidden */
  42999. export class _OcclusionDataStorage {
  43000. /** @hidden */
  43001. occlusionInternalRetryCounter: number;
  43002. /** @hidden */
  43003. isOcclusionQueryInProgress: boolean;
  43004. /** @hidden */
  43005. isOccluded: boolean;
  43006. /** @hidden */
  43007. occlusionRetryCount: number;
  43008. /** @hidden */
  43009. occlusionType: number;
  43010. /** @hidden */
  43011. occlusionQueryAlgorithmType: number;
  43012. }
  43013. module "babylonjs/Engines/engine" {
  43014. interface Engine {
  43015. /**
  43016. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  43017. * @return the new query
  43018. */
  43019. createQuery(): WebGLQuery;
  43020. /**
  43021. * Delete and release a webGL query
  43022. * @param query defines the query to delete
  43023. * @return the current engine
  43024. */
  43025. deleteQuery(query: WebGLQuery): Engine;
  43026. /**
  43027. * Check if a given query has resolved and got its value
  43028. * @param query defines the query to check
  43029. * @returns true if the query got its value
  43030. */
  43031. isQueryResultAvailable(query: WebGLQuery): boolean;
  43032. /**
  43033. * Gets the value of a given query
  43034. * @param query defines the query to check
  43035. * @returns the value of the query
  43036. */
  43037. getQueryResult(query: WebGLQuery): number;
  43038. /**
  43039. * Initiates an occlusion query
  43040. * @param algorithmType defines the algorithm to use
  43041. * @param query defines the query to use
  43042. * @returns the current engine
  43043. * @see http://doc.babylonjs.com/features/occlusionquery
  43044. */
  43045. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  43046. /**
  43047. * Ends an occlusion query
  43048. * @see http://doc.babylonjs.com/features/occlusionquery
  43049. * @param algorithmType defines the algorithm to use
  43050. * @returns the current engine
  43051. */
  43052. endOcclusionQuery(algorithmType: number): Engine;
  43053. /**
  43054. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  43055. * Please note that only one query can be issued at a time
  43056. * @returns a time token used to track the time span
  43057. */
  43058. startTimeQuery(): Nullable<_TimeToken>;
  43059. /**
  43060. * Ends a time query
  43061. * @param token defines the token used to measure the time span
  43062. * @returns the time spent (in ns)
  43063. */
  43064. endTimeQuery(token: _TimeToken): int;
  43065. /** @hidden */
  43066. _currentNonTimestampToken: Nullable<_TimeToken>;
  43067. /** @hidden */
  43068. _createTimeQuery(): WebGLQuery;
  43069. /** @hidden */
  43070. _deleteTimeQuery(query: WebGLQuery): void;
  43071. /** @hidden */
  43072. _getGlAlgorithmType(algorithmType: number): number;
  43073. /** @hidden */
  43074. _getTimeQueryResult(query: WebGLQuery): any;
  43075. /** @hidden */
  43076. _getTimeQueryAvailability(query: WebGLQuery): any;
  43077. }
  43078. }
  43079. module "babylonjs/Meshes/abstractMesh" {
  43080. interface AbstractMesh {
  43081. /**
  43082. * Backing filed
  43083. * @hidden
  43084. */
  43085. __occlusionDataStorage: _OcclusionDataStorage;
  43086. /**
  43087. * Access property
  43088. * @hidden
  43089. */
  43090. _occlusionDataStorage: _OcclusionDataStorage;
  43091. /**
  43092. * 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.
  43093. * The default value is -1 which means don't break the query and wait till the result
  43094. * @see http://doc.babylonjs.com/features/occlusionquery
  43095. */
  43096. occlusionRetryCount: number;
  43097. /**
  43098. * 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:
  43099. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  43100. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  43101. * * 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.
  43102. * @see http://doc.babylonjs.com/features/occlusionquery
  43103. */
  43104. occlusionType: number;
  43105. /**
  43106. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  43107. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  43108. * * 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.
  43109. * @see http://doc.babylonjs.com/features/occlusionquery
  43110. */
  43111. occlusionQueryAlgorithmType: number;
  43112. /**
  43113. * 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
  43114. * @see http://doc.babylonjs.com/features/occlusionquery
  43115. */
  43116. isOccluded: boolean;
  43117. /**
  43118. * Flag to check the progress status of the query
  43119. * @see http://doc.babylonjs.com/features/occlusionquery
  43120. */
  43121. isOcclusionQueryInProgress: boolean;
  43122. }
  43123. }
  43124. }
  43125. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  43126. import { Nullable } from "babylonjs/types";
  43127. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  43128. /** @hidden */
  43129. export var _forceTransformFeedbackToBundle: boolean;
  43130. module "babylonjs/Engines/engine" {
  43131. interface Engine {
  43132. /**
  43133. * Creates a webGL transform feedback object
  43134. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  43135. * @returns the webGL transform feedback object
  43136. */
  43137. createTransformFeedback(): WebGLTransformFeedback;
  43138. /**
  43139. * Delete a webGL transform feedback object
  43140. * @param value defines the webGL transform feedback object to delete
  43141. */
  43142. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  43143. /**
  43144. * Bind a webGL transform feedback object to the webgl context
  43145. * @param value defines the webGL transform feedback object to bind
  43146. */
  43147. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  43148. /**
  43149. * Begins a transform feedback operation
  43150. * @param usePoints defines if points or triangles must be used
  43151. */
  43152. beginTransformFeedback(usePoints: boolean): void;
  43153. /**
  43154. * Ends a transform feedback operation
  43155. */
  43156. endTransformFeedback(): void;
  43157. /**
  43158. * Specify the varyings to use with transform feedback
  43159. * @param program defines the associated webGL program
  43160. * @param value defines the list of strings representing the varying names
  43161. */
  43162. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  43163. /**
  43164. * Bind a webGL buffer for a transform feedback operation
  43165. * @param value defines the webGL buffer to bind
  43166. */
  43167. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  43168. }
  43169. }
  43170. }
  43171. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  43172. import { Scene } from "babylonjs/scene";
  43173. import { Engine } from "babylonjs/Engines/engine";
  43174. import { Texture } from "babylonjs/Materials/Textures/texture";
  43175. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  43176. import "babylonjs/Engines/Extensions/engine.multiRender";
  43177. /**
  43178. * Creation options of the multi render target texture.
  43179. */
  43180. export interface IMultiRenderTargetOptions {
  43181. /**
  43182. * Define if the texture needs to create mip maps after render.
  43183. */
  43184. generateMipMaps?: boolean;
  43185. /**
  43186. * Define the types of all the draw buffers we want to create
  43187. */
  43188. types?: number[];
  43189. /**
  43190. * Define the sampling modes of all the draw buffers we want to create
  43191. */
  43192. samplingModes?: number[];
  43193. /**
  43194. * Define if a depth buffer is required
  43195. */
  43196. generateDepthBuffer?: boolean;
  43197. /**
  43198. * Define if a stencil buffer is required
  43199. */
  43200. generateStencilBuffer?: boolean;
  43201. /**
  43202. * Define if a depth texture is required instead of a depth buffer
  43203. */
  43204. generateDepthTexture?: boolean;
  43205. /**
  43206. * Define the number of desired draw buffers
  43207. */
  43208. textureCount?: number;
  43209. /**
  43210. * Define if aspect ratio should be adapted to the texture or stay the scene one
  43211. */
  43212. doNotChangeAspectRatio?: boolean;
  43213. /**
  43214. * Define the default type of the buffers we are creating
  43215. */
  43216. defaultType?: number;
  43217. }
  43218. /**
  43219. * A multi render target, like a render target provides the ability to render to a texture.
  43220. * Unlike the render target, it can render to several draw buffers in one draw.
  43221. * This is specially interesting in deferred rendering or for any effects requiring more than
  43222. * just one color from a single pass.
  43223. */
  43224. export class MultiRenderTarget extends RenderTargetTexture {
  43225. private _internalTextures;
  43226. private _textures;
  43227. private _multiRenderTargetOptions;
  43228. /**
  43229. * Get if draw buffers are currently supported by the used hardware and browser.
  43230. */
  43231. readonly isSupported: boolean;
  43232. /**
  43233. * Get the list of textures generated by the multi render target.
  43234. */
  43235. readonly textures: Texture[];
  43236. /**
  43237. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  43238. */
  43239. readonly depthTexture: Texture;
  43240. /**
  43241. * Set the wrapping mode on U of all the textures we are rendering to.
  43242. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43243. */
  43244. wrapU: number;
  43245. /**
  43246. * Set the wrapping mode on V of all the textures we are rendering to.
  43247. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43248. */
  43249. wrapV: number;
  43250. /**
  43251. * Instantiate a new multi render target texture.
  43252. * A multi render target, like a render target provides the ability to render to a texture.
  43253. * Unlike the render target, it can render to several draw buffers in one draw.
  43254. * This is specially interesting in deferred rendering or for any effects requiring more than
  43255. * just one color from a single pass.
  43256. * @param name Define the name of the texture
  43257. * @param size Define the size of the buffers to render to
  43258. * @param count Define the number of target we are rendering into
  43259. * @param scene Define the scene the texture belongs to
  43260. * @param options Define the options used to create the multi render target
  43261. */
  43262. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  43263. /** @hidden */
  43264. _rebuild(): void;
  43265. private _createInternalTextures;
  43266. private _createTextures;
  43267. /**
  43268. * Define the number of samples used if MSAA is enabled.
  43269. */
  43270. samples: number;
  43271. /**
  43272. * Resize all the textures in the multi render target.
  43273. * Be carrefull as it will recreate all the data in the new texture.
  43274. * @param size Define the new size
  43275. */
  43276. resize(size: any): void;
  43277. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  43278. /**
  43279. * Dispose the render targets and their associated resources
  43280. */
  43281. dispose(): void;
  43282. /**
  43283. * Release all the underlying texture used as draw buffers.
  43284. */
  43285. releaseInternalTextures(): void;
  43286. }
  43287. }
  43288. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  43289. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  43290. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  43291. import { Nullable } from "babylonjs/types";
  43292. module "babylonjs/Engines/engine" {
  43293. interface Engine {
  43294. /**
  43295. * Unbind a list of render target textures from the webGL context
  43296. * This is used only when drawBuffer extension or webGL2 are active
  43297. * @param textures defines the render target textures to unbind
  43298. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  43299. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  43300. */
  43301. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  43302. /**
  43303. * Create a multi render target texture
  43304. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  43305. * @param size defines the size of the texture
  43306. * @param options defines the creation options
  43307. * @returns the cube texture as an InternalTexture
  43308. */
  43309. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  43310. /**
  43311. * Update the sample count for a given multiple render target texture
  43312. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  43313. * @param textures defines the textures to update
  43314. * @param samples defines the sample count to set
  43315. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  43316. */
  43317. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  43318. }
  43319. }
  43320. }
  43321. declare module "babylonjs/Engines/Extensions/index" {
  43322. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  43323. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  43324. export * from "babylonjs/Engines/Extensions/engine.multiview";
  43325. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  43326. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  43327. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  43328. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  43329. export * from "babylonjs/Engines/Extensions/engine.webVR";
  43330. }
  43331. declare module "babylonjs/Engines/index" {
  43332. export * from "babylonjs/Engines/constants";
  43333. export * from "babylonjs/Engines/engine";
  43334. export * from "babylonjs/Engines/engineStore";
  43335. export * from "babylonjs/Engines/nullEngine";
  43336. export * from "babylonjs/Engines/Extensions/index";
  43337. export * from "babylonjs/Engines/IPipelineContext";
  43338. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  43339. }
  43340. declare module "babylonjs/Events/clipboardEvents" {
  43341. /**
  43342. * Gather the list of clipboard event types as constants.
  43343. */
  43344. export class ClipboardEventTypes {
  43345. /**
  43346. * The clipboard event is fired when a copy command is active (pressed).
  43347. */
  43348. static readonly COPY: number;
  43349. /**
  43350. * The clipboard event is fired when a cut command is active (pressed).
  43351. */
  43352. static readonly CUT: number;
  43353. /**
  43354. * The clipboard event is fired when a paste command is active (pressed).
  43355. */
  43356. static readonly PASTE: number;
  43357. }
  43358. /**
  43359. * This class is used to store clipboard related info for the onClipboardObservable event.
  43360. */
  43361. export class ClipboardInfo {
  43362. /**
  43363. * Defines the type of event (BABYLON.ClipboardEventTypes)
  43364. */
  43365. type: number;
  43366. /**
  43367. * Defines the related dom event
  43368. */
  43369. event: ClipboardEvent;
  43370. /**
  43371. *Creates an instance of ClipboardInfo.
  43372. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  43373. * @param event Defines the related dom event
  43374. */
  43375. constructor(
  43376. /**
  43377. * Defines the type of event (BABYLON.ClipboardEventTypes)
  43378. */
  43379. type: number,
  43380. /**
  43381. * Defines the related dom event
  43382. */
  43383. event: ClipboardEvent);
  43384. /**
  43385. * Get the clipboard event's type from the keycode.
  43386. * @param keyCode Defines the keyCode for the current keyboard event.
  43387. * @return {number}
  43388. */
  43389. static GetTypeFromCharacter(keyCode: number): number;
  43390. }
  43391. }
  43392. declare module "babylonjs/Events/index" {
  43393. export * from "babylonjs/Events/keyboardEvents";
  43394. export * from "babylonjs/Events/pointerEvents";
  43395. export * from "babylonjs/Events/clipboardEvents";
  43396. }
  43397. declare module "babylonjs/Loading/sceneLoader" {
  43398. import { Observable } from "babylonjs/Misc/observable";
  43399. import { Nullable } from "babylonjs/types";
  43400. import { Scene } from "babylonjs/scene";
  43401. import { Engine } from "babylonjs/Engines/engine";
  43402. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43403. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  43404. import { AssetContainer } from "babylonjs/assetContainer";
  43405. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  43406. import { Skeleton } from "babylonjs/Bones/skeleton";
  43407. /**
  43408. * Class used to represent data loading progression
  43409. */
  43410. export class SceneLoaderProgressEvent {
  43411. /** defines if data length to load can be evaluated */
  43412. readonly lengthComputable: boolean;
  43413. /** defines the loaded data length */
  43414. readonly loaded: number;
  43415. /** defines the data length to load */
  43416. readonly total: number;
  43417. /**
  43418. * Create a new progress event
  43419. * @param lengthComputable defines if data length to load can be evaluated
  43420. * @param loaded defines the loaded data length
  43421. * @param total defines the data length to load
  43422. */
  43423. constructor(
  43424. /** defines if data length to load can be evaluated */
  43425. lengthComputable: boolean,
  43426. /** defines the loaded data length */
  43427. loaded: number,
  43428. /** defines the data length to load */
  43429. total: number);
  43430. /**
  43431. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43432. * @param event defines the source event
  43433. * @returns a new SceneLoaderProgressEvent
  43434. */
  43435. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43436. }
  43437. /**
  43438. * Interface used by SceneLoader plugins to define supported file extensions
  43439. */
  43440. export interface ISceneLoaderPluginExtensions {
  43441. /**
  43442. * Defines the list of supported extensions
  43443. */
  43444. [extension: string]: {
  43445. isBinary: boolean;
  43446. };
  43447. }
  43448. /**
  43449. * Interface used by SceneLoader plugin factory
  43450. */
  43451. export interface ISceneLoaderPluginFactory {
  43452. /**
  43453. * Defines the name of the factory
  43454. */
  43455. name: string;
  43456. /**
  43457. * Function called to create a new plugin
  43458. * @return the new plugin
  43459. */
  43460. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43461. /**
  43462. * Boolean indicating if the plugin can direct load specific data
  43463. */
  43464. canDirectLoad?: (data: string) => boolean;
  43465. }
  43466. /**
  43467. * Interface used to define a SceneLoader plugin
  43468. */
  43469. export interface ISceneLoaderPlugin {
  43470. /**
  43471. * The friendly name of this plugin.
  43472. */
  43473. name: string;
  43474. /**
  43475. * The file extensions supported by this plugin.
  43476. */
  43477. extensions: string | ISceneLoaderPluginExtensions;
  43478. /**
  43479. * Import meshes into a scene.
  43480. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43481. * @param scene The scene to import into
  43482. * @param data The data to import
  43483. * @param rootUrl The root url for scene and resources
  43484. * @param meshes The meshes array to import into
  43485. * @param particleSystems The particle systems array to import into
  43486. * @param skeletons The skeletons array to import into
  43487. * @param onError The callback when import fails
  43488. * @returns True if successful or false otherwise
  43489. */
  43490. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43491. /**
  43492. * Load into a scene.
  43493. * @param scene The scene to load into
  43494. * @param data The data to import
  43495. * @param rootUrl The root url for scene and resources
  43496. * @param onError The callback when import fails
  43497. * @returns true if successful or false otherwise
  43498. */
  43499. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43500. /**
  43501. * The callback that returns true if the data can be directly loaded.
  43502. */
  43503. canDirectLoad?: (data: string) => boolean;
  43504. /**
  43505. * The callback that allows custom handling of the root url based on the response url.
  43506. */
  43507. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43508. /**
  43509. * Load into an asset container.
  43510. * @param scene The scene to load into
  43511. * @param data The data to import
  43512. * @param rootUrl The root url for scene and resources
  43513. * @param onError The callback when import fails
  43514. * @returns The loaded asset container
  43515. */
  43516. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43517. }
  43518. /**
  43519. * Interface used to define an async SceneLoader plugin
  43520. */
  43521. export interface ISceneLoaderPluginAsync {
  43522. /**
  43523. * The friendly name of this plugin.
  43524. */
  43525. name: string;
  43526. /**
  43527. * The file extensions supported by this plugin.
  43528. */
  43529. extensions: string | ISceneLoaderPluginExtensions;
  43530. /**
  43531. * Import meshes into a scene.
  43532. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43533. * @param scene The scene to import into
  43534. * @param data The data to import
  43535. * @param rootUrl The root url for scene and resources
  43536. * @param onProgress The callback when the load progresses
  43537. * @param fileName Defines the name of the file to load
  43538. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43539. */
  43540. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43541. meshes: AbstractMesh[];
  43542. particleSystems: IParticleSystem[];
  43543. skeletons: Skeleton[];
  43544. animationGroups: AnimationGroup[];
  43545. }>;
  43546. /**
  43547. * Load into a scene.
  43548. * @param scene The scene to load into
  43549. * @param data The data to import
  43550. * @param rootUrl The root url for scene and resources
  43551. * @param onProgress The callback when the load progresses
  43552. * @param fileName Defines the name of the file to load
  43553. * @returns Nothing
  43554. */
  43555. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43556. /**
  43557. * The callback that returns true if the data can be directly loaded.
  43558. */
  43559. canDirectLoad?: (data: string) => boolean;
  43560. /**
  43561. * The callback that allows custom handling of the root url based on the response url.
  43562. */
  43563. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43564. /**
  43565. * Load into an asset container.
  43566. * @param scene The scene to load into
  43567. * @param data The data to import
  43568. * @param rootUrl The root url for scene and resources
  43569. * @param onProgress The callback when the load progresses
  43570. * @param fileName Defines the name of the file to load
  43571. * @returns The loaded asset container
  43572. */
  43573. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43574. }
  43575. /**
  43576. * Class used to load scene from various file formats using registered plugins
  43577. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43578. */
  43579. export class SceneLoader {
  43580. /**
  43581. * No logging while loading
  43582. */
  43583. static readonly NO_LOGGING: number;
  43584. /**
  43585. * Minimal logging while loading
  43586. */
  43587. static readonly MINIMAL_LOGGING: number;
  43588. /**
  43589. * Summary logging while loading
  43590. */
  43591. static readonly SUMMARY_LOGGING: number;
  43592. /**
  43593. * Detailled logging while loading
  43594. */
  43595. static readonly DETAILED_LOGGING: number;
  43596. /**
  43597. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43598. */
  43599. static ForceFullSceneLoadingForIncremental: boolean;
  43600. /**
  43601. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43602. */
  43603. static ShowLoadingScreen: boolean;
  43604. /**
  43605. * Defines the current logging level (while loading the scene)
  43606. * @ignorenaming
  43607. */
  43608. static loggingLevel: number;
  43609. /**
  43610. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43611. */
  43612. static CleanBoneMatrixWeights: boolean;
  43613. /**
  43614. * Event raised when a plugin is used to load a scene
  43615. */
  43616. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43617. private static _registeredPlugins;
  43618. private static _getDefaultPlugin;
  43619. private static _getPluginForExtension;
  43620. private static _getPluginForDirectLoad;
  43621. private static _getPluginForFilename;
  43622. private static _getDirectLoad;
  43623. private static _loadData;
  43624. private static _getFileInfo;
  43625. /**
  43626. * Gets a plugin that can load the given extension
  43627. * @param extension defines the extension to load
  43628. * @returns a plugin or null if none works
  43629. */
  43630. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43631. /**
  43632. * Gets a boolean indicating that the given extension can be loaded
  43633. * @param extension defines the extension to load
  43634. * @returns true if the extension is supported
  43635. */
  43636. static IsPluginForExtensionAvailable(extension: string): boolean;
  43637. /**
  43638. * Adds a new plugin to the list of registered plugins
  43639. * @param plugin defines the plugin to add
  43640. */
  43641. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43642. /**
  43643. * Import meshes into a scene
  43644. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43645. * @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)
  43646. * @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)
  43647. * @param scene the instance of BABYLON.Scene to append to
  43648. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43649. * @param onProgress a callback with a progress event for each file being loaded
  43650. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43651. * @param pluginExtension the extension used to determine the plugin
  43652. * @returns The loaded plugin
  43653. */
  43654. 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>;
  43655. /**
  43656. * Import meshes into a scene
  43657. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43658. * @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)
  43659. * @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)
  43660. * @param scene the instance of BABYLON.Scene to append to
  43661. * @param onProgress a callback with a progress event for each file being loaded
  43662. * @param pluginExtension the extension used to determine the plugin
  43663. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43664. */
  43665. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43666. meshes: AbstractMesh[];
  43667. particleSystems: IParticleSystem[];
  43668. skeletons: Skeleton[];
  43669. animationGroups: AnimationGroup[];
  43670. }>;
  43671. /**
  43672. * Load a scene
  43673. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  43674. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  43675. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43676. * @param onSuccess a callback with the scene when import succeeds
  43677. * @param onProgress a callback with a progress event for each file being loaded
  43678. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43679. * @param pluginExtension the extension used to determine the plugin
  43680. * @returns The loaded plugin
  43681. */
  43682. static 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>;
  43683. /**
  43684. * Load a scene
  43685. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  43686. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  43687. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43688. * @param onProgress a callback with a progress event for each file being loaded
  43689. * @param pluginExtension the extension used to determine the plugin
  43690. * @returns The loaded scene
  43691. */
  43692. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43693. /**
  43694. * Append a scene
  43695. * @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)
  43696. * @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)
  43697. * @param scene is the instance of BABYLON.Scene to append to
  43698. * @param onSuccess a callback with the scene when import succeeds
  43699. * @param onProgress a callback with a progress event for each file being loaded
  43700. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43701. * @param pluginExtension the extension used to determine the plugin
  43702. * @returns The loaded plugin
  43703. */
  43704. 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>;
  43705. /**
  43706. * Append a scene
  43707. * @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)
  43708. * @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)
  43709. * @param scene is the instance of BABYLON.Scene to append to
  43710. * @param onProgress a callback with a progress event for each file being loaded
  43711. * @param pluginExtension the extension used to determine the plugin
  43712. * @returns The given scene
  43713. */
  43714. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43715. /**
  43716. * Load a scene into an asset container
  43717. * @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)
  43718. * @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)
  43719. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43720. * @param onSuccess a callback with the scene when import succeeds
  43721. * @param onProgress a callback with a progress event for each file being loaded
  43722. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43723. * @param pluginExtension the extension used to determine the plugin
  43724. * @returns The loaded plugin
  43725. */
  43726. 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>;
  43727. /**
  43728. * Load a scene into an asset container
  43729. * @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)
  43730. * @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)
  43731. * @param scene is the instance of Scene to append to
  43732. * @param onProgress a callback with a progress event for each file being loaded
  43733. * @param pluginExtension the extension used to determine the plugin
  43734. * @returns The loaded asset container
  43735. */
  43736. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43737. }
  43738. }
  43739. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  43740. import { Scene } from "babylonjs/scene";
  43741. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43742. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43743. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43744. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43745. /**
  43746. * Google Daydream controller
  43747. */
  43748. export class DaydreamController extends WebVRController {
  43749. /**
  43750. * Base Url for the controller model.
  43751. */
  43752. static MODEL_BASE_URL: string;
  43753. /**
  43754. * File name for the controller model.
  43755. */
  43756. static MODEL_FILENAME: string;
  43757. /**
  43758. * Gamepad Id prefix used to identify Daydream Controller.
  43759. */
  43760. static readonly GAMEPAD_ID_PREFIX: string;
  43761. /**
  43762. * Creates a new DaydreamController from a gamepad
  43763. * @param vrGamepad the gamepad that the controller should be created from
  43764. */
  43765. constructor(vrGamepad: any);
  43766. /**
  43767. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43768. * @param scene scene in which to add meshes
  43769. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43770. */
  43771. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43772. /**
  43773. * Called once for each button that changed state since the last frame
  43774. * @param buttonIdx Which button index changed
  43775. * @param state New state of the button
  43776. * @param changes Which properties on the state changed since last frame
  43777. */
  43778. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43779. }
  43780. }
  43781. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  43782. import { Scene } from "babylonjs/scene";
  43783. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43784. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43785. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43786. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43787. /**
  43788. * Gear VR Controller
  43789. */
  43790. export class GearVRController extends WebVRController {
  43791. /**
  43792. * Base Url for the controller model.
  43793. */
  43794. static MODEL_BASE_URL: string;
  43795. /**
  43796. * File name for the controller model.
  43797. */
  43798. static MODEL_FILENAME: string;
  43799. /**
  43800. * Gamepad Id prefix used to identify this controller.
  43801. */
  43802. static readonly GAMEPAD_ID_PREFIX: string;
  43803. private readonly _buttonIndexToObservableNameMap;
  43804. /**
  43805. * Creates a new GearVRController from a gamepad
  43806. * @param vrGamepad the gamepad that the controller should be created from
  43807. */
  43808. constructor(vrGamepad: any);
  43809. /**
  43810. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43811. * @param scene scene in which to add meshes
  43812. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43813. */
  43814. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43815. /**
  43816. * Called once for each button that changed state since the last frame
  43817. * @param buttonIdx Which button index changed
  43818. * @param state New state of the button
  43819. * @param changes Which properties on the state changed since last frame
  43820. */
  43821. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43822. }
  43823. }
  43824. declare module "babylonjs/Gamepads/Controllers/genericController" {
  43825. import { Scene } from "babylonjs/scene";
  43826. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43827. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43828. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43829. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43830. /**
  43831. * Generic Controller
  43832. */
  43833. export class GenericController extends WebVRController {
  43834. /**
  43835. * Base Url for the controller model.
  43836. */
  43837. static readonly MODEL_BASE_URL: string;
  43838. /**
  43839. * File name for the controller model.
  43840. */
  43841. static readonly MODEL_FILENAME: string;
  43842. /**
  43843. * Creates a new GenericController from a gamepad
  43844. * @param vrGamepad the gamepad that the controller should be created from
  43845. */
  43846. constructor(vrGamepad: any);
  43847. /**
  43848. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43849. * @param scene scene in which to add meshes
  43850. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43851. */
  43852. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43853. /**
  43854. * Called once for each button that changed state since the last frame
  43855. * @param buttonIdx Which button index changed
  43856. * @param state New state of the button
  43857. * @param changes Which properties on the state changed since last frame
  43858. */
  43859. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43860. }
  43861. }
  43862. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  43863. import { Observable } from "babylonjs/Misc/observable";
  43864. import { Scene } from "babylonjs/scene";
  43865. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43866. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43867. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43868. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43869. /**
  43870. * Oculus Touch Controller
  43871. */
  43872. export class OculusTouchController extends WebVRController {
  43873. /**
  43874. * Base Url for the controller model.
  43875. */
  43876. static MODEL_BASE_URL: string;
  43877. /**
  43878. * File name for the left controller model.
  43879. */
  43880. static MODEL_LEFT_FILENAME: string;
  43881. /**
  43882. * File name for the right controller model.
  43883. */
  43884. static MODEL_RIGHT_FILENAME: string;
  43885. /**
  43886. * Fired when the secondary trigger on this controller is modified
  43887. */
  43888. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  43889. /**
  43890. * Fired when the thumb rest on this controller is modified
  43891. */
  43892. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  43893. /**
  43894. * Creates a new OculusTouchController from a gamepad
  43895. * @param vrGamepad the gamepad that the controller should be created from
  43896. */
  43897. constructor(vrGamepad: any);
  43898. /**
  43899. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43900. * @param scene scene in which to add meshes
  43901. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43902. */
  43903. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43904. /**
  43905. * Fired when the A button on this controller is modified
  43906. */
  43907. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43908. /**
  43909. * Fired when the B button on this controller is modified
  43910. */
  43911. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43912. /**
  43913. * Fired when the X button on this controller is modified
  43914. */
  43915. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43916. /**
  43917. * Fired when the Y button on this controller is modified
  43918. */
  43919. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43920. /**
  43921. * Called once for each button that changed state since the last frame
  43922. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  43923. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  43924. * 2) secondary trigger (same)
  43925. * 3) A (right) X (left), touch, pressed = value
  43926. * 4) B / Y
  43927. * 5) thumb rest
  43928. * @param buttonIdx Which button index changed
  43929. * @param state New state of the button
  43930. * @param changes Which properties on the state changed since last frame
  43931. */
  43932. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43933. }
  43934. }
  43935. declare module "babylonjs/Gamepads/Controllers/viveController" {
  43936. import { Scene } from "babylonjs/scene";
  43937. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43938. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43939. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43940. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43941. import { Observable } from "babylonjs/Misc/observable";
  43942. /**
  43943. * Vive Controller
  43944. */
  43945. export class ViveController extends WebVRController {
  43946. /**
  43947. * Base Url for the controller model.
  43948. */
  43949. static MODEL_BASE_URL: string;
  43950. /**
  43951. * File name for the controller model.
  43952. */
  43953. static MODEL_FILENAME: string;
  43954. /**
  43955. * Creates a new ViveController from a gamepad
  43956. * @param vrGamepad the gamepad that the controller should be created from
  43957. */
  43958. constructor(vrGamepad: any);
  43959. /**
  43960. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43961. * @param scene scene in which to add meshes
  43962. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43963. */
  43964. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43965. /**
  43966. * Fired when the left button on this controller is modified
  43967. */
  43968. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43969. /**
  43970. * Fired when the right button on this controller is modified
  43971. */
  43972. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43973. /**
  43974. * Fired when the menu button on this controller is modified
  43975. */
  43976. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43977. /**
  43978. * Called once for each button that changed state since the last frame
  43979. * Vive mapping:
  43980. * 0: touchpad
  43981. * 1: trigger
  43982. * 2: left AND right buttons
  43983. * 3: menu button
  43984. * @param buttonIdx Which button index changed
  43985. * @param state New state of the button
  43986. * @param changes Which properties on the state changed since last frame
  43987. */
  43988. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43989. }
  43990. }
  43991. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  43992. import { Observable } from "babylonjs/Misc/observable";
  43993. import { Scene } from "babylonjs/scene";
  43994. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43995. import { Ray } from "babylonjs/Culling/ray";
  43996. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43997. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43998. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43999. /**
  44000. * Defines the WindowsMotionController object that the state of the windows motion controller
  44001. */
  44002. export class WindowsMotionController extends WebVRController {
  44003. /**
  44004. * The base url used to load the left and right controller models
  44005. */
  44006. static MODEL_BASE_URL: string;
  44007. /**
  44008. * The name of the left controller model file
  44009. */
  44010. static MODEL_LEFT_FILENAME: string;
  44011. /**
  44012. * The name of the right controller model file
  44013. */
  44014. static MODEL_RIGHT_FILENAME: string;
  44015. /**
  44016. * The controller name prefix for this controller type
  44017. */
  44018. static readonly GAMEPAD_ID_PREFIX: string;
  44019. /**
  44020. * The controller id pattern for this controller type
  44021. */
  44022. private static readonly GAMEPAD_ID_PATTERN;
  44023. private _loadedMeshInfo;
  44024. private readonly _mapping;
  44025. /**
  44026. * Fired when the trackpad on this controller is clicked
  44027. */
  44028. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  44029. /**
  44030. * Fired when the trackpad on this controller is modified
  44031. */
  44032. onTrackpadValuesChangedObservable: Observable<StickValues>;
  44033. /**
  44034. * The current x and y values of this controller's trackpad
  44035. */
  44036. trackpad: StickValues;
  44037. /**
  44038. * Creates a new WindowsMotionController from a gamepad
  44039. * @param vrGamepad the gamepad that the controller should be created from
  44040. */
  44041. constructor(vrGamepad: any);
  44042. /**
  44043. * Fired when the trigger on this controller is modified
  44044. */
  44045. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44046. /**
  44047. * Fired when the menu button on this controller is modified
  44048. */
  44049. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44050. /**
  44051. * Fired when the grip button on this controller is modified
  44052. */
  44053. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44054. /**
  44055. * Fired when the thumbstick button on this controller is modified
  44056. */
  44057. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44058. /**
  44059. * Fired when the touchpad button on this controller is modified
  44060. */
  44061. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44062. /**
  44063. * Fired when the touchpad values on this controller are modified
  44064. */
  44065. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  44066. private _updateTrackpad;
  44067. /**
  44068. * Called once per frame by the engine.
  44069. */
  44070. update(): void;
  44071. /**
  44072. * Called once for each button that changed state since the last frame
  44073. * @param buttonIdx Which button index changed
  44074. * @param state New state of the button
  44075. * @param changes Which properties on the state changed since last frame
  44076. */
  44077. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44078. /**
  44079. * Moves the buttons on the controller mesh based on their current state
  44080. * @param buttonName the name of the button to move
  44081. * @param buttonValue the value of the button which determines the buttons new position
  44082. */
  44083. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  44084. /**
  44085. * Moves the axis on the controller mesh based on its current state
  44086. * @param axis the index of the axis
  44087. * @param axisValue the value of the axis which determines the meshes new position
  44088. * @hidden
  44089. */
  44090. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  44091. /**
  44092. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44093. * @param scene scene in which to add meshes
  44094. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44095. */
  44096. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  44097. /**
  44098. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  44099. * can be transformed by button presses and axes values, based on this._mapping.
  44100. *
  44101. * @param scene scene in which the meshes exist
  44102. * @param meshes list of meshes that make up the controller model to process
  44103. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  44104. */
  44105. private processModel;
  44106. private createMeshInfo;
  44107. /**
  44108. * Gets the ray of the controller in the direction the controller is pointing
  44109. * @param length the length the resulting ray should be
  44110. * @returns a ray in the direction the controller is pointing
  44111. */
  44112. getForwardRay(length?: number): Ray;
  44113. /**
  44114. * Disposes of the controller
  44115. */
  44116. dispose(): void;
  44117. }
  44118. }
  44119. declare module "babylonjs/Gamepads/Controllers/index" {
  44120. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  44121. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  44122. export * from "babylonjs/Gamepads/Controllers/genericController";
  44123. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  44124. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44125. export * from "babylonjs/Gamepads/Controllers/viveController";
  44126. export * from "babylonjs/Gamepads/Controllers/webVRController";
  44127. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  44128. }
  44129. declare module "babylonjs/Gamepads/index" {
  44130. export * from "babylonjs/Gamepads/Controllers/index";
  44131. export * from "babylonjs/Gamepads/gamepad";
  44132. export * from "babylonjs/Gamepads/gamepadManager";
  44133. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  44134. export * from "babylonjs/Gamepads/xboxGamepad";
  44135. }
  44136. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  44137. import { Observable } from "babylonjs/Misc/observable";
  44138. import { Nullable } from "babylonjs/types";
  44139. import { Vector3, Color3 } from "babylonjs/Maths/math";
  44140. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44141. import { Mesh } from "babylonjs/Meshes/mesh";
  44142. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44143. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44144. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44145. /**
  44146. * Single axis scale gizmo
  44147. */
  44148. export class AxisScaleGizmo extends Gizmo {
  44149. private _coloredMaterial;
  44150. /**
  44151. * Drag behavior responsible for the gizmos dragging interactions
  44152. */
  44153. dragBehavior: PointerDragBehavior;
  44154. private _pointerObserver;
  44155. /**
  44156. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44157. */
  44158. snapDistance: number;
  44159. /**
  44160. * Event that fires each time the gizmo snaps to a new location.
  44161. * * snapDistance is the the change in distance
  44162. */
  44163. onSnapObservable: Observable<{
  44164. snapDistance: number;
  44165. }>;
  44166. /**
  44167. * If the scaling operation should be done on all axis (default: false)
  44168. */
  44169. uniformScaling: boolean;
  44170. /**
  44171. * Creates an AxisScaleGizmo
  44172. * @param gizmoLayer The utility layer the gizmo will be added to
  44173. * @param dragAxis The axis which the gizmo will be able to scale on
  44174. * @param color The color of the gizmo
  44175. */
  44176. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  44177. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44178. /**
  44179. * Disposes of the gizmo
  44180. */
  44181. dispose(): void;
  44182. /**
  44183. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  44184. * @param mesh The mesh to replace the default mesh of the gizmo
  44185. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  44186. */
  44187. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  44188. }
  44189. }
  44190. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  44191. import { Observable } from "babylonjs/Misc/observable";
  44192. import { Nullable } from "babylonjs/types";
  44193. import { Vector3, Color3 } from "babylonjs/Maths/math";
  44194. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44195. import { Mesh } from "babylonjs/Meshes/mesh";
  44196. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44197. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44198. import "babylonjs/Meshes/Builders/boxBuilder";
  44199. /**
  44200. * Bounding box gizmo
  44201. */
  44202. export class BoundingBoxGizmo extends Gizmo {
  44203. private _lineBoundingBox;
  44204. private _rotateSpheresParent;
  44205. private _scaleBoxesParent;
  44206. private _boundingDimensions;
  44207. private _renderObserver;
  44208. private _pointerObserver;
  44209. private _scaleDragSpeed;
  44210. private _tmpQuaternion;
  44211. private _tmpVector;
  44212. private _tmpRotationMatrix;
  44213. /**
  44214. * 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)
  44215. */
  44216. ignoreChildren: boolean;
  44217. /**
  44218. * 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)
  44219. */
  44220. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  44221. /**
  44222. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  44223. */
  44224. rotationSphereSize: number;
  44225. /**
  44226. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  44227. */
  44228. scaleBoxSize: number;
  44229. /**
  44230. * 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)
  44231. */
  44232. fixedDragMeshScreenSize: boolean;
  44233. /**
  44234. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  44235. */
  44236. fixedDragMeshScreenSizeDistanceFactor: number;
  44237. /**
  44238. * Fired when a rotation sphere or scale box is dragged
  44239. */
  44240. onDragStartObservable: Observable<{}>;
  44241. /**
  44242. * Fired when a scale box is dragged
  44243. */
  44244. onScaleBoxDragObservable: Observable<{}>;
  44245. /**
  44246. * Fired when a scale box drag is ended
  44247. */
  44248. onScaleBoxDragEndObservable: Observable<{}>;
  44249. /**
  44250. * Fired when a rotation sphere is dragged
  44251. */
  44252. onRotationSphereDragObservable: Observable<{}>;
  44253. /**
  44254. * Fired when a rotation sphere drag is ended
  44255. */
  44256. onRotationSphereDragEndObservable: Observable<{}>;
  44257. /**
  44258. * 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)
  44259. */
  44260. scalePivot: Nullable<Vector3>;
  44261. /**
  44262. * Mesh used as a pivot to rotate the attached mesh
  44263. */
  44264. private _anchorMesh;
  44265. private _existingMeshScale;
  44266. private _dragMesh;
  44267. private pointerDragBehavior;
  44268. private coloredMaterial;
  44269. private hoverColoredMaterial;
  44270. /**
  44271. * Sets the color of the bounding box gizmo
  44272. * @param color the color to set
  44273. */
  44274. setColor(color: Color3): void;
  44275. /**
  44276. * Creates an BoundingBoxGizmo
  44277. * @param gizmoLayer The utility layer the gizmo will be added to
  44278. * @param color The color of the gizmo
  44279. */
  44280. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  44281. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44282. private _selectNode;
  44283. /**
  44284. * Updates the bounding box information for the Gizmo
  44285. */
  44286. updateBoundingBox(): void;
  44287. private _updateRotationSpheres;
  44288. private _updateScaleBoxes;
  44289. /**
  44290. * Enables rotation on the specified axis and disables rotation on the others
  44291. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  44292. */
  44293. setEnabledRotationAxis(axis: string): void;
  44294. /**
  44295. * Enables/disables scaling
  44296. * @param enable if scaling should be enabled
  44297. */
  44298. setEnabledScaling(enable: boolean): void;
  44299. private _updateDummy;
  44300. /**
  44301. * Enables a pointer drag behavior on the bounding box of the gizmo
  44302. */
  44303. enableDragBehavior(): void;
  44304. /**
  44305. * Disposes of the gizmo
  44306. */
  44307. dispose(): void;
  44308. /**
  44309. * 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)
  44310. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  44311. * @returns the bounding box mesh with the passed in mesh as a child
  44312. */
  44313. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  44314. /**
  44315. * CustomMeshes are not supported by this gizmo
  44316. * @param mesh The mesh to replace the default mesh of the gizmo
  44317. */
  44318. setCustomMesh(mesh: Mesh): void;
  44319. }
  44320. }
  44321. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  44322. import { Observable } from "babylonjs/Misc/observable";
  44323. import { Nullable } from "babylonjs/types";
  44324. import { Vector3, Color3 } from "babylonjs/Maths/math";
  44325. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44326. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44327. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44328. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44329. import "babylonjs/Meshes/Builders/linesBuilder";
  44330. /**
  44331. * Single plane rotation gizmo
  44332. */
  44333. export class PlaneRotationGizmo extends Gizmo {
  44334. /**
  44335. * Drag behavior responsible for the gizmos dragging interactions
  44336. */
  44337. dragBehavior: PointerDragBehavior;
  44338. private _pointerObserver;
  44339. /**
  44340. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  44341. */
  44342. snapDistance: number;
  44343. /**
  44344. * Event that fires each time the gizmo snaps to a new location.
  44345. * * snapDistance is the the change in distance
  44346. */
  44347. onSnapObservable: Observable<{
  44348. snapDistance: number;
  44349. }>;
  44350. /**
  44351. * Creates a PlaneRotationGizmo
  44352. * @param gizmoLayer The utility layer the gizmo will be added to
  44353. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  44354. * @param color The color of the gizmo
  44355. * @param tessellation Amount of tessellation to be used when creating rotation circles
  44356. */
  44357. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  44358. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44359. /**
  44360. * Disposes of the gizmo
  44361. */
  44362. dispose(): void;
  44363. }
  44364. }
  44365. declare module "babylonjs/Gizmos/rotationGizmo" {
  44366. import { Observable } from "babylonjs/Misc/observable";
  44367. import { Nullable } from "babylonjs/types";
  44368. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44369. import { Mesh } from "babylonjs/Meshes/mesh";
  44370. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44371. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  44372. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44373. /**
  44374. * Gizmo that enables rotating a mesh along 3 axis
  44375. */
  44376. export class RotationGizmo extends Gizmo {
  44377. /**
  44378. * Internal gizmo used for interactions on the x axis
  44379. */
  44380. xGizmo: PlaneRotationGizmo;
  44381. /**
  44382. * Internal gizmo used for interactions on the y axis
  44383. */
  44384. yGizmo: PlaneRotationGizmo;
  44385. /**
  44386. * Internal gizmo used for interactions on the z axis
  44387. */
  44388. zGizmo: PlaneRotationGizmo;
  44389. /** Fires an event when any of it's sub gizmos are dragged */
  44390. onDragStartObservable: Observable<{}>;
  44391. /** Fires an event when any of it's sub gizmos are released from dragging */
  44392. onDragEndObservable: Observable<{}>;
  44393. attachedMesh: Nullable<AbstractMesh>;
  44394. /**
  44395. * Creates a RotationGizmo
  44396. * @param gizmoLayer The utility layer the gizmo will be added to
  44397. * @param tessellation Amount of tessellation to be used when creating rotation circles
  44398. */
  44399. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  44400. updateGizmoRotationToMatchAttachedMesh: boolean;
  44401. /**
  44402. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44403. */
  44404. snapDistance: number;
  44405. /**
  44406. * Ratio for the scale of the gizmo (Default: 1)
  44407. */
  44408. scaleRatio: number;
  44409. /**
  44410. * Disposes of the gizmo
  44411. */
  44412. dispose(): void;
  44413. /**
  44414. * CustomMeshes are not supported by this gizmo
  44415. * @param mesh The mesh to replace the default mesh of the gizmo
  44416. */
  44417. setCustomMesh(mesh: Mesh): void;
  44418. }
  44419. }
  44420. declare module "babylonjs/Gizmos/positionGizmo" {
  44421. import { Observable } from "babylonjs/Misc/observable";
  44422. import { Nullable } from "babylonjs/types";
  44423. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44424. import { Mesh } from "babylonjs/Meshes/mesh";
  44425. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44426. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  44427. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44428. /**
  44429. * Gizmo that enables dragging a mesh along 3 axis
  44430. */
  44431. export class PositionGizmo extends Gizmo {
  44432. /**
  44433. * Internal gizmo used for interactions on the x axis
  44434. */
  44435. xGizmo: AxisDragGizmo;
  44436. /**
  44437. * Internal gizmo used for interactions on the y axis
  44438. */
  44439. yGizmo: AxisDragGizmo;
  44440. /**
  44441. * Internal gizmo used for interactions on the z axis
  44442. */
  44443. zGizmo: AxisDragGizmo;
  44444. /** Fires an event when any of it's sub gizmos are dragged */
  44445. onDragStartObservable: Observable<{}>;
  44446. /** Fires an event when any of it's sub gizmos are released from dragging */
  44447. onDragEndObservable: Observable<{}>;
  44448. attachedMesh: Nullable<AbstractMesh>;
  44449. /**
  44450. * Creates a PositionGizmo
  44451. * @param gizmoLayer The utility layer the gizmo will be added to
  44452. */
  44453. constructor(gizmoLayer?: UtilityLayerRenderer);
  44454. updateGizmoRotationToMatchAttachedMesh: boolean;
  44455. /**
  44456. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44457. */
  44458. snapDistance: number;
  44459. /**
  44460. * Ratio for the scale of the gizmo (Default: 1)
  44461. */
  44462. scaleRatio: number;
  44463. /**
  44464. * Disposes of the gizmo
  44465. */
  44466. dispose(): void;
  44467. /**
  44468. * CustomMeshes are not supported by this gizmo
  44469. * @param mesh The mesh to replace the default mesh of the gizmo
  44470. */
  44471. setCustomMesh(mesh: Mesh): void;
  44472. }
  44473. }
  44474. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  44475. import { Scene } from "babylonjs/scene";
  44476. import { Color4, Vector4 } from "babylonjs/Maths/math";
  44477. import { Mesh } from "babylonjs/Meshes/mesh";
  44478. import { Nullable } from "babylonjs/types";
  44479. /**
  44480. * Class containing static functions to help procedurally build meshes
  44481. */
  44482. export class PolyhedronBuilder {
  44483. /**
  44484. * Creates a polyhedron mesh
  44485. * * 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
  44486. * * The parameter `size` (positive float, default 1) sets the polygon size
  44487. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  44488. * * 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`
  44489. * * 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
  44490. * * 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)`)
  44491. * * 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
  44492. * * 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
  44493. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44494. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44495. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44496. * @param name defines the name of the mesh
  44497. * @param options defines the options used to create the mesh
  44498. * @param scene defines the hosting scene
  44499. * @returns the polyhedron mesh
  44500. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  44501. */
  44502. static CreatePolyhedron(name: string, options: {
  44503. type?: number;
  44504. size?: number;
  44505. sizeX?: number;
  44506. sizeY?: number;
  44507. sizeZ?: number;
  44508. custom?: any;
  44509. faceUV?: Vector4[];
  44510. faceColors?: Color4[];
  44511. flat?: boolean;
  44512. updatable?: boolean;
  44513. sideOrientation?: number;
  44514. frontUVs?: Vector4;
  44515. backUVs?: Vector4;
  44516. }, scene?: Nullable<Scene>): Mesh;
  44517. }
  44518. }
  44519. declare module "babylonjs/Gizmos/scaleGizmo" {
  44520. import { Observable } from "babylonjs/Misc/observable";
  44521. import { Nullable } from "babylonjs/types";
  44522. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44523. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44524. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  44525. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44526. /**
  44527. * Gizmo that enables scaling a mesh along 3 axis
  44528. */
  44529. export class ScaleGizmo extends Gizmo {
  44530. /**
  44531. * Internal gizmo used for interactions on the x axis
  44532. */
  44533. xGizmo: AxisScaleGizmo;
  44534. /**
  44535. * Internal gizmo used for interactions on the y axis
  44536. */
  44537. yGizmo: AxisScaleGizmo;
  44538. /**
  44539. * Internal gizmo used for interactions on the z axis
  44540. */
  44541. zGizmo: AxisScaleGizmo;
  44542. /**
  44543. * Internal gizmo used to scale all axis equally
  44544. */
  44545. uniformScaleGizmo: AxisScaleGizmo;
  44546. /** Fires an event when any of it's sub gizmos are dragged */
  44547. onDragStartObservable: Observable<{}>;
  44548. /** Fires an event when any of it's sub gizmos are released from dragging */
  44549. onDragEndObservable: Observable<{}>;
  44550. attachedMesh: Nullable<AbstractMesh>;
  44551. /**
  44552. * Creates a ScaleGizmo
  44553. * @param gizmoLayer The utility layer the gizmo will be added to
  44554. */
  44555. constructor(gizmoLayer?: UtilityLayerRenderer);
  44556. updateGizmoRotationToMatchAttachedMesh: boolean;
  44557. /**
  44558. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44559. */
  44560. snapDistance: number;
  44561. /**
  44562. * Ratio for the scale of the gizmo (Default: 1)
  44563. */
  44564. scaleRatio: number;
  44565. /**
  44566. * Disposes of the gizmo
  44567. */
  44568. dispose(): void;
  44569. }
  44570. }
  44571. declare module "babylonjs/Gizmos/gizmoManager" {
  44572. import { Observable } from "babylonjs/Misc/observable";
  44573. import { Nullable } from "babylonjs/types";
  44574. import { Scene, IDisposable } from "babylonjs/scene";
  44575. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44576. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  44577. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  44578. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44579. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  44580. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  44581. /**
  44582. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  44583. */
  44584. export class GizmoManager implements IDisposable {
  44585. private scene;
  44586. /**
  44587. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  44588. */
  44589. gizmos: {
  44590. positionGizmo: Nullable<PositionGizmo>;
  44591. rotationGizmo: Nullable<RotationGizmo>;
  44592. scaleGizmo: Nullable<ScaleGizmo>;
  44593. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  44594. };
  44595. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  44596. clearGizmoOnEmptyPointerEvent: boolean;
  44597. /** Fires an event when the manager is attached to a mesh */
  44598. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  44599. private _gizmosEnabled;
  44600. private _pointerObserver;
  44601. private _attachedMesh;
  44602. private _boundingBoxColor;
  44603. private _defaultUtilityLayer;
  44604. private _defaultKeepDepthUtilityLayer;
  44605. /**
  44606. * When bounding box gizmo is enabled, this can be used to track drag/end events
  44607. */
  44608. boundingBoxDragBehavior: SixDofDragBehavior;
  44609. /**
  44610. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  44611. */
  44612. attachableMeshes: Nullable<Array<AbstractMesh>>;
  44613. /**
  44614. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  44615. */
  44616. usePointerToAttachGizmos: boolean;
  44617. /**
  44618. * Instatiates a gizmo manager
  44619. * @param scene the scene to overlay the gizmos on top of
  44620. */
  44621. constructor(scene: Scene);
  44622. /**
  44623. * Attaches a set of gizmos to the specified mesh
  44624. * @param mesh The mesh the gizmo's should be attached to
  44625. */
  44626. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  44627. /**
  44628. * If the position gizmo is enabled
  44629. */
  44630. positionGizmoEnabled: boolean;
  44631. /**
  44632. * If the rotation gizmo is enabled
  44633. */
  44634. rotationGizmoEnabled: boolean;
  44635. /**
  44636. * If the scale gizmo is enabled
  44637. */
  44638. scaleGizmoEnabled: boolean;
  44639. /**
  44640. * If the boundingBox gizmo is enabled
  44641. */
  44642. boundingBoxGizmoEnabled: boolean;
  44643. /**
  44644. * Disposes of the gizmo manager
  44645. */
  44646. dispose(): void;
  44647. }
  44648. }
  44649. declare module "babylonjs/Lights/directionalLight" {
  44650. import { Camera } from "babylonjs/Cameras/camera";
  44651. import { Scene } from "babylonjs/scene";
  44652. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  44653. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44654. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  44655. import { Effect } from "babylonjs/Materials/effect";
  44656. /**
  44657. * A directional light is defined by a direction (what a surprise!).
  44658. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  44659. * 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.
  44660. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44661. */
  44662. export class DirectionalLight extends ShadowLight {
  44663. private _shadowFrustumSize;
  44664. /**
  44665. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  44666. */
  44667. /**
  44668. * Specifies a fix frustum size for the shadow generation.
  44669. */
  44670. shadowFrustumSize: number;
  44671. private _shadowOrthoScale;
  44672. /**
  44673. * Gets the shadow projection scale against the optimal computed one.
  44674. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44675. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44676. */
  44677. /**
  44678. * Sets the shadow projection scale against the optimal computed one.
  44679. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44680. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44681. */
  44682. shadowOrthoScale: number;
  44683. /**
  44684. * Automatically compute the projection matrix to best fit (including all the casters)
  44685. * on each frame.
  44686. */
  44687. autoUpdateExtends: boolean;
  44688. private _orthoLeft;
  44689. private _orthoRight;
  44690. private _orthoTop;
  44691. private _orthoBottom;
  44692. /**
  44693. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  44694. * The directional light is emitted from everywhere in the given direction.
  44695. * It can cast shadows.
  44696. * Documentation : https://doc.babylonjs.com/babylon101/lights
  44697. * @param name The friendly name of the light
  44698. * @param direction The direction of the light
  44699. * @param scene The scene the light belongs to
  44700. */
  44701. constructor(name: string, direction: Vector3, scene: Scene);
  44702. /**
  44703. * Returns the string "DirectionalLight".
  44704. * @return The class name
  44705. */
  44706. getClassName(): string;
  44707. /**
  44708. * Returns the integer 1.
  44709. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  44710. */
  44711. getTypeID(): number;
  44712. /**
  44713. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  44714. * Returns the DirectionalLight Shadow projection matrix.
  44715. */
  44716. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44717. /**
  44718. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  44719. * Returns the DirectionalLight Shadow projection matrix.
  44720. */
  44721. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  44722. /**
  44723. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  44724. * Returns the DirectionalLight Shadow projection matrix.
  44725. */
  44726. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44727. protected _buildUniformLayout(): void;
  44728. /**
  44729. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  44730. * @param effect The effect to update
  44731. * @param lightIndex The index of the light in the effect to update
  44732. * @returns The directional light
  44733. */
  44734. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  44735. /**
  44736. * Gets the minZ used for shadow according to both the scene and the light.
  44737. *
  44738. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  44739. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  44740. * @param activeCamera The camera we are returning the min for
  44741. * @returns the depth min z
  44742. */
  44743. getDepthMinZ(activeCamera: Camera): number;
  44744. /**
  44745. * Gets the maxZ used for shadow according to both the scene and the light.
  44746. *
  44747. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  44748. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  44749. * @param activeCamera The camera we are returning the max for
  44750. * @returns the depth max z
  44751. */
  44752. getDepthMaxZ(activeCamera: Camera): number;
  44753. /**
  44754. * Prepares the list of defines specific to the light type.
  44755. * @param defines the list of defines
  44756. * @param lightIndex defines the index of the light for the effect
  44757. */
  44758. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  44759. }
  44760. }
  44761. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  44762. import { Mesh } from "babylonjs/Meshes/mesh";
  44763. /**
  44764. * Class containing static functions to help procedurally build meshes
  44765. */
  44766. export class HemisphereBuilder {
  44767. /**
  44768. * Creates a hemisphere mesh
  44769. * @param name defines the name of the mesh
  44770. * @param options defines the options used to create the mesh
  44771. * @param scene defines the hosting scene
  44772. * @returns the hemisphere mesh
  44773. */
  44774. static CreateHemisphere(name: string, options: {
  44775. segments?: number;
  44776. diameter?: number;
  44777. sideOrientation?: number;
  44778. }, scene: any): Mesh;
  44779. }
  44780. }
  44781. declare module "babylonjs/Lights/spotLight" {
  44782. import { Nullable } from "babylonjs/types";
  44783. import { Scene } from "babylonjs/scene";
  44784. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  44785. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44786. import { Effect } from "babylonjs/Materials/effect";
  44787. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44788. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  44789. /**
  44790. * A spot light is defined by a position, a direction, an angle, and an exponent.
  44791. * These values define a cone of light starting from the position, emitting toward the direction.
  44792. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  44793. * and the exponent defines the speed of the decay of the light with distance (reach).
  44794. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44795. */
  44796. export class SpotLight extends ShadowLight {
  44797. private _angle;
  44798. private _innerAngle;
  44799. private _cosHalfAngle;
  44800. private _lightAngleScale;
  44801. private _lightAngleOffset;
  44802. /**
  44803. * Gets the cone angle of the spot light in Radians.
  44804. */
  44805. /**
  44806. * Sets the cone angle of the spot light in Radians.
  44807. */
  44808. angle: number;
  44809. /**
  44810. * Only used in gltf falloff mode, this defines the angle where
  44811. * the directional falloff will start before cutting at angle which could be seen
  44812. * as outer angle.
  44813. */
  44814. /**
  44815. * Only used in gltf falloff mode, this defines the angle where
  44816. * the directional falloff will start before cutting at angle which could be seen
  44817. * as outer angle.
  44818. */
  44819. innerAngle: number;
  44820. private _shadowAngleScale;
  44821. /**
  44822. * Allows scaling the angle of the light for shadow generation only.
  44823. */
  44824. /**
  44825. * Allows scaling the angle of the light for shadow generation only.
  44826. */
  44827. shadowAngleScale: number;
  44828. /**
  44829. * The light decay speed with the distance from the emission spot.
  44830. */
  44831. exponent: number;
  44832. private _projectionTextureMatrix;
  44833. /**
  44834. * Allows reading the projecton texture
  44835. */
  44836. readonly projectionTextureMatrix: Matrix;
  44837. protected _projectionTextureLightNear: number;
  44838. /**
  44839. * Gets the near clip of the Spotlight for texture projection.
  44840. */
  44841. /**
  44842. * Sets the near clip of the Spotlight for texture projection.
  44843. */
  44844. projectionTextureLightNear: number;
  44845. protected _projectionTextureLightFar: number;
  44846. /**
  44847. * Gets the far clip of the Spotlight for texture projection.
  44848. */
  44849. /**
  44850. * Sets the far clip of the Spotlight for texture projection.
  44851. */
  44852. projectionTextureLightFar: number;
  44853. protected _projectionTextureUpDirection: Vector3;
  44854. /**
  44855. * Gets the Up vector of the Spotlight for texture projection.
  44856. */
  44857. /**
  44858. * Sets the Up vector of the Spotlight for texture projection.
  44859. */
  44860. projectionTextureUpDirection: Vector3;
  44861. private _projectionTexture;
  44862. /**
  44863. * Gets the projection texture of the light.
  44864. */
  44865. /**
  44866. * Sets the projection texture of the light.
  44867. */
  44868. projectionTexture: Nullable<BaseTexture>;
  44869. private _projectionTextureViewLightDirty;
  44870. private _projectionTextureProjectionLightDirty;
  44871. private _projectionTextureDirty;
  44872. private _projectionTextureViewTargetVector;
  44873. private _projectionTextureViewLightMatrix;
  44874. private _projectionTextureProjectionLightMatrix;
  44875. private _projectionTextureScalingMatrix;
  44876. /**
  44877. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  44878. * It can cast shadows.
  44879. * Documentation : https://doc.babylonjs.com/babylon101/lights
  44880. * @param name The light friendly name
  44881. * @param position The position of the spot light in the scene
  44882. * @param direction The direction of the light in the scene
  44883. * @param angle The cone angle of the light in Radians
  44884. * @param exponent The light decay speed with the distance from the emission spot
  44885. * @param scene The scene the lights belongs to
  44886. */
  44887. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  44888. /**
  44889. * Returns the string "SpotLight".
  44890. * @returns the class name
  44891. */
  44892. getClassName(): string;
  44893. /**
  44894. * Returns the integer 2.
  44895. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  44896. */
  44897. getTypeID(): number;
  44898. /**
  44899. * Overrides the direction setter to recompute the projection texture view light Matrix.
  44900. */
  44901. protected _setDirection(value: Vector3): void;
  44902. /**
  44903. * Overrides the position setter to recompute the projection texture view light Matrix.
  44904. */
  44905. protected _setPosition(value: Vector3): void;
  44906. /**
  44907. * 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.
  44908. * Returns the SpotLight.
  44909. */
  44910. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44911. protected _computeProjectionTextureViewLightMatrix(): void;
  44912. protected _computeProjectionTextureProjectionLightMatrix(): void;
  44913. /**
  44914. * Main function for light texture projection matrix computing.
  44915. */
  44916. protected _computeProjectionTextureMatrix(): void;
  44917. protected _buildUniformLayout(): void;
  44918. private _computeAngleValues;
  44919. /**
  44920. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  44921. * @param effect The effect to update
  44922. * @param lightIndex The index of the light in the effect to update
  44923. * @returns The spot light
  44924. */
  44925. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  44926. /**
  44927. * Disposes the light and the associated resources.
  44928. */
  44929. dispose(): void;
  44930. /**
  44931. * Prepares the list of defines specific to the light type.
  44932. * @param defines the list of defines
  44933. * @param lightIndex defines the index of the light for the effect
  44934. */
  44935. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  44936. }
  44937. }
  44938. declare module "babylonjs/Gizmos/lightGizmo" {
  44939. import { Nullable } from "babylonjs/types";
  44940. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44941. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44942. import { Light } from "babylonjs/Lights/light";
  44943. /**
  44944. * Gizmo that enables viewing a light
  44945. */
  44946. export class LightGizmo extends Gizmo {
  44947. private _lightMesh;
  44948. private _material;
  44949. private cachedPosition;
  44950. private cachedForward;
  44951. /**
  44952. * Creates a LightGizmo
  44953. * @param gizmoLayer The utility layer the gizmo will be added to
  44954. */
  44955. constructor(gizmoLayer?: UtilityLayerRenderer);
  44956. private _light;
  44957. /**
  44958. * The light that the gizmo is attached to
  44959. */
  44960. light: Nullable<Light>;
  44961. /**
  44962. * @hidden
  44963. * Updates the gizmo to match the attached mesh's position/rotation
  44964. */
  44965. protected _update(): void;
  44966. private static _Scale;
  44967. /**
  44968. * Creates the lines for a light mesh
  44969. */
  44970. private static _createLightLines;
  44971. private static _CreateHemisphericLightMesh;
  44972. private static _CreatePointLightMesh;
  44973. private static _CreateSpotLightMesh;
  44974. private static _CreateDirectionalLightMesh;
  44975. }
  44976. }
  44977. declare module "babylonjs/Gizmos/index" {
  44978. export * from "babylonjs/Gizmos/axisDragGizmo";
  44979. export * from "babylonjs/Gizmos/axisScaleGizmo";
  44980. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  44981. export * from "babylonjs/Gizmos/gizmo";
  44982. export * from "babylonjs/Gizmos/gizmoManager";
  44983. export * from "babylonjs/Gizmos/planeRotationGizmo";
  44984. export * from "babylonjs/Gizmos/positionGizmo";
  44985. export * from "babylonjs/Gizmos/rotationGizmo";
  44986. export * from "babylonjs/Gizmos/scaleGizmo";
  44987. export * from "babylonjs/Gizmos/lightGizmo";
  44988. }
  44989. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  44990. /** @hidden */
  44991. export var backgroundFragmentDeclaration: {
  44992. name: string;
  44993. shader: string;
  44994. };
  44995. }
  44996. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  44997. /** @hidden */
  44998. export var backgroundUboDeclaration: {
  44999. name: string;
  45000. shader: string;
  45001. };
  45002. }
  45003. declare module "babylonjs/Shaders/background.fragment" {
  45004. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  45005. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  45006. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  45007. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  45008. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  45009. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  45010. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45011. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  45012. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  45013. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  45014. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  45015. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  45016. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  45017. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  45018. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  45019. /** @hidden */
  45020. export var backgroundPixelShader: {
  45021. name: string;
  45022. shader: string;
  45023. };
  45024. }
  45025. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  45026. /** @hidden */
  45027. export var backgroundVertexDeclaration: {
  45028. name: string;
  45029. shader: string;
  45030. };
  45031. }
  45032. declare module "babylonjs/Shaders/background.vertex" {
  45033. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  45034. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  45035. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45036. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  45037. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  45038. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  45039. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  45040. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  45041. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  45042. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  45043. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  45044. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  45045. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  45046. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  45047. /** @hidden */
  45048. export var backgroundVertexShader: {
  45049. name: string;
  45050. shader: string;
  45051. };
  45052. }
  45053. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  45054. import { Nullable, int, float } from "babylonjs/types";
  45055. import { Scene } from "babylonjs/scene";
  45056. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  45057. import { SubMesh } from "babylonjs/Meshes/subMesh";
  45058. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45059. import { Mesh } from "babylonjs/Meshes/mesh";
  45060. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  45061. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  45062. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  45063. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45064. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  45065. import "babylonjs/Shaders/background.fragment";
  45066. import "babylonjs/Shaders/background.vertex";
  45067. /**
  45068. * Background material used to create an efficient environement around your scene.
  45069. */
  45070. export class BackgroundMaterial extends PushMaterial {
  45071. /**
  45072. * Standard reflectance value at parallel view angle.
  45073. */
  45074. static StandardReflectance0: number;
  45075. /**
  45076. * Standard reflectance value at grazing angle.
  45077. */
  45078. static StandardReflectance90: number;
  45079. protected _primaryColor: Color3;
  45080. /**
  45081. * Key light Color (multiply against the environement texture)
  45082. */
  45083. primaryColor: Color3;
  45084. protected __perceptualColor: Nullable<Color3>;
  45085. /**
  45086. * Experimental Internal Use Only.
  45087. *
  45088. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  45089. * This acts as a helper to set the primary color to a more "human friendly" value.
  45090. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  45091. * output color as close as possible from the chosen value.
  45092. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  45093. * part of lighting setup.)
  45094. */
  45095. _perceptualColor: Nullable<Color3>;
  45096. protected _primaryColorShadowLevel: float;
  45097. /**
  45098. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  45099. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  45100. */
  45101. primaryColorShadowLevel: float;
  45102. protected _primaryColorHighlightLevel: float;
  45103. /**
  45104. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  45105. * The primary color is used at the level chosen to define what the white area would look.
  45106. */
  45107. primaryColorHighlightLevel: float;
  45108. protected _reflectionTexture: Nullable<BaseTexture>;
  45109. /**
  45110. * Reflection Texture used in the material.
  45111. * Should be author in a specific way for the best result (refer to the documentation).
  45112. */
  45113. reflectionTexture: Nullable<BaseTexture>;
  45114. protected _reflectionBlur: float;
  45115. /**
  45116. * Reflection Texture level of blur.
  45117. *
  45118. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  45119. * texture twice.
  45120. */
  45121. reflectionBlur: float;
  45122. protected _diffuseTexture: Nullable<BaseTexture>;
  45123. /**
  45124. * Diffuse Texture used in the material.
  45125. * Should be author in a specific way for the best result (refer to the documentation).
  45126. */
  45127. diffuseTexture: Nullable<BaseTexture>;
  45128. protected _shadowLights: Nullable<IShadowLight[]>;
  45129. /**
  45130. * Specify the list of lights casting shadow on the material.
  45131. * All scene shadow lights will be included if null.
  45132. */
  45133. shadowLights: Nullable<IShadowLight[]>;
  45134. protected _shadowLevel: float;
  45135. /**
  45136. * Helps adjusting the shadow to a softer level if required.
  45137. * 0 means black shadows and 1 means no shadows.
  45138. */
  45139. shadowLevel: float;
  45140. protected _sceneCenter: Vector3;
  45141. /**
  45142. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  45143. * It is usually zero but might be interesting to modify according to your setup.
  45144. */
  45145. sceneCenter: Vector3;
  45146. protected _opacityFresnel: boolean;
  45147. /**
  45148. * This helps specifying that the material is falling off to the sky box at grazing angle.
  45149. * This helps ensuring a nice transition when the camera goes under the ground.
  45150. */
  45151. opacityFresnel: boolean;
  45152. protected _reflectionFresnel: boolean;
  45153. /**
  45154. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  45155. * This helps adding a mirror texture on the ground.
  45156. */
  45157. reflectionFresnel: boolean;
  45158. protected _reflectionFalloffDistance: number;
  45159. /**
  45160. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  45161. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  45162. */
  45163. reflectionFalloffDistance: number;
  45164. protected _reflectionAmount: number;
  45165. /**
  45166. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  45167. */
  45168. reflectionAmount: number;
  45169. protected _reflectionReflectance0: number;
  45170. /**
  45171. * This specifies the weight of the reflection at grazing angle.
  45172. */
  45173. reflectionReflectance0: number;
  45174. protected _reflectionReflectance90: number;
  45175. /**
  45176. * This specifies the weight of the reflection at a perpendicular point of view.
  45177. */
  45178. reflectionReflectance90: number;
  45179. /**
  45180. * Sets the reflection reflectance fresnel values according to the default standard
  45181. * empirically know to work well :-)
  45182. */
  45183. reflectionStandardFresnelWeight: number;
  45184. protected _useRGBColor: boolean;
  45185. /**
  45186. * Helps to directly use the maps channels instead of their level.
  45187. */
  45188. useRGBColor: boolean;
  45189. protected _enableNoise: boolean;
  45190. /**
  45191. * This helps reducing the banding effect that could occur on the background.
  45192. */
  45193. enableNoise: boolean;
  45194. /**
  45195. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45196. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  45197. * Recommended to be keep at 1.0 except for special cases.
  45198. */
  45199. fovMultiplier: number;
  45200. private _fovMultiplier;
  45201. /**
  45202. * Enable the FOV adjustment feature controlled by fovMultiplier.
  45203. */
  45204. useEquirectangularFOV: boolean;
  45205. private _maxSimultaneousLights;
  45206. /**
  45207. * Number of Simultaneous lights allowed on the material.
  45208. */
  45209. maxSimultaneousLights: int;
  45210. /**
  45211. * Default configuration related to image processing available in the Background Material.
  45212. */
  45213. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45214. /**
  45215. * Keep track of the image processing observer to allow dispose and replace.
  45216. */
  45217. private _imageProcessingObserver;
  45218. /**
  45219. * Attaches a new image processing configuration to the PBR Material.
  45220. * @param configuration (if null the scene configuration will be use)
  45221. */
  45222. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45223. /**
  45224. * Gets the image processing configuration used either in this material.
  45225. */
  45226. /**
  45227. * Sets the Default image processing configuration used either in the this material.
  45228. *
  45229. * If sets to null, the scene one is in use.
  45230. */
  45231. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  45232. /**
  45233. * Gets wether the color curves effect is enabled.
  45234. */
  45235. /**
  45236. * Sets wether the color curves effect is enabled.
  45237. */
  45238. cameraColorCurvesEnabled: boolean;
  45239. /**
  45240. * Gets wether the color grading effect is enabled.
  45241. */
  45242. /**
  45243. * Gets wether the color grading effect is enabled.
  45244. */
  45245. cameraColorGradingEnabled: boolean;
  45246. /**
  45247. * Gets wether tonemapping is enabled or not.
  45248. */
  45249. /**
  45250. * Sets wether tonemapping is enabled or not
  45251. */
  45252. cameraToneMappingEnabled: boolean;
  45253. /**
  45254. * The camera exposure used on this material.
  45255. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45256. * This corresponds to a photographic exposure.
  45257. */
  45258. /**
  45259. * The camera exposure used on this material.
  45260. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45261. * This corresponds to a photographic exposure.
  45262. */
  45263. cameraExposure: float;
  45264. /**
  45265. * Gets The camera contrast used on this material.
  45266. */
  45267. /**
  45268. * Sets The camera contrast used on this material.
  45269. */
  45270. cameraContrast: float;
  45271. /**
  45272. * Gets the Color Grading 2D Lookup Texture.
  45273. */
  45274. /**
  45275. * Sets the Color Grading 2D Lookup Texture.
  45276. */
  45277. cameraColorGradingTexture: Nullable<BaseTexture>;
  45278. /**
  45279. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45280. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45281. * 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;
  45282. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45283. */
  45284. /**
  45285. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45286. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45287. * 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;
  45288. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45289. */
  45290. cameraColorCurves: Nullable<ColorCurves>;
  45291. /**
  45292. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  45293. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  45294. */
  45295. switchToBGR: boolean;
  45296. private _renderTargets;
  45297. private _reflectionControls;
  45298. private _white;
  45299. private _primaryShadowColor;
  45300. private _primaryHighlightColor;
  45301. /**
  45302. * Instantiates a Background Material in the given scene
  45303. * @param name The friendly name of the material
  45304. * @param scene The scene to add the material to
  45305. */
  45306. constructor(name: string, scene: Scene);
  45307. /**
  45308. * Gets a boolean indicating that current material needs to register RTT
  45309. */
  45310. readonly hasRenderTargetTextures: boolean;
  45311. /**
  45312. * The entire material has been created in order to prevent overdraw.
  45313. * @returns false
  45314. */
  45315. needAlphaTesting(): boolean;
  45316. /**
  45317. * The entire material has been created in order to prevent overdraw.
  45318. * @returns true if blending is enable
  45319. */
  45320. needAlphaBlending(): boolean;
  45321. /**
  45322. * Checks wether the material is ready to be rendered for a given mesh.
  45323. * @param mesh The mesh to render
  45324. * @param subMesh The submesh to check against
  45325. * @param useInstances Specify wether or not the material is used with instances
  45326. * @returns true if all the dependencies are ready (Textures, Effects...)
  45327. */
  45328. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45329. /**
  45330. * Compute the primary color according to the chosen perceptual color.
  45331. */
  45332. private _computePrimaryColorFromPerceptualColor;
  45333. /**
  45334. * Compute the highlights and shadow colors according to their chosen levels.
  45335. */
  45336. private _computePrimaryColors;
  45337. /**
  45338. * Build the uniform buffer used in the material.
  45339. */
  45340. buildUniformLayout(): void;
  45341. /**
  45342. * Unbind the material.
  45343. */
  45344. unbind(): void;
  45345. /**
  45346. * Bind only the world matrix to the material.
  45347. * @param world The world matrix to bind.
  45348. */
  45349. bindOnlyWorldMatrix(world: Matrix): void;
  45350. /**
  45351. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  45352. * @param world The world matrix to bind.
  45353. * @param subMesh The submesh to bind for.
  45354. */
  45355. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45356. /**
  45357. * Dispose the material.
  45358. * @param forceDisposeEffect Force disposal of the associated effect.
  45359. * @param forceDisposeTextures Force disposal of the associated textures.
  45360. */
  45361. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45362. /**
  45363. * Clones the material.
  45364. * @param name The cloned name.
  45365. * @returns The cloned material.
  45366. */
  45367. clone(name: string): BackgroundMaterial;
  45368. /**
  45369. * Serializes the current material to its JSON representation.
  45370. * @returns The JSON representation.
  45371. */
  45372. serialize(): any;
  45373. /**
  45374. * Gets the class name of the material
  45375. * @returns "BackgroundMaterial"
  45376. */
  45377. getClassName(): string;
  45378. /**
  45379. * Parse a JSON input to create back a background material.
  45380. * @param source The JSON data to parse
  45381. * @param scene The scene to create the parsed material in
  45382. * @param rootUrl The root url of the assets the material depends upon
  45383. * @returns the instantiated BackgroundMaterial.
  45384. */
  45385. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  45386. }
  45387. }
  45388. declare module "babylonjs/Helpers/environmentHelper" {
  45389. import { Observable } from "babylonjs/Misc/observable";
  45390. import { Nullable } from "babylonjs/types";
  45391. import { Scene } from "babylonjs/scene";
  45392. import { Vector3, Color3 } from "babylonjs/Maths/math";
  45393. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45394. import { Mesh } from "babylonjs/Meshes/mesh";
  45395. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45396. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  45397. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  45398. import "babylonjs/Meshes/Builders/planeBuilder";
  45399. import "babylonjs/Meshes/Builders/boxBuilder";
  45400. /**
  45401. * Represents the different options available during the creation of
  45402. * a Environment helper.
  45403. *
  45404. * This can control the default ground, skybox and image processing setup of your scene.
  45405. */
  45406. export interface IEnvironmentHelperOptions {
  45407. /**
  45408. * Specifies wether or not to create a ground.
  45409. * True by default.
  45410. */
  45411. createGround: boolean;
  45412. /**
  45413. * Specifies the ground size.
  45414. * 15 by default.
  45415. */
  45416. groundSize: number;
  45417. /**
  45418. * The texture used on the ground for the main color.
  45419. * Comes from the BabylonJS CDN by default.
  45420. *
  45421. * Remarks: Can be either a texture or a url.
  45422. */
  45423. groundTexture: string | BaseTexture;
  45424. /**
  45425. * The color mixed in the ground texture by default.
  45426. * BabylonJS clearColor by default.
  45427. */
  45428. groundColor: Color3;
  45429. /**
  45430. * Specifies the ground opacity.
  45431. * 1 by default.
  45432. */
  45433. groundOpacity: number;
  45434. /**
  45435. * Enables the ground to receive shadows.
  45436. * True by default.
  45437. */
  45438. enableGroundShadow: boolean;
  45439. /**
  45440. * Helps preventing the shadow to be fully black on the ground.
  45441. * 0.5 by default.
  45442. */
  45443. groundShadowLevel: number;
  45444. /**
  45445. * Creates a mirror texture attach to the ground.
  45446. * false by default.
  45447. */
  45448. enableGroundMirror: boolean;
  45449. /**
  45450. * Specifies the ground mirror size ratio.
  45451. * 0.3 by default as the default kernel is 64.
  45452. */
  45453. groundMirrorSizeRatio: number;
  45454. /**
  45455. * Specifies the ground mirror blur kernel size.
  45456. * 64 by default.
  45457. */
  45458. groundMirrorBlurKernel: number;
  45459. /**
  45460. * Specifies the ground mirror visibility amount.
  45461. * 1 by default
  45462. */
  45463. groundMirrorAmount: number;
  45464. /**
  45465. * Specifies the ground mirror reflectance weight.
  45466. * This uses the standard weight of the background material to setup the fresnel effect
  45467. * of the mirror.
  45468. * 1 by default.
  45469. */
  45470. groundMirrorFresnelWeight: number;
  45471. /**
  45472. * Specifies the ground mirror Falloff distance.
  45473. * This can helps reducing the size of the reflection.
  45474. * 0 by Default.
  45475. */
  45476. groundMirrorFallOffDistance: number;
  45477. /**
  45478. * Specifies the ground mirror texture type.
  45479. * Unsigned Int by Default.
  45480. */
  45481. groundMirrorTextureType: number;
  45482. /**
  45483. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  45484. * the shown objects.
  45485. */
  45486. groundYBias: number;
  45487. /**
  45488. * Specifies wether or not to create a skybox.
  45489. * True by default.
  45490. */
  45491. createSkybox: boolean;
  45492. /**
  45493. * Specifies the skybox size.
  45494. * 20 by default.
  45495. */
  45496. skyboxSize: number;
  45497. /**
  45498. * The texture used on the skybox for the main color.
  45499. * Comes from the BabylonJS CDN by default.
  45500. *
  45501. * Remarks: Can be either a texture or a url.
  45502. */
  45503. skyboxTexture: string | BaseTexture;
  45504. /**
  45505. * The color mixed in the skybox texture by default.
  45506. * BabylonJS clearColor by default.
  45507. */
  45508. skyboxColor: Color3;
  45509. /**
  45510. * The background rotation around the Y axis of the scene.
  45511. * This helps aligning the key lights of your scene with the background.
  45512. * 0 by default.
  45513. */
  45514. backgroundYRotation: number;
  45515. /**
  45516. * Compute automatically the size of the elements to best fit with the scene.
  45517. */
  45518. sizeAuto: boolean;
  45519. /**
  45520. * Default position of the rootMesh if autoSize is not true.
  45521. */
  45522. rootPosition: Vector3;
  45523. /**
  45524. * Sets up the image processing in the scene.
  45525. * true by default.
  45526. */
  45527. setupImageProcessing: boolean;
  45528. /**
  45529. * The texture used as your environment texture in the scene.
  45530. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  45531. *
  45532. * Remarks: Can be either a texture or a url.
  45533. */
  45534. environmentTexture: string | BaseTexture;
  45535. /**
  45536. * The value of the exposure to apply to the scene.
  45537. * 0.6 by default if setupImageProcessing is true.
  45538. */
  45539. cameraExposure: number;
  45540. /**
  45541. * The value of the contrast to apply to the scene.
  45542. * 1.6 by default if setupImageProcessing is true.
  45543. */
  45544. cameraContrast: number;
  45545. /**
  45546. * Specifies wether or not tonemapping should be enabled in the scene.
  45547. * true by default if setupImageProcessing is true.
  45548. */
  45549. toneMappingEnabled: boolean;
  45550. }
  45551. /**
  45552. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  45553. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  45554. * It also helps with the default setup of your imageProcessing configuration.
  45555. */
  45556. export class EnvironmentHelper {
  45557. /**
  45558. * Default ground texture URL.
  45559. */
  45560. private static _groundTextureCDNUrl;
  45561. /**
  45562. * Default skybox texture URL.
  45563. */
  45564. private static _skyboxTextureCDNUrl;
  45565. /**
  45566. * Default environment texture URL.
  45567. */
  45568. private static _environmentTextureCDNUrl;
  45569. /**
  45570. * Creates the default options for the helper.
  45571. */
  45572. private static _getDefaultOptions;
  45573. private _rootMesh;
  45574. /**
  45575. * Gets the root mesh created by the helper.
  45576. */
  45577. readonly rootMesh: Mesh;
  45578. private _skybox;
  45579. /**
  45580. * Gets the skybox created by the helper.
  45581. */
  45582. readonly skybox: Nullable<Mesh>;
  45583. private _skyboxTexture;
  45584. /**
  45585. * Gets the skybox texture created by the helper.
  45586. */
  45587. readonly skyboxTexture: Nullable<BaseTexture>;
  45588. private _skyboxMaterial;
  45589. /**
  45590. * Gets the skybox material created by the helper.
  45591. */
  45592. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  45593. private _ground;
  45594. /**
  45595. * Gets the ground mesh created by the helper.
  45596. */
  45597. readonly ground: Nullable<Mesh>;
  45598. private _groundTexture;
  45599. /**
  45600. * Gets the ground texture created by the helper.
  45601. */
  45602. readonly groundTexture: Nullable<BaseTexture>;
  45603. private _groundMirror;
  45604. /**
  45605. * Gets the ground mirror created by the helper.
  45606. */
  45607. readonly groundMirror: Nullable<MirrorTexture>;
  45608. /**
  45609. * Gets the ground mirror render list to helps pushing the meshes
  45610. * you wish in the ground reflection.
  45611. */
  45612. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  45613. private _groundMaterial;
  45614. /**
  45615. * Gets the ground material created by the helper.
  45616. */
  45617. readonly groundMaterial: Nullable<BackgroundMaterial>;
  45618. /**
  45619. * Stores the creation options.
  45620. */
  45621. private readonly _scene;
  45622. private _options;
  45623. /**
  45624. * This observable will be notified with any error during the creation of the environment,
  45625. * mainly texture creation errors.
  45626. */
  45627. onErrorObservable: Observable<{
  45628. message?: string;
  45629. exception?: any;
  45630. }>;
  45631. /**
  45632. * constructor
  45633. * @param options Defines the options we want to customize the helper
  45634. * @param scene The scene to add the material to
  45635. */
  45636. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  45637. /**
  45638. * Updates the background according to the new options
  45639. * @param options
  45640. */
  45641. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  45642. /**
  45643. * Sets the primary color of all the available elements.
  45644. * @param color the main color to affect to the ground and the background
  45645. */
  45646. setMainColor(color: Color3): void;
  45647. /**
  45648. * Setup the image processing according to the specified options.
  45649. */
  45650. private _setupImageProcessing;
  45651. /**
  45652. * Setup the environment texture according to the specified options.
  45653. */
  45654. private _setupEnvironmentTexture;
  45655. /**
  45656. * Setup the background according to the specified options.
  45657. */
  45658. private _setupBackground;
  45659. /**
  45660. * Get the scene sizes according to the setup.
  45661. */
  45662. private _getSceneSize;
  45663. /**
  45664. * Setup the ground according to the specified options.
  45665. */
  45666. private _setupGround;
  45667. /**
  45668. * Setup the ground material according to the specified options.
  45669. */
  45670. private _setupGroundMaterial;
  45671. /**
  45672. * Setup the ground diffuse texture according to the specified options.
  45673. */
  45674. private _setupGroundDiffuseTexture;
  45675. /**
  45676. * Setup the ground mirror texture according to the specified options.
  45677. */
  45678. private _setupGroundMirrorTexture;
  45679. /**
  45680. * Setup the ground to receive the mirror texture.
  45681. */
  45682. private _setupMirrorInGroundMaterial;
  45683. /**
  45684. * Setup the skybox according to the specified options.
  45685. */
  45686. private _setupSkybox;
  45687. /**
  45688. * Setup the skybox material according to the specified options.
  45689. */
  45690. private _setupSkyboxMaterial;
  45691. /**
  45692. * Setup the skybox reflection texture according to the specified options.
  45693. */
  45694. private _setupSkyboxReflectionTexture;
  45695. private _errorHandler;
  45696. /**
  45697. * Dispose all the elements created by the Helper.
  45698. */
  45699. dispose(): void;
  45700. }
  45701. }
  45702. declare module "babylonjs/Helpers/photoDome" {
  45703. import { Observable } from "babylonjs/Misc/observable";
  45704. import { Nullable } from "babylonjs/types";
  45705. import { Scene } from "babylonjs/scene";
  45706. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45707. import { Mesh } from "babylonjs/Meshes/mesh";
  45708. import { Texture } from "babylonjs/Materials/Textures/texture";
  45709. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  45710. import "babylonjs/Meshes/Builders/sphereBuilder";
  45711. /**
  45712. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  45713. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  45714. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  45715. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  45716. */
  45717. export class PhotoDome extends TransformNode {
  45718. private _useDirectMapping;
  45719. /**
  45720. * The texture being displayed on the sphere
  45721. */
  45722. protected _photoTexture: Texture;
  45723. /**
  45724. * Gets or sets the texture being displayed on the sphere
  45725. */
  45726. photoTexture: Texture;
  45727. /**
  45728. * Observable raised when an error occured while loading the 360 image
  45729. */
  45730. onLoadErrorObservable: Observable<string>;
  45731. /**
  45732. * The skybox material
  45733. */
  45734. protected _material: BackgroundMaterial;
  45735. /**
  45736. * The surface used for the skybox
  45737. */
  45738. protected _mesh: Mesh;
  45739. /**
  45740. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45741. * Also see the options.resolution property.
  45742. */
  45743. fovMultiplier: number;
  45744. /**
  45745. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  45746. * @param name Element's name, child elements will append suffixes for their own names.
  45747. * @param urlsOfPhoto defines the url of the photo to display
  45748. * @param options defines an object containing optional or exposed sub element properties
  45749. * @param onError defines a callback called when an error occured while loading the texture
  45750. */
  45751. constructor(name: string, urlOfPhoto: string, options: {
  45752. resolution?: number;
  45753. size?: number;
  45754. useDirectMapping?: boolean;
  45755. faceForward?: boolean;
  45756. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  45757. /**
  45758. * Releases resources associated with this node.
  45759. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  45760. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  45761. */
  45762. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  45763. }
  45764. }
  45765. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  45766. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45767. /** @hidden */
  45768. export var rgbdDecodePixelShader: {
  45769. name: string;
  45770. shader: string;
  45771. };
  45772. }
  45773. declare module "babylonjs/Misc/brdfTextureTools" {
  45774. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45775. import { Scene } from "babylonjs/scene";
  45776. import "babylonjs/Shaders/rgbdDecode.fragment";
  45777. /**
  45778. * Class used to host texture specific utilities
  45779. */
  45780. export class BRDFTextureTools {
  45781. /**
  45782. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  45783. * @param texture the texture to expand.
  45784. */
  45785. private static _ExpandDefaultBRDFTexture;
  45786. /**
  45787. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  45788. * @param scene defines the hosting scene
  45789. * @returns the environment BRDF texture
  45790. */
  45791. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  45792. private static _environmentBRDFBase64Texture;
  45793. }
  45794. }
  45795. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  45796. import { Nullable } from "babylonjs/types";
  45797. import { IAnimatable } from "babylonjs/Misc/tools";
  45798. import { Color3 } from "babylonjs/Maths/math";
  45799. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45800. import { EffectFallbacks } from "babylonjs/Materials/effect";
  45801. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  45802. import { Engine } from "babylonjs/Engines/engine";
  45803. import { Scene } from "babylonjs/scene";
  45804. /**
  45805. * @hidden
  45806. */
  45807. export interface IMaterialClearCoatDefines {
  45808. CLEARCOAT: boolean;
  45809. CLEARCOAT_DEFAULTIOR: boolean;
  45810. CLEARCOAT_TEXTURE: boolean;
  45811. CLEARCOAT_TEXTUREDIRECTUV: number;
  45812. CLEARCOAT_BUMP: boolean;
  45813. CLEARCOAT_BUMPDIRECTUV: number;
  45814. CLEARCOAT_TINT: boolean;
  45815. CLEARCOAT_TINT_TEXTURE: boolean;
  45816. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  45817. /** @hidden */
  45818. _areTexturesDirty: boolean;
  45819. }
  45820. /**
  45821. * Define the code related to the clear coat parameters of the pbr material.
  45822. */
  45823. export class PBRClearCoatConfiguration {
  45824. /**
  45825. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  45826. * The default fits with a polyurethane material.
  45827. */
  45828. private static readonly _DefaultIndiceOfRefraction;
  45829. private _isEnabled;
  45830. /**
  45831. * Defines if the clear coat is enabled in the material.
  45832. */
  45833. isEnabled: boolean;
  45834. /**
  45835. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  45836. */
  45837. intensity: number;
  45838. /**
  45839. * Defines the clear coat layer roughness.
  45840. */
  45841. roughness: number;
  45842. private _indiceOfRefraction;
  45843. /**
  45844. * Defines the indice of refraction of the clear coat.
  45845. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  45846. * The default fits with a polyurethane material.
  45847. * Changing the default value is more performance intensive.
  45848. */
  45849. indiceOfRefraction: number;
  45850. private _texture;
  45851. /**
  45852. * Stores the clear coat values in a texture.
  45853. */
  45854. texture: Nullable<BaseTexture>;
  45855. private _bumpTexture;
  45856. /**
  45857. * Define the clear coat specific bump texture.
  45858. */
  45859. bumpTexture: Nullable<BaseTexture>;
  45860. private _isTintEnabled;
  45861. /**
  45862. * Defines if the clear coat tint is enabled in the material.
  45863. */
  45864. isTintEnabled: boolean;
  45865. /**
  45866. * Defines the clear coat tint of the material.
  45867. * This is only use if tint is enabled
  45868. */
  45869. tintColor: Color3;
  45870. /**
  45871. * Defines the distance at which the tint color should be found in the
  45872. * clear coat media.
  45873. * This is only use if tint is enabled
  45874. */
  45875. tintColorAtDistance: number;
  45876. /**
  45877. * Defines the clear coat layer thickness.
  45878. * This is only use if tint is enabled
  45879. */
  45880. tintThickness: number;
  45881. private _tintTexture;
  45882. /**
  45883. * Stores the clear tint values in a texture.
  45884. * rgb is tint
  45885. * a is a thickness factor
  45886. */
  45887. tintTexture: Nullable<BaseTexture>;
  45888. /** @hidden */
  45889. private _internalMarkAllSubMeshesAsTexturesDirty;
  45890. /** @hidden */
  45891. _markAllSubMeshesAsTexturesDirty(): void;
  45892. /**
  45893. * Instantiate a new istance of clear coat configuration.
  45894. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45895. */
  45896. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45897. /**
  45898. * Gets wehter the submesh is ready to be used or not.
  45899. * @param defines the list of "defines" to update.
  45900. * @param scene defines the scene the material belongs to.
  45901. * @param engine defines the engine the material belongs to.
  45902. * @param disableBumpMap defines wether the material disables bump or not.
  45903. * @returns - boolean indicating that the submesh is ready or not.
  45904. */
  45905. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  45906. /**
  45907. * Checks to see if a texture is used in the material.
  45908. * @param defines the list of "defines" to update.
  45909. * @param scene defines the scene to the material belongs to.
  45910. */
  45911. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  45912. /**
  45913. * Binds the material data.
  45914. * @param uniformBuffer defines the Uniform buffer to fill in.
  45915. * @param scene defines the scene the material belongs to.
  45916. * @param engine defines the engine the material belongs to.
  45917. * @param disableBumpMap defines wether the material disables bump or not.
  45918. * @param isFrozen defines wether the material is frozen or not.
  45919. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  45920. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  45921. */
  45922. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  45923. /**
  45924. * Checks to see if a texture is used in the material.
  45925. * @param texture - Base texture to use.
  45926. * @returns - Boolean specifying if a texture is used in the material.
  45927. */
  45928. hasTexture(texture: BaseTexture): boolean;
  45929. /**
  45930. * Returns an array of the actively used textures.
  45931. * @param activeTextures Array of BaseTextures
  45932. */
  45933. getActiveTextures(activeTextures: BaseTexture[]): void;
  45934. /**
  45935. * Returns the animatable textures.
  45936. * @param animatables Array of animatable textures.
  45937. */
  45938. getAnimatables(animatables: IAnimatable[]): void;
  45939. /**
  45940. * Disposes the resources of the material.
  45941. * @param forceDisposeTextures - Forces the disposal of all textures.
  45942. */
  45943. dispose(forceDisposeTextures?: boolean): void;
  45944. /**
  45945. * Get the current class name of the texture useful for serialization or dynamic coding.
  45946. * @returns "PBRClearCoatConfiguration"
  45947. */
  45948. getClassName(): string;
  45949. /**
  45950. * Add fallbacks to the effect fallbacks list.
  45951. * @param defines defines the Base texture to use.
  45952. * @param fallbacks defines the current fallback list.
  45953. * @param currentRank defines the current fallback rank.
  45954. * @returns the new fallback rank.
  45955. */
  45956. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45957. /**
  45958. * Add the required uniforms to the current list.
  45959. * @param uniforms defines the current uniform list.
  45960. */
  45961. static AddUniforms(uniforms: string[]): void;
  45962. /**
  45963. * Add the required samplers to the current list.
  45964. * @param samplers defines the current sampler list.
  45965. */
  45966. static AddSamplers(samplers: string[]): void;
  45967. /**
  45968. * Add the required uniforms to the current buffer.
  45969. * @param uniformBuffer defines the current uniform buffer.
  45970. */
  45971. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45972. /**
  45973. * Makes a duplicate of the current configuration into another one.
  45974. * @param clearCoatConfiguration define the config where to copy the info
  45975. */
  45976. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  45977. /**
  45978. * Serializes this clear coat configuration.
  45979. * @returns - An object with the serialized config.
  45980. */
  45981. serialize(): any;
  45982. /**
  45983. * Parses a Clear Coat Configuration from a serialized object.
  45984. * @param source - Serialized object.
  45985. */
  45986. parse(source: any): void;
  45987. }
  45988. }
  45989. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  45990. import { EffectFallbacks } from "babylonjs/Materials/effect";
  45991. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  45992. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45993. import { Vector2 } from "babylonjs/Maths/math";
  45994. import { Scene } from "babylonjs/scene";
  45995. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45996. import { IAnimatable } from "babylonjs/Misc/tools";
  45997. import { Nullable } from "babylonjs/types";
  45998. /**
  45999. * @hidden
  46000. */
  46001. export interface IMaterialAnisotropicDefines {
  46002. ANISOTROPIC: boolean;
  46003. ANISOTROPIC_TEXTURE: boolean;
  46004. ANISOTROPIC_TEXTUREDIRECTUV: number;
  46005. MAINUV1: boolean;
  46006. _areTexturesDirty: boolean;
  46007. _needUVs: boolean;
  46008. }
  46009. /**
  46010. * Define the code related to the anisotropic parameters of the pbr material.
  46011. */
  46012. export class PBRAnisotropicConfiguration {
  46013. private _isEnabled;
  46014. /**
  46015. * Defines if the anisotropy is enabled in the material.
  46016. */
  46017. isEnabled: boolean;
  46018. /**
  46019. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  46020. */
  46021. intensity: number;
  46022. /**
  46023. * Defines if the effect is along the tangents, bitangents or in between.
  46024. * By default, the effect is "strectching" the highlights along the tangents.
  46025. */
  46026. direction: Vector2;
  46027. private _texture;
  46028. /**
  46029. * Stores the anisotropy values in a texture.
  46030. * rg is direction (like normal from -1 to 1)
  46031. * b is a intensity
  46032. */
  46033. texture: Nullable<BaseTexture>;
  46034. /** @hidden */
  46035. private _internalMarkAllSubMeshesAsTexturesDirty;
  46036. /** @hidden */
  46037. _markAllSubMeshesAsTexturesDirty(): void;
  46038. /**
  46039. * Instantiate a new istance of anisotropy configuration.
  46040. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46041. */
  46042. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46043. /**
  46044. * Specifies that the submesh is ready to be used.
  46045. * @param defines the list of "defines" to update.
  46046. * @param scene defines the scene the material belongs to.
  46047. * @returns - boolean indicating that the submesh is ready or not.
  46048. */
  46049. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  46050. /**
  46051. * Checks to see if a texture is used in the material.
  46052. * @param defines the list of "defines" to update.
  46053. * @param mesh the mesh we are preparing the defines for.
  46054. * @param scene defines the scene the material belongs to.
  46055. */
  46056. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  46057. /**
  46058. * Binds the material data.
  46059. * @param uniformBuffer defines the Uniform buffer to fill in.
  46060. * @param scene defines the scene the material belongs to.
  46061. * @param isFrozen defines wether the material is frozen or not.
  46062. */
  46063. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  46064. /**
  46065. * Checks to see if a texture is used in the material.
  46066. * @param texture - Base texture to use.
  46067. * @returns - Boolean specifying if a texture is used in the material.
  46068. */
  46069. hasTexture(texture: BaseTexture): boolean;
  46070. /**
  46071. * Returns an array of the actively used textures.
  46072. * @param activeTextures Array of BaseTextures
  46073. */
  46074. getActiveTextures(activeTextures: BaseTexture[]): void;
  46075. /**
  46076. * Returns the animatable textures.
  46077. * @param animatables Array of animatable textures.
  46078. */
  46079. getAnimatables(animatables: IAnimatable[]): void;
  46080. /**
  46081. * Disposes the resources of the material.
  46082. * @param forceDisposeTextures - Forces the disposal of all textures.
  46083. */
  46084. dispose(forceDisposeTextures?: boolean): void;
  46085. /**
  46086. * Get the current class name of the texture useful for serialization or dynamic coding.
  46087. * @returns "PBRAnisotropicConfiguration"
  46088. */
  46089. getClassName(): string;
  46090. /**
  46091. * Add fallbacks to the effect fallbacks list.
  46092. * @param defines defines the Base texture to use.
  46093. * @param fallbacks defines the current fallback list.
  46094. * @param currentRank defines the current fallback rank.
  46095. * @returns the new fallback rank.
  46096. */
  46097. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46098. /**
  46099. * Add the required uniforms to the current list.
  46100. * @param uniforms defines the current uniform list.
  46101. */
  46102. static AddUniforms(uniforms: 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. * Add the required samplers to the current list.
  46110. * @param samplers defines the current sampler list.
  46111. */
  46112. static AddSamplers(samplers: string[]): void;
  46113. /**
  46114. * Makes a duplicate of the current configuration into another one.
  46115. * @param anisotropicConfiguration define the config where to copy the info
  46116. */
  46117. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  46118. /**
  46119. * Serializes this anisotropy configuration.
  46120. * @returns - An object with the serialized config.
  46121. */
  46122. serialize(): any;
  46123. /**
  46124. * Parses a anisotropy Configuration from a serialized object.
  46125. * @param source - Serialized object.
  46126. */
  46127. parse(source: any): void;
  46128. }
  46129. }
  46130. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  46131. /**
  46132. * @hidden
  46133. */
  46134. export interface IMaterialBRDFDefines {
  46135. BRDF_V_HEIGHT_CORRELATED: boolean;
  46136. MS_BRDF_ENERGY_CONSERVATION: boolean;
  46137. SPHERICAL_HARMONICS: boolean;
  46138. /** @hidden */
  46139. _areMiscDirty: boolean;
  46140. }
  46141. /**
  46142. * Define the code related to the BRDF parameters of the pbr material.
  46143. */
  46144. export class PBRBRDFConfiguration {
  46145. /**
  46146. * Default value used for the energy conservation.
  46147. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  46148. */
  46149. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  46150. /**
  46151. * Default value used for the Smith Visibility Height Correlated mode.
  46152. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  46153. */
  46154. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  46155. /**
  46156. * Default value used for the IBL diffuse part.
  46157. * This can help switching back to the polynomials mode globally which is a tiny bit
  46158. * less GPU intensive at the drawback of a lower quality.
  46159. */
  46160. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  46161. private _useEnergyConservation;
  46162. /**
  46163. * Defines if the material uses energy conservation.
  46164. */
  46165. useEnergyConservation: boolean;
  46166. private _useSmithVisibilityHeightCorrelated;
  46167. /**
  46168. * LEGACY Mode set to false
  46169. * Defines if the material uses height smith correlated visibility term.
  46170. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  46171. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  46172. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  46173. * Not relying on height correlated will also disable energy conservation.
  46174. */
  46175. useSmithVisibilityHeightCorrelated: boolean;
  46176. private _useSphericalHarmonics;
  46177. /**
  46178. * LEGACY Mode set to false
  46179. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  46180. * diffuse part of the IBL.
  46181. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  46182. * to the ground truth.
  46183. */
  46184. useSphericalHarmonics: boolean;
  46185. /** @hidden */
  46186. private _internalMarkAllSubMeshesAsMiscDirty;
  46187. /** @hidden */
  46188. _markAllSubMeshesAsMiscDirty(): void;
  46189. /**
  46190. * Instantiate a new istance of clear coat configuration.
  46191. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  46192. */
  46193. constructor(markAllSubMeshesAsMiscDirty: () => void);
  46194. /**
  46195. * Checks to see if a texture is used in the material.
  46196. * @param defines the list of "defines" to update.
  46197. */
  46198. prepareDefines(defines: IMaterialBRDFDefines): void;
  46199. /**
  46200. * Get the current class name of the texture useful for serialization or dynamic coding.
  46201. * @returns "PBRClearCoatConfiguration"
  46202. */
  46203. getClassName(): string;
  46204. /**
  46205. * Makes a duplicate of the current configuration into another one.
  46206. * @param brdfConfiguration define the config where to copy the info
  46207. */
  46208. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  46209. /**
  46210. * Serializes this BRDF configuration.
  46211. * @returns - An object with the serialized config.
  46212. */
  46213. serialize(): any;
  46214. /**
  46215. * Parses a BRDF Configuration from a serialized object.
  46216. * @param source - Serialized object.
  46217. */
  46218. parse(source: any): void;
  46219. }
  46220. }
  46221. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  46222. import { EffectFallbacks } from "babylonjs/Materials/effect";
  46223. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  46224. import { Color3 } from "babylonjs/Maths/math";
  46225. import { Scene } from "babylonjs/scene";
  46226. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46227. import { IAnimatable } from "babylonjs/Misc/tools";
  46228. import { Nullable } from "babylonjs/types";
  46229. /**
  46230. * @hidden
  46231. */
  46232. export interface IMaterialSheenDefines {
  46233. SHEEN: boolean;
  46234. SHEEN_TEXTURE: boolean;
  46235. SHEEN_TEXTUREDIRECTUV: number;
  46236. SHEEN_LINKWITHALBEDO: boolean;
  46237. /** @hidden */
  46238. _areTexturesDirty: boolean;
  46239. }
  46240. /**
  46241. * Define the code related to the Sheen parameters of the pbr material.
  46242. */
  46243. export class PBRSheenConfiguration {
  46244. private _isEnabled;
  46245. /**
  46246. * Defines if the material uses sheen.
  46247. */
  46248. isEnabled: boolean;
  46249. private _linkSheenWithAlbedo;
  46250. /**
  46251. * Defines if the sheen is linked to the sheen color.
  46252. */
  46253. linkSheenWithAlbedo: boolean;
  46254. /**
  46255. * Defines the sheen intensity.
  46256. */
  46257. intensity: number;
  46258. /**
  46259. * Defines the sheen color.
  46260. */
  46261. color: Color3;
  46262. private _texture;
  46263. /**
  46264. * Stores the sheen tint values in a texture.
  46265. * rgb is tint
  46266. * a is a intensity
  46267. */
  46268. texture: Nullable<BaseTexture>;
  46269. /** @hidden */
  46270. private _internalMarkAllSubMeshesAsTexturesDirty;
  46271. /** @hidden */
  46272. _markAllSubMeshesAsTexturesDirty(): void;
  46273. /**
  46274. * Instantiate a new istance of clear coat configuration.
  46275. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46276. */
  46277. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46278. /**
  46279. * Specifies that the submesh is ready to be used.
  46280. * @param defines the list of "defines" to update.
  46281. * @param scene defines the scene the material belongs to.
  46282. * @returns - boolean indicating that the submesh is ready or not.
  46283. */
  46284. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  46285. /**
  46286. * Checks to see if a texture is used in the material.
  46287. * @param defines the list of "defines" to update.
  46288. * @param scene defines the scene the material belongs to.
  46289. */
  46290. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  46291. /**
  46292. * Binds the material data.
  46293. * @param uniformBuffer defines the Uniform buffer to fill in.
  46294. * @param scene defines the scene the material belongs to.
  46295. * @param isFrozen defines wether the material is frozen or not.
  46296. */
  46297. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  46298. /**
  46299. * Checks to see if a texture is used in the material.
  46300. * @param texture - Base texture to use.
  46301. * @returns - Boolean specifying if a texture is used in the material.
  46302. */
  46303. hasTexture(texture: BaseTexture): boolean;
  46304. /**
  46305. * Returns an array of the actively used textures.
  46306. * @param activeTextures Array of BaseTextures
  46307. */
  46308. getActiveTextures(activeTextures: BaseTexture[]): void;
  46309. /**
  46310. * Returns the animatable textures.
  46311. * @param animatables Array of animatable textures.
  46312. */
  46313. getAnimatables(animatables: IAnimatable[]): void;
  46314. /**
  46315. * Disposes the resources of the material.
  46316. * @param forceDisposeTextures - Forces the disposal of all textures.
  46317. */
  46318. dispose(forceDisposeTextures?: boolean): void;
  46319. /**
  46320. * Get the current class name of the texture useful for serialization or dynamic coding.
  46321. * @returns "PBRSheenConfiguration"
  46322. */
  46323. getClassName(): string;
  46324. /**
  46325. * Add fallbacks to the effect fallbacks list.
  46326. * @param defines defines the Base texture to use.
  46327. * @param fallbacks defines the current fallback list.
  46328. * @param currentRank defines the current fallback rank.
  46329. * @returns the new fallback rank.
  46330. */
  46331. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46332. /**
  46333. * Add the required uniforms to the current list.
  46334. * @param uniforms defines the current uniform list.
  46335. */
  46336. static AddUniforms(uniforms: string[]): void;
  46337. /**
  46338. * Add the required uniforms to the current buffer.
  46339. * @param uniformBuffer defines the current uniform buffer.
  46340. */
  46341. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46342. /**
  46343. * Add the required samplers to the current list.
  46344. * @param samplers defines the current sampler list.
  46345. */
  46346. static AddSamplers(samplers: string[]): void;
  46347. /**
  46348. * Makes a duplicate of the current configuration into another one.
  46349. * @param sheenConfiguration define the config where to copy the info
  46350. */
  46351. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  46352. /**
  46353. * Serializes this BRDF configuration.
  46354. * @returns - An object with the serialized config.
  46355. */
  46356. serialize(): any;
  46357. /**
  46358. * Parses a Sheen Configuration from a serialized object.
  46359. * @param source - Serialized object.
  46360. */
  46361. parse(source: any): void;
  46362. }
  46363. }
  46364. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  46365. import { Nullable } from "babylonjs/types";
  46366. import { IAnimatable } from "babylonjs/Misc/tools";
  46367. import { Color3 } from "babylonjs/Maths/math";
  46368. import { SmartArray } from "babylonjs/Misc/smartArray";
  46369. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46370. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  46371. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  46372. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  46373. import { Engine } from "babylonjs/Engines/engine";
  46374. import { Scene } from "babylonjs/scene";
  46375. /**
  46376. * @hidden
  46377. */
  46378. export interface IMaterialSubSurfaceDefines {
  46379. SUBSURFACE: boolean;
  46380. SS_REFRACTION: boolean;
  46381. SS_TRANSLUCENCY: boolean;
  46382. SS_SCATERRING: boolean;
  46383. SS_THICKNESSANDMASK_TEXTURE: boolean;
  46384. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  46385. SS_REFRACTIONMAP_3D: boolean;
  46386. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  46387. SS_LODINREFRACTIONALPHA: boolean;
  46388. SS_GAMMAREFRACTION: boolean;
  46389. SS_RGBDREFRACTION: boolean;
  46390. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  46391. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  46392. /** @hidden */
  46393. _areTexturesDirty: boolean;
  46394. }
  46395. /**
  46396. * Define the code related to the sub surface parameters of the pbr material.
  46397. */
  46398. export class PBRSubSurfaceConfiguration {
  46399. private _isRefractionEnabled;
  46400. /**
  46401. * Defines if the refraction is enabled in the material.
  46402. */
  46403. isRefractionEnabled: boolean;
  46404. private _isTranslucencyEnabled;
  46405. /**
  46406. * Defines if the translucency is enabled in the material.
  46407. */
  46408. isTranslucencyEnabled: boolean;
  46409. private _isScatteringEnabled;
  46410. /**
  46411. * Defines the refraction intensity of the material.
  46412. * The refraction when enabled replaces the Diffuse part of the material.
  46413. * The intensity helps transitionning between diffuse and refraction.
  46414. */
  46415. refractionIntensity: number;
  46416. /**
  46417. * Defines the translucency intensity of the material.
  46418. * When translucency has been enabled, this defines how much of the "translucency"
  46419. * is addded to the diffuse part of the material.
  46420. */
  46421. translucencyIntensity: number;
  46422. /**
  46423. * Defines the scattering intensity of the material.
  46424. * When scattering has been enabled, this defines how much of the "scattered light"
  46425. * is addded to the diffuse part of the material.
  46426. */
  46427. scatteringIntensity: number;
  46428. private _thicknessTexture;
  46429. /**
  46430. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  46431. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  46432. * 0 would mean minimumThickness
  46433. * 1 would mean maximumThickness
  46434. * The other channels might be use as a mask to vary the different effects intensity.
  46435. */
  46436. thicknessTexture: Nullable<BaseTexture>;
  46437. private _refractionTexture;
  46438. /**
  46439. * Defines the texture to use for refraction.
  46440. */
  46441. refractionTexture: Nullable<BaseTexture>;
  46442. private _indexOfRefraction;
  46443. /**
  46444. * Defines the indice of refraction used in the material.
  46445. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  46446. */
  46447. indexOfRefraction: number;
  46448. private _invertRefractionY;
  46449. /**
  46450. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  46451. */
  46452. invertRefractionY: boolean;
  46453. private _linkRefractionWithTransparency;
  46454. /**
  46455. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  46456. * Materials half opaque for instance using refraction could benefit from this control.
  46457. */
  46458. linkRefractionWithTransparency: boolean;
  46459. /**
  46460. * Defines the minimum thickness stored in the thickness map.
  46461. * If no thickness map is defined, this value will be used to simulate thickness.
  46462. */
  46463. minimumThickness: number;
  46464. /**
  46465. * Defines the maximum thickness stored in the thickness map.
  46466. */
  46467. maximumThickness: number;
  46468. /**
  46469. * Defines the volume tint of the material.
  46470. * This is used for both translucency and scattering.
  46471. */
  46472. tintColor: Color3;
  46473. /**
  46474. * Defines the distance at which the tint color should be found in the media.
  46475. * This is used for refraction only.
  46476. */
  46477. tintColorAtDistance: number;
  46478. /**
  46479. * Defines how far each channel transmit through the media.
  46480. * It is defined as a color to simplify it selection.
  46481. */
  46482. diffusionDistance: Color3;
  46483. private _useMaskFromThicknessTexture;
  46484. /**
  46485. * Stores the intensity of the different subsurface effects in the thickness texture.
  46486. * * the green channel is the translucency intensity.
  46487. * * the blue channel is the scattering intensity.
  46488. * * the alpha channel is the refraction intensity.
  46489. */
  46490. useMaskFromThicknessTexture: boolean;
  46491. /** @hidden */
  46492. private _internalMarkAllSubMeshesAsTexturesDirty;
  46493. /** @hidden */
  46494. _markAllSubMeshesAsTexturesDirty(): void;
  46495. /**
  46496. * Instantiate a new istance of sub surface configuration.
  46497. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46498. */
  46499. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46500. /**
  46501. * Gets wehter the submesh is ready to be used or not.
  46502. * @param defines the list of "defines" to update.
  46503. * @param scene defines the scene the material belongs to.
  46504. * @returns - boolean indicating that the submesh is ready or not.
  46505. */
  46506. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  46507. /**
  46508. * Checks to see if a texture is used in the material.
  46509. * @param defines the list of "defines" to update.
  46510. * @param scene defines the scene to the material belongs to.
  46511. */
  46512. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  46513. /**
  46514. * Binds the material data.
  46515. * @param uniformBuffer defines the Uniform buffer to fill in.
  46516. * @param scene defines the scene the material belongs to.
  46517. * @param engine defines the engine the material belongs to.
  46518. * @param isFrozen defines wether the material is frozen or not.
  46519. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  46520. */
  46521. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  46522. /**
  46523. * Unbinds the material from the mesh.
  46524. * @param activeEffect defines the effect that should be unbound from.
  46525. * @returns true if unbound, otherwise false
  46526. */
  46527. unbind(activeEffect: Effect): boolean;
  46528. /**
  46529. * Returns the texture used for refraction or null if none is used.
  46530. * @param scene defines the scene the material belongs to.
  46531. * @returns - Refraction texture if present. If no refraction texture and refraction
  46532. * is linked with transparency, returns environment texture. Otherwise, returns null.
  46533. */
  46534. private _getRefractionTexture;
  46535. /**
  46536. * Returns true if alpha blending should be disabled.
  46537. */
  46538. readonly disableAlphaBlending: boolean;
  46539. /**
  46540. * Fills the list of render target textures.
  46541. * @param renderTargets the list of render targets to update
  46542. */
  46543. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  46544. /**
  46545. * Checks to see if a texture is used in the material.
  46546. * @param texture - Base texture to use.
  46547. * @returns - Boolean specifying if a texture is used in the material.
  46548. */
  46549. hasTexture(texture: BaseTexture): boolean;
  46550. /**
  46551. * Gets a boolean indicating that current material needs to register RTT
  46552. * @returns true if this uses a render target otherwise false.
  46553. */
  46554. hasRenderTargetTextures(): boolean;
  46555. /**
  46556. * Returns an array of the actively used textures.
  46557. * @param activeTextures Array of BaseTextures
  46558. */
  46559. getActiveTextures(activeTextures: BaseTexture[]): void;
  46560. /**
  46561. * Returns the animatable textures.
  46562. * @param animatables Array of animatable textures.
  46563. */
  46564. getAnimatables(animatables: IAnimatable[]): void;
  46565. /**
  46566. * Disposes the resources of the material.
  46567. * @param forceDisposeTextures - Forces the disposal of all textures.
  46568. */
  46569. dispose(forceDisposeTextures?: boolean): void;
  46570. /**
  46571. * Get the current class name of the texture useful for serialization or dynamic coding.
  46572. * @returns "PBRSubSurfaceConfiguration"
  46573. */
  46574. getClassName(): string;
  46575. /**
  46576. * Add fallbacks to the effect fallbacks list.
  46577. * @param defines defines the Base texture to use.
  46578. * @param fallbacks defines the current fallback list.
  46579. * @param currentRank defines the current fallback rank.
  46580. * @returns the new fallback rank.
  46581. */
  46582. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46583. /**
  46584. * Add the required uniforms to the current list.
  46585. * @param uniforms defines the current uniform list.
  46586. */
  46587. static AddUniforms(uniforms: string[]): void;
  46588. /**
  46589. * Add the required samplers to the current list.
  46590. * @param samplers defines the current sampler list.
  46591. */
  46592. static AddSamplers(samplers: string[]): void;
  46593. /**
  46594. * Add the required uniforms to the current buffer.
  46595. * @param uniformBuffer defines the current uniform buffer.
  46596. */
  46597. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46598. /**
  46599. * Makes a duplicate of the current configuration into another one.
  46600. * @param configuration define the config where to copy the info
  46601. */
  46602. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  46603. /**
  46604. * Serializes this Sub Surface configuration.
  46605. * @returns - An object with the serialized config.
  46606. */
  46607. serialize(): any;
  46608. /**
  46609. * Parses a Sub Surface Configuration from a serialized object.
  46610. * @param source - Serialized object.
  46611. */
  46612. parse(source: any): void;
  46613. }
  46614. }
  46615. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  46616. /** @hidden */
  46617. export var pbrFragmentDeclaration: {
  46618. name: string;
  46619. shader: string;
  46620. };
  46621. }
  46622. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  46623. /** @hidden */
  46624. export var pbrUboDeclaration: {
  46625. name: string;
  46626. shader: string;
  46627. };
  46628. }
  46629. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  46630. /** @hidden */
  46631. export var pbrFragmentExtraDeclaration: {
  46632. name: string;
  46633. shader: string;
  46634. };
  46635. }
  46636. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  46637. /** @hidden */
  46638. export var pbrFragmentSamplersDeclaration: {
  46639. name: string;
  46640. shader: string;
  46641. };
  46642. }
  46643. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  46644. /** @hidden */
  46645. export var pbrHelperFunctions: {
  46646. name: string;
  46647. shader: string;
  46648. };
  46649. }
  46650. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  46651. /** @hidden */
  46652. export var harmonicsFunctions: {
  46653. name: string;
  46654. shader: string;
  46655. };
  46656. }
  46657. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  46658. /** @hidden */
  46659. export var pbrDirectLightingSetupFunctions: {
  46660. name: string;
  46661. shader: string;
  46662. };
  46663. }
  46664. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  46665. /** @hidden */
  46666. export var pbrDirectLightingFalloffFunctions: {
  46667. name: string;
  46668. shader: string;
  46669. };
  46670. }
  46671. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  46672. /** @hidden */
  46673. export var pbrBRDFFunctions: {
  46674. name: string;
  46675. shader: string;
  46676. };
  46677. }
  46678. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  46679. /** @hidden */
  46680. export var pbrDirectLightingFunctions: {
  46681. name: string;
  46682. shader: string;
  46683. };
  46684. }
  46685. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  46686. /** @hidden */
  46687. export var pbrIBLFunctions: {
  46688. name: string;
  46689. shader: string;
  46690. };
  46691. }
  46692. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  46693. /** @hidden */
  46694. export var pbrDebug: {
  46695. name: string;
  46696. shader: string;
  46697. };
  46698. }
  46699. declare module "babylonjs/Shaders/pbr.fragment" {
  46700. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  46701. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  46702. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  46703. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  46704. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  46705. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  46706. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  46707. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  46708. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  46709. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  46710. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46711. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  46712. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  46713. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  46714. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  46715. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  46716. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  46717. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  46718. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  46719. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  46720. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  46721. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  46722. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  46723. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  46724. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  46725. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  46726. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  46727. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  46728. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  46729. /** @hidden */
  46730. export var pbrPixelShader: {
  46731. name: string;
  46732. shader: string;
  46733. };
  46734. }
  46735. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  46736. /** @hidden */
  46737. export var pbrVertexDeclaration: {
  46738. name: string;
  46739. shader: string;
  46740. };
  46741. }
  46742. declare module "babylonjs/Shaders/pbr.vertex" {
  46743. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  46744. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  46745. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46746. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  46747. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  46748. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  46749. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  46750. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  46751. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  46752. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  46753. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  46754. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  46755. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  46756. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  46757. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  46758. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  46759. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  46760. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  46761. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  46762. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  46763. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  46764. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  46765. /** @hidden */
  46766. export var pbrVertexShader: {
  46767. name: string;
  46768. shader: string;
  46769. };
  46770. }
  46771. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  46772. import { IAnimatable } from "babylonjs/Misc/tools";
  46773. import { Nullable } from "babylonjs/types";
  46774. import { Scene } from "babylonjs/scene";
  46775. import { Matrix, Color3 } from "babylonjs/Maths/math";
  46776. import { SubMesh } from "babylonjs/Meshes/subMesh";
  46777. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46778. import { Mesh } from "babylonjs/Meshes/mesh";
  46779. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  46780. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  46781. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  46782. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  46783. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  46784. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  46785. import { Material } from "babylonjs/Materials/material";
  46786. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  46787. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  46788. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46789. import "babylonjs/Shaders/pbr.fragment";
  46790. import "babylonjs/Shaders/pbr.vertex";
  46791. /**
  46792. * Manages the defines for the PBR Material.
  46793. * @hidden
  46794. */
  46795. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  46796. PBR: boolean;
  46797. MAINUV1: boolean;
  46798. MAINUV2: boolean;
  46799. UV1: boolean;
  46800. UV2: boolean;
  46801. ALBEDO: boolean;
  46802. ALBEDODIRECTUV: number;
  46803. VERTEXCOLOR: boolean;
  46804. AMBIENT: boolean;
  46805. AMBIENTDIRECTUV: number;
  46806. AMBIENTINGRAYSCALE: boolean;
  46807. OPACITY: boolean;
  46808. VERTEXALPHA: boolean;
  46809. OPACITYDIRECTUV: number;
  46810. OPACITYRGB: boolean;
  46811. ALPHATEST: boolean;
  46812. DEPTHPREPASS: boolean;
  46813. ALPHABLEND: boolean;
  46814. ALPHAFROMALBEDO: boolean;
  46815. ALPHATESTVALUE: string;
  46816. SPECULAROVERALPHA: boolean;
  46817. RADIANCEOVERALPHA: boolean;
  46818. ALPHAFRESNEL: boolean;
  46819. LINEARALPHAFRESNEL: boolean;
  46820. PREMULTIPLYALPHA: boolean;
  46821. EMISSIVE: boolean;
  46822. EMISSIVEDIRECTUV: number;
  46823. REFLECTIVITY: boolean;
  46824. REFLECTIVITYDIRECTUV: number;
  46825. SPECULARTERM: boolean;
  46826. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  46827. MICROSURFACEAUTOMATIC: boolean;
  46828. LODBASEDMICROSFURACE: boolean;
  46829. MICROSURFACEMAP: boolean;
  46830. MICROSURFACEMAPDIRECTUV: number;
  46831. METALLICWORKFLOW: boolean;
  46832. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  46833. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  46834. METALLNESSSTOREINMETALMAPBLUE: boolean;
  46835. AOSTOREINMETALMAPRED: boolean;
  46836. ENVIRONMENTBRDF: boolean;
  46837. ENVIRONMENTBRDF_RGBD: boolean;
  46838. NORMAL: boolean;
  46839. TANGENT: boolean;
  46840. BUMP: boolean;
  46841. BUMPDIRECTUV: number;
  46842. OBJECTSPACE_NORMALMAP: boolean;
  46843. PARALLAX: boolean;
  46844. PARALLAXOCCLUSION: boolean;
  46845. NORMALXYSCALE: boolean;
  46846. LIGHTMAP: boolean;
  46847. LIGHTMAPDIRECTUV: number;
  46848. USELIGHTMAPASSHADOWMAP: boolean;
  46849. GAMMALIGHTMAP: boolean;
  46850. REFLECTION: boolean;
  46851. REFLECTIONMAP_3D: boolean;
  46852. REFLECTIONMAP_SPHERICAL: boolean;
  46853. REFLECTIONMAP_PLANAR: boolean;
  46854. REFLECTIONMAP_CUBIC: boolean;
  46855. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  46856. REFLECTIONMAP_PROJECTION: boolean;
  46857. REFLECTIONMAP_SKYBOX: boolean;
  46858. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  46859. REFLECTIONMAP_EXPLICIT: boolean;
  46860. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  46861. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  46862. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  46863. INVERTCUBICMAP: boolean;
  46864. USESPHERICALFROMREFLECTIONMAP: boolean;
  46865. SPHERICAL_HARMONICS: boolean;
  46866. USESPHERICALINVERTEX: boolean;
  46867. REFLECTIONMAP_OPPOSITEZ: boolean;
  46868. LODINREFLECTIONALPHA: boolean;
  46869. GAMMAREFLECTION: boolean;
  46870. RGBDREFLECTION: boolean;
  46871. RADIANCEOCCLUSION: boolean;
  46872. HORIZONOCCLUSION: boolean;
  46873. INSTANCES: boolean;
  46874. NUM_BONE_INFLUENCERS: number;
  46875. BonesPerMesh: number;
  46876. BONETEXTURE: boolean;
  46877. NONUNIFORMSCALING: boolean;
  46878. MORPHTARGETS: boolean;
  46879. MORPHTARGETS_NORMAL: boolean;
  46880. MORPHTARGETS_TANGENT: boolean;
  46881. NUM_MORPH_INFLUENCERS: number;
  46882. IMAGEPROCESSING: boolean;
  46883. VIGNETTE: boolean;
  46884. VIGNETTEBLENDMODEMULTIPLY: boolean;
  46885. VIGNETTEBLENDMODEOPAQUE: boolean;
  46886. TONEMAPPING: boolean;
  46887. TONEMAPPING_ACES: boolean;
  46888. CONTRAST: boolean;
  46889. COLORCURVES: boolean;
  46890. COLORGRADING: boolean;
  46891. COLORGRADING3D: boolean;
  46892. SAMPLER3DGREENDEPTH: boolean;
  46893. SAMPLER3DBGRMAP: boolean;
  46894. IMAGEPROCESSINGPOSTPROCESS: boolean;
  46895. EXPOSURE: boolean;
  46896. MULTIVIEW: boolean;
  46897. USEPHYSICALLIGHTFALLOFF: boolean;
  46898. USEGLTFLIGHTFALLOFF: boolean;
  46899. TWOSIDEDLIGHTING: boolean;
  46900. SHADOWFLOAT: boolean;
  46901. CLIPPLANE: boolean;
  46902. CLIPPLANE2: boolean;
  46903. CLIPPLANE3: boolean;
  46904. CLIPPLANE4: boolean;
  46905. POINTSIZE: boolean;
  46906. FOG: boolean;
  46907. LOGARITHMICDEPTH: boolean;
  46908. FORCENORMALFORWARD: boolean;
  46909. SPECULARAA: boolean;
  46910. CLEARCOAT: boolean;
  46911. CLEARCOAT_DEFAULTIOR: boolean;
  46912. CLEARCOAT_TEXTURE: boolean;
  46913. CLEARCOAT_TEXTUREDIRECTUV: number;
  46914. CLEARCOAT_BUMP: boolean;
  46915. CLEARCOAT_BUMPDIRECTUV: number;
  46916. CLEARCOAT_TINT: boolean;
  46917. CLEARCOAT_TINT_TEXTURE: boolean;
  46918. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  46919. ANISOTROPIC: boolean;
  46920. ANISOTROPIC_TEXTURE: boolean;
  46921. ANISOTROPIC_TEXTUREDIRECTUV: number;
  46922. BRDF_V_HEIGHT_CORRELATED: boolean;
  46923. MS_BRDF_ENERGY_CONSERVATION: boolean;
  46924. SHEEN: boolean;
  46925. SHEEN_TEXTURE: boolean;
  46926. SHEEN_TEXTUREDIRECTUV: number;
  46927. SHEEN_LINKWITHALBEDO: boolean;
  46928. SUBSURFACE: boolean;
  46929. SS_REFRACTION: boolean;
  46930. SS_TRANSLUCENCY: boolean;
  46931. SS_SCATERRING: boolean;
  46932. SS_THICKNESSANDMASK_TEXTURE: boolean;
  46933. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  46934. SS_REFRACTIONMAP_3D: boolean;
  46935. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  46936. SS_LODINREFRACTIONALPHA: boolean;
  46937. SS_GAMMAREFRACTION: boolean;
  46938. SS_RGBDREFRACTION: boolean;
  46939. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  46940. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  46941. UNLIT: boolean;
  46942. DEBUGMODE: number;
  46943. /**
  46944. * Initializes the PBR Material defines.
  46945. */
  46946. constructor();
  46947. /**
  46948. * Resets the PBR Material defines.
  46949. */
  46950. reset(): void;
  46951. }
  46952. /**
  46953. * The Physically based material base class of BJS.
  46954. *
  46955. * This offers the main features of a standard PBR material.
  46956. * For more information, please refer to the documentation :
  46957. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  46958. */
  46959. export abstract class PBRBaseMaterial extends PushMaterial {
  46960. /**
  46961. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  46962. */
  46963. static readonly PBRMATERIAL_OPAQUE: number;
  46964. /**
  46965. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  46966. */
  46967. static readonly PBRMATERIAL_ALPHATEST: number;
  46968. /**
  46969. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46970. */
  46971. static readonly PBRMATERIAL_ALPHABLEND: number;
  46972. /**
  46973. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46974. * They are also discarded below the alpha cutoff threshold to improve performances.
  46975. */
  46976. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  46977. /**
  46978. * Defines the default value of how much AO map is occluding the analytical lights
  46979. * (point spot...).
  46980. */
  46981. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  46982. /**
  46983. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  46984. */
  46985. static readonly LIGHTFALLOFF_PHYSICAL: number;
  46986. /**
  46987. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  46988. * to enhance interoperability with other engines.
  46989. */
  46990. static readonly LIGHTFALLOFF_GLTF: number;
  46991. /**
  46992. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  46993. * to enhance interoperability with other materials.
  46994. */
  46995. static readonly LIGHTFALLOFF_STANDARD: number;
  46996. /**
  46997. * Intensity of the direct lights e.g. the four lights available in your scene.
  46998. * This impacts both the direct diffuse and specular highlights.
  46999. */
  47000. protected _directIntensity: number;
  47001. /**
  47002. * Intensity of the emissive part of the material.
  47003. * This helps controlling the emissive effect without modifying the emissive color.
  47004. */
  47005. protected _emissiveIntensity: number;
  47006. /**
  47007. * Intensity of the environment e.g. how much the environment will light the object
  47008. * either through harmonics for rough material or through the refelction for shiny ones.
  47009. */
  47010. protected _environmentIntensity: number;
  47011. /**
  47012. * This is a special control allowing the reduction of the specular highlights coming from the
  47013. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  47014. */
  47015. protected _specularIntensity: number;
  47016. /**
  47017. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  47018. */
  47019. private _lightingInfos;
  47020. /**
  47021. * Debug Control allowing disabling the bump map on this material.
  47022. */
  47023. protected _disableBumpMap: boolean;
  47024. /**
  47025. * AKA Diffuse Texture in standard nomenclature.
  47026. */
  47027. protected _albedoTexture: Nullable<BaseTexture>;
  47028. /**
  47029. * AKA Occlusion Texture in other nomenclature.
  47030. */
  47031. protected _ambientTexture: Nullable<BaseTexture>;
  47032. /**
  47033. * AKA Occlusion Texture Intensity in other nomenclature.
  47034. */
  47035. protected _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. protected _ambientTextureImpactOnAnalyticalLights: number;
  47042. /**
  47043. * Stores the alpha values in a texture.
  47044. */
  47045. protected _opacityTexture: Nullable<BaseTexture>;
  47046. /**
  47047. * Stores the reflection values in a texture.
  47048. */
  47049. protected _reflectionTexture: Nullable<BaseTexture>;
  47050. /**
  47051. * Stores the emissive values in a texture.
  47052. */
  47053. protected _emissiveTexture: Nullable<BaseTexture>;
  47054. /**
  47055. * AKA Specular texture in other nomenclature.
  47056. */
  47057. protected _reflectivityTexture: Nullable<BaseTexture>;
  47058. /**
  47059. * Used to switch from specular/glossiness to metallic/roughness workflow.
  47060. */
  47061. protected _metallicTexture: Nullable<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. protected _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. protected _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. protected _microSurfaceTexture: Nullable<BaseTexture>;
  47077. /**
  47078. * Stores surface normal data used to displace a mesh in a texture.
  47079. */
  47080. protected _bumpTexture: Nullable<BaseTexture>;
  47081. /**
  47082. * Stores the pre-calculated light information of a mesh in a texture.
  47083. */
  47084. protected _lightmapTexture: Nullable<BaseTexture>;
  47085. /**
  47086. * The color of a material in ambient lighting.
  47087. */
  47088. protected _ambientColor: Color3;
  47089. /**
  47090. * AKA Diffuse Color in other nomenclature.
  47091. */
  47092. protected _albedoColor: Color3;
  47093. /**
  47094. * AKA Specular Color in other nomenclature.
  47095. */
  47096. protected _reflectivityColor: Color3;
  47097. /**
  47098. * The color applied when light is reflected from a material.
  47099. */
  47100. protected _reflectionColor: Color3;
  47101. /**
  47102. * The color applied when light is emitted from a material.
  47103. */
  47104. protected _emissiveColor: Color3;
  47105. /**
  47106. * AKA Glossiness in other nomenclature.
  47107. */
  47108. protected _microSurface: number;
  47109. /**
  47110. * Specifies that the material will use the light map as a show map.
  47111. */
  47112. protected _useLightmapAsShadowmap: boolean;
  47113. /**
  47114. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  47115. * makes the reflect vector face the model (under horizon).
  47116. */
  47117. protected _useHorizonOcclusion: boolean;
  47118. /**
  47119. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  47120. * too much the area relying on ambient texture to define their ambient occlusion.
  47121. */
  47122. protected _useRadianceOcclusion: boolean;
  47123. /**
  47124. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  47125. */
  47126. protected _useAlphaFromAlbedoTexture: boolean;
  47127. /**
  47128. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  47129. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  47130. */
  47131. protected _useSpecularOverAlpha: boolean;
  47132. /**
  47133. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  47134. */
  47135. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  47136. /**
  47137. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  47138. */
  47139. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  47140. /**
  47141. * Specifies if the metallic texture contains the roughness information in its green channel.
  47142. */
  47143. protected _useRoughnessFromMetallicTextureGreen: boolean;
  47144. /**
  47145. * Specifies if the metallic texture contains the metallness information in its blue channel.
  47146. */
  47147. protected _useMetallnessFromMetallicTextureBlue: boolean;
  47148. /**
  47149. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  47150. */
  47151. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  47152. /**
  47153. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  47154. */
  47155. protected _useAmbientInGrayScale: boolean;
  47156. /**
  47157. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  47158. * The material will try to infer what glossiness each pixel should be.
  47159. */
  47160. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  47161. /**
  47162. * Defines the falloff type used in this material.
  47163. * It by default is Physical.
  47164. */
  47165. protected _lightFalloff: number;
  47166. /**
  47167. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  47168. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  47169. */
  47170. protected _useRadianceOverAlpha: boolean;
  47171. /**
  47172. * Allows using an object space normal map (instead of tangent space).
  47173. */
  47174. protected _useObjectSpaceNormalMap: boolean;
  47175. /**
  47176. * Allows using the bump map in parallax mode.
  47177. */
  47178. protected _useParallax: boolean;
  47179. /**
  47180. * Allows using the bump map in parallax occlusion mode.
  47181. */
  47182. protected _useParallaxOcclusion: boolean;
  47183. /**
  47184. * Controls the scale bias of the parallax mode.
  47185. */
  47186. protected _parallaxScaleBias: number;
  47187. /**
  47188. * If sets to true, disables all the lights affecting the material.
  47189. */
  47190. protected _disableLighting: boolean;
  47191. /**
  47192. * Number of Simultaneous lights allowed on the material.
  47193. */
  47194. protected _maxSimultaneousLights: number;
  47195. /**
  47196. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  47197. */
  47198. protected _invertNormalMapX: boolean;
  47199. /**
  47200. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  47201. */
  47202. protected _invertNormalMapY: boolean;
  47203. /**
  47204. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47205. */
  47206. protected _twoSidedLighting: boolean;
  47207. /**
  47208. * Defines the alpha limits in alpha test mode.
  47209. */
  47210. protected _alphaCutOff: number;
  47211. /**
  47212. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  47213. */
  47214. protected _forceAlphaTest: boolean;
  47215. /**
  47216. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47217. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  47218. */
  47219. protected _useAlphaFresnel: boolean;
  47220. /**
  47221. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47222. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  47223. */
  47224. protected _useLinearAlphaFresnel: boolean;
  47225. /**
  47226. * The transparency mode of the material.
  47227. */
  47228. protected _transparencyMode: Nullable<number>;
  47229. /**
  47230. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  47231. * from cos thetav and roughness:
  47232. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  47233. */
  47234. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  47235. /**
  47236. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  47237. */
  47238. protected _forceIrradianceInFragment: boolean;
  47239. /**
  47240. * Force normal to face away from face.
  47241. */
  47242. protected _forceNormalForward: boolean;
  47243. /**
  47244. * Enables specular anti aliasing in the PBR shader.
  47245. * It will both interacts on the Geometry for analytical and IBL lighting.
  47246. * It also prefilter the roughness map based on the bump values.
  47247. */
  47248. protected _enableSpecularAntiAliasing: boolean;
  47249. /**
  47250. * Default configuration related to image processing available in the PBR Material.
  47251. */
  47252. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  47253. /**
  47254. * Keep track of the image processing observer to allow dispose and replace.
  47255. */
  47256. private _imageProcessingObserver;
  47257. /**
  47258. * Attaches a new image processing configuration to the PBR Material.
  47259. * @param configuration
  47260. */
  47261. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  47262. /**
  47263. * Stores the available render targets.
  47264. */
  47265. private _renderTargets;
  47266. /**
  47267. * Sets the global ambient color for the material used in lighting calculations.
  47268. */
  47269. private _globalAmbientColor;
  47270. /**
  47271. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  47272. */
  47273. private _useLogarithmicDepth;
  47274. /**
  47275. * If set to true, no lighting calculations will be applied.
  47276. */
  47277. private _unlit;
  47278. private _debugMode;
  47279. /**
  47280. * @hidden
  47281. * This is reserved for the inspector.
  47282. * Defines the material debug mode.
  47283. * It helps seeing only some components of the material while troubleshooting.
  47284. */
  47285. debugMode: number;
  47286. /**
  47287. * @hidden
  47288. * This is reserved for the inspector.
  47289. * Specify from where on screen the debug mode should start.
  47290. * The value goes from -1 (full screen) to 1 (not visible)
  47291. * It helps with side by side comparison against the final render
  47292. * This defaults to -1
  47293. */
  47294. private debugLimit;
  47295. /**
  47296. * @hidden
  47297. * This is reserved for the inspector.
  47298. * As the default viewing range might not be enough (if the ambient is really small for instance)
  47299. * You can use the factor to better multiply the final value.
  47300. */
  47301. private debugFactor;
  47302. /**
  47303. * Defines the clear coat layer parameters for the material.
  47304. */
  47305. readonly clearCoat: PBRClearCoatConfiguration;
  47306. /**
  47307. * Defines the anisotropic parameters for the material.
  47308. */
  47309. readonly anisotropy: PBRAnisotropicConfiguration;
  47310. /**
  47311. * Defines the BRDF parameters for the material.
  47312. */
  47313. readonly brdf: PBRBRDFConfiguration;
  47314. /**
  47315. * Defines the Sheen parameters for the material.
  47316. */
  47317. readonly sheen: PBRSheenConfiguration;
  47318. /**
  47319. * Defines the SubSurface parameters for the material.
  47320. */
  47321. readonly subSurface: PBRSubSurfaceConfiguration;
  47322. /**
  47323. * Custom callback helping to override the default shader used in the material.
  47324. */
  47325. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  47326. /**
  47327. * Instantiates a new PBRMaterial instance.
  47328. *
  47329. * @param name The material name
  47330. * @param scene The scene the material will be use in.
  47331. */
  47332. constructor(name: string, scene: Scene);
  47333. /**
  47334. * Gets a boolean indicating that current material needs to register RTT
  47335. */
  47336. readonly hasRenderTargetTextures: boolean;
  47337. /**
  47338. * Gets the name of the material class.
  47339. */
  47340. getClassName(): string;
  47341. /**
  47342. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  47343. */
  47344. /**
  47345. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  47346. */
  47347. useLogarithmicDepth: boolean;
  47348. /**
  47349. * Gets the current transparency mode.
  47350. */
  47351. /**
  47352. * Sets the transparency mode of the material.
  47353. *
  47354. * | Value | Type | Description |
  47355. * | ----- | ----------------------------------- | ----------- |
  47356. * | 0 | OPAQUE | |
  47357. * | 1 | ALPHATEST | |
  47358. * | 2 | ALPHABLEND | |
  47359. * | 3 | ALPHATESTANDBLEND | |
  47360. *
  47361. */
  47362. transparencyMode: Nullable<number>;
  47363. /**
  47364. * Returns true if alpha blending should be disabled.
  47365. */
  47366. private readonly _disableAlphaBlending;
  47367. /**
  47368. * Specifies whether or not this material should be rendered in alpha blend mode.
  47369. */
  47370. needAlphaBlending(): boolean;
  47371. /**
  47372. * Specifies if the mesh will require alpha blending.
  47373. * @param mesh - BJS mesh.
  47374. */
  47375. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  47376. /**
  47377. * Specifies whether or not this material should be rendered in alpha test mode.
  47378. */
  47379. needAlphaTesting(): boolean;
  47380. /**
  47381. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  47382. */
  47383. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  47384. /**
  47385. * Gets the texture used for the alpha test.
  47386. */
  47387. getAlphaTestTexture(): Nullable<BaseTexture>;
  47388. /**
  47389. * Specifies that the submesh is ready to be used.
  47390. * @param mesh - BJS mesh.
  47391. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  47392. * @param useInstances - Specifies that instances should be used.
  47393. * @returns - boolean indicating that the submesh is ready or not.
  47394. */
  47395. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  47396. /**
  47397. * Specifies if the material uses metallic roughness workflow.
  47398. * @returns boolean specifiying if the material uses metallic roughness workflow.
  47399. */
  47400. isMetallicWorkflow(): boolean;
  47401. private _prepareEffect;
  47402. private _prepareDefines;
  47403. /**
  47404. * Force shader compilation
  47405. */
  47406. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  47407. clipPlane: boolean;
  47408. }>): void;
  47409. /**
  47410. * Initializes the uniform buffer layout for the shader.
  47411. */
  47412. buildUniformLayout(): void;
  47413. /**
  47414. * Unbinds the material from the mesh
  47415. */
  47416. unbind(): void;
  47417. /**
  47418. * Binds the submesh data.
  47419. * @param world - The world matrix.
  47420. * @param mesh - The BJS mesh.
  47421. * @param subMesh - A submesh of the BJS mesh.
  47422. */
  47423. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  47424. /**
  47425. * Returns the animatable textures.
  47426. * @returns - Array of animatable textures.
  47427. */
  47428. getAnimatables(): IAnimatable[];
  47429. /**
  47430. * Returns the texture used for reflections.
  47431. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  47432. */
  47433. private _getReflectionTexture;
  47434. /**
  47435. * Returns an array of the actively used textures.
  47436. * @returns - Array of BaseTextures
  47437. */
  47438. getActiveTextures(): BaseTexture[];
  47439. /**
  47440. * Checks to see if a texture is used in the material.
  47441. * @param texture - Base texture to use.
  47442. * @returns - Boolean specifying if a texture is used in the material.
  47443. */
  47444. hasTexture(texture: BaseTexture): boolean;
  47445. /**
  47446. * Disposes the resources of the material.
  47447. * @param forceDisposeEffect - Forces the disposal of effects.
  47448. * @param forceDisposeTextures - Forces the disposal of all textures.
  47449. */
  47450. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  47451. }
  47452. }
  47453. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  47454. import { Nullable } from "babylonjs/types";
  47455. import { Scene } from "babylonjs/scene";
  47456. import { Color3 } from "babylonjs/Maths/math";
  47457. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  47458. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  47459. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47460. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  47461. /**
  47462. * The Physically based material of BJS.
  47463. *
  47464. * This offers the main features of a standard PBR material.
  47465. * For more information, please refer to the documentation :
  47466. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  47467. */
  47468. export class PBRMaterial extends PBRBaseMaterial {
  47469. /**
  47470. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  47471. */
  47472. static readonly PBRMATERIAL_OPAQUE: number;
  47473. /**
  47474. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  47475. */
  47476. static readonly PBRMATERIAL_ALPHATEST: number;
  47477. /**
  47478. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47479. */
  47480. static readonly PBRMATERIAL_ALPHABLEND: number;
  47481. /**
  47482. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47483. * They are also discarded below the alpha cutoff threshold to improve performances.
  47484. */
  47485. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  47486. /**
  47487. * Defines the default value of how much AO map is occluding the analytical lights
  47488. * (point spot...).
  47489. */
  47490. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  47491. /**
  47492. * Intensity of the direct lights e.g. the four lights available in your scene.
  47493. * This impacts both the direct diffuse and specular highlights.
  47494. */
  47495. directIntensity: number;
  47496. /**
  47497. * Intensity of the emissive part of the material.
  47498. * This helps controlling the emissive effect without modifying the emissive color.
  47499. */
  47500. emissiveIntensity: number;
  47501. /**
  47502. * Intensity of the environment e.g. how much the environment will light the object
  47503. * either through harmonics for rough material or through the refelction for shiny ones.
  47504. */
  47505. environmentIntensity: number;
  47506. /**
  47507. * This is a special control allowing the reduction of the specular highlights coming from the
  47508. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  47509. */
  47510. specularIntensity: number;
  47511. /**
  47512. * Debug Control allowing disabling the bump map on this material.
  47513. */
  47514. disableBumpMap: boolean;
  47515. /**
  47516. * AKA Diffuse Texture in standard nomenclature.
  47517. */
  47518. albedoTexture: BaseTexture;
  47519. /**
  47520. * AKA Occlusion Texture in other nomenclature.
  47521. */
  47522. ambientTexture: BaseTexture;
  47523. /**
  47524. * AKA Occlusion Texture Intensity in other nomenclature.
  47525. */
  47526. ambientTextureStrength: number;
  47527. /**
  47528. * Defines how much the AO map is occluding the analytical lights (point spot...).
  47529. * 1 means it completely occludes it
  47530. * 0 mean it has no impact
  47531. */
  47532. ambientTextureImpactOnAnalyticalLights: number;
  47533. /**
  47534. * Stores the alpha values in a texture.
  47535. */
  47536. opacityTexture: BaseTexture;
  47537. /**
  47538. * Stores the reflection values in a texture.
  47539. */
  47540. reflectionTexture: Nullable<BaseTexture>;
  47541. /**
  47542. * Stores the emissive values in a texture.
  47543. */
  47544. emissiveTexture: BaseTexture;
  47545. /**
  47546. * AKA Specular texture in other nomenclature.
  47547. */
  47548. reflectivityTexture: BaseTexture;
  47549. /**
  47550. * Used to switch from specular/glossiness to metallic/roughness workflow.
  47551. */
  47552. metallicTexture: BaseTexture;
  47553. /**
  47554. * Specifies the metallic scalar of the metallic/roughness workflow.
  47555. * Can also be used to scale the metalness values of the metallic texture.
  47556. */
  47557. metallic: Nullable<number>;
  47558. /**
  47559. * Specifies the roughness scalar of the metallic/roughness workflow.
  47560. * Can also be used to scale the roughness values of the metallic texture.
  47561. */
  47562. roughness: Nullable<number>;
  47563. /**
  47564. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  47565. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  47566. */
  47567. microSurfaceTexture: BaseTexture;
  47568. /**
  47569. * Stores surface normal data used to displace a mesh in a texture.
  47570. */
  47571. bumpTexture: BaseTexture;
  47572. /**
  47573. * Stores the pre-calculated light information of a mesh in a texture.
  47574. */
  47575. lightmapTexture: BaseTexture;
  47576. /**
  47577. * Stores the refracted light information in a texture.
  47578. */
  47579. refractionTexture: Nullable<BaseTexture>;
  47580. /**
  47581. * The color of a material in ambient lighting.
  47582. */
  47583. ambientColor: Color3;
  47584. /**
  47585. * AKA Diffuse Color in other nomenclature.
  47586. */
  47587. albedoColor: Color3;
  47588. /**
  47589. * AKA Specular Color in other nomenclature.
  47590. */
  47591. reflectivityColor: Color3;
  47592. /**
  47593. * The color reflected from the material.
  47594. */
  47595. reflectionColor: Color3;
  47596. /**
  47597. * The color emitted from the material.
  47598. */
  47599. emissiveColor: Color3;
  47600. /**
  47601. * AKA Glossiness in other nomenclature.
  47602. */
  47603. microSurface: number;
  47604. /**
  47605. * source material index of refraction (IOR)' / 'destination material IOR.
  47606. */
  47607. indexOfRefraction: number;
  47608. /**
  47609. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  47610. */
  47611. invertRefractionY: boolean;
  47612. /**
  47613. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  47614. * Materials half opaque for instance using refraction could benefit from this control.
  47615. */
  47616. linkRefractionWithTransparency: boolean;
  47617. /**
  47618. * If true, the light map contains occlusion information instead of lighting info.
  47619. */
  47620. useLightmapAsShadowmap: boolean;
  47621. /**
  47622. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  47623. */
  47624. useAlphaFromAlbedoTexture: boolean;
  47625. /**
  47626. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  47627. */
  47628. forceAlphaTest: boolean;
  47629. /**
  47630. * Defines the alpha limits in alpha test mode.
  47631. */
  47632. alphaCutOff: number;
  47633. /**
  47634. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  47635. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  47636. */
  47637. useSpecularOverAlpha: boolean;
  47638. /**
  47639. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  47640. */
  47641. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  47642. /**
  47643. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  47644. */
  47645. useRoughnessFromMetallicTextureAlpha: boolean;
  47646. /**
  47647. * Specifies if the metallic texture contains the roughness information in its green channel.
  47648. */
  47649. useRoughnessFromMetallicTextureGreen: boolean;
  47650. /**
  47651. * Specifies if the metallic texture contains the metallness information in its blue channel.
  47652. */
  47653. useMetallnessFromMetallicTextureBlue: boolean;
  47654. /**
  47655. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  47656. */
  47657. useAmbientOcclusionFromMetallicTextureRed: boolean;
  47658. /**
  47659. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  47660. */
  47661. useAmbientInGrayScale: boolean;
  47662. /**
  47663. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  47664. * The material will try to infer what glossiness each pixel should be.
  47665. */
  47666. useAutoMicroSurfaceFromReflectivityMap: boolean;
  47667. /**
  47668. * BJS is using an harcoded light falloff based on a manually sets up range.
  47669. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  47670. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  47671. */
  47672. /**
  47673. * BJS is using an harcoded light falloff based on a manually sets up range.
  47674. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  47675. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  47676. */
  47677. usePhysicalLightFalloff: boolean;
  47678. /**
  47679. * In order to support the falloff compatibility with gltf, a special mode has been added
  47680. * to reproduce the gltf light falloff.
  47681. */
  47682. /**
  47683. * In order to support the falloff compatibility with gltf, a special mode has been added
  47684. * to reproduce the gltf light falloff.
  47685. */
  47686. useGLTFLightFalloff: boolean;
  47687. /**
  47688. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  47689. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  47690. */
  47691. useRadianceOverAlpha: boolean;
  47692. /**
  47693. * Allows using an object space normal map (instead of tangent space).
  47694. */
  47695. useObjectSpaceNormalMap: boolean;
  47696. /**
  47697. * Allows using the bump map in parallax mode.
  47698. */
  47699. useParallax: boolean;
  47700. /**
  47701. * Allows using the bump map in parallax occlusion mode.
  47702. */
  47703. useParallaxOcclusion: boolean;
  47704. /**
  47705. * Controls the scale bias of the parallax mode.
  47706. */
  47707. parallaxScaleBias: number;
  47708. /**
  47709. * If sets to true, disables all the lights affecting the material.
  47710. */
  47711. disableLighting: boolean;
  47712. /**
  47713. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  47714. */
  47715. forceIrradianceInFragment: boolean;
  47716. /**
  47717. * Number of Simultaneous lights allowed on the material.
  47718. */
  47719. maxSimultaneousLights: number;
  47720. /**
  47721. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  47722. */
  47723. invertNormalMapX: boolean;
  47724. /**
  47725. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  47726. */
  47727. invertNormalMapY: boolean;
  47728. /**
  47729. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47730. */
  47731. twoSidedLighting: boolean;
  47732. /**
  47733. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47734. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  47735. */
  47736. useAlphaFresnel: boolean;
  47737. /**
  47738. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47739. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  47740. */
  47741. useLinearAlphaFresnel: boolean;
  47742. /**
  47743. * Let user defines the brdf lookup texture used for IBL.
  47744. * A default 8bit version is embedded but you could point at :
  47745. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  47746. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  47747. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  47748. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  47749. */
  47750. environmentBRDFTexture: Nullable<BaseTexture>;
  47751. /**
  47752. * Force normal to face away from face.
  47753. */
  47754. forceNormalForward: boolean;
  47755. /**
  47756. * Enables specular anti aliasing in the PBR shader.
  47757. * It will both interacts on the Geometry for analytical and IBL lighting.
  47758. * It also prefilter the roughness map based on the bump values.
  47759. */
  47760. enableSpecularAntiAliasing: boolean;
  47761. /**
  47762. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  47763. * makes the reflect vector face the model (under horizon).
  47764. */
  47765. useHorizonOcclusion: boolean;
  47766. /**
  47767. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  47768. * too much the area relying on ambient texture to define their ambient occlusion.
  47769. */
  47770. useRadianceOcclusion: boolean;
  47771. /**
  47772. * If set to true, no lighting calculations will be applied.
  47773. */
  47774. unlit: boolean;
  47775. /**
  47776. * Gets the image processing configuration used either in this material.
  47777. */
  47778. /**
  47779. * Sets the Default image processing configuration used either in the this material.
  47780. *
  47781. * If sets to null, the scene one is in use.
  47782. */
  47783. imageProcessingConfiguration: ImageProcessingConfiguration;
  47784. /**
  47785. * Gets wether the color curves effect is enabled.
  47786. */
  47787. /**
  47788. * Sets wether the color curves effect is enabled.
  47789. */
  47790. cameraColorCurvesEnabled: boolean;
  47791. /**
  47792. * Gets wether the color grading effect is enabled.
  47793. */
  47794. /**
  47795. * Gets wether the color grading effect is enabled.
  47796. */
  47797. cameraColorGradingEnabled: boolean;
  47798. /**
  47799. * Gets wether tonemapping is enabled or not.
  47800. */
  47801. /**
  47802. * Sets wether tonemapping is enabled or not
  47803. */
  47804. cameraToneMappingEnabled: boolean;
  47805. /**
  47806. * The camera exposure used on this material.
  47807. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47808. * This corresponds to a photographic exposure.
  47809. */
  47810. /**
  47811. * The camera exposure used on this material.
  47812. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47813. * This corresponds to a photographic exposure.
  47814. */
  47815. cameraExposure: number;
  47816. /**
  47817. * Gets The camera contrast used on this material.
  47818. */
  47819. /**
  47820. * Sets The camera contrast used on this material.
  47821. */
  47822. cameraContrast: number;
  47823. /**
  47824. * Gets the Color Grading 2D Lookup Texture.
  47825. */
  47826. /**
  47827. * Sets the Color Grading 2D Lookup Texture.
  47828. */
  47829. cameraColorGradingTexture: Nullable<BaseTexture>;
  47830. /**
  47831. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47832. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47833. * 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;
  47834. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47835. */
  47836. /**
  47837. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47838. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47839. * 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;
  47840. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47841. */
  47842. cameraColorCurves: Nullable<ColorCurves>;
  47843. /**
  47844. * Instantiates a new PBRMaterial instance.
  47845. *
  47846. * @param name The material name
  47847. * @param scene The scene the material will be use in.
  47848. */
  47849. constructor(name: string, scene: Scene);
  47850. /**
  47851. * Returns the name of this material class.
  47852. */
  47853. getClassName(): string;
  47854. /**
  47855. * Makes a duplicate of the current material.
  47856. * @param name - name to use for the new material.
  47857. */
  47858. clone(name: string): PBRMaterial;
  47859. /**
  47860. * Serializes this PBR Material.
  47861. * @returns - An object with the serialized material.
  47862. */
  47863. serialize(): any;
  47864. /**
  47865. * Parses a PBR Material from a serialized object.
  47866. * @param source - Serialized object.
  47867. * @param scene - BJS scene instance.
  47868. * @param rootUrl - url for the scene object
  47869. * @returns - PBRMaterial
  47870. */
  47871. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  47872. }
  47873. }
  47874. declare module "babylonjs/Misc/dds" {
  47875. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  47876. import { Engine } from "babylonjs/Engines/engine";
  47877. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47878. import { Nullable } from "babylonjs/types";
  47879. import { Scene } from "babylonjs/scene";
  47880. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  47881. /**
  47882. * Direct draw surface info
  47883. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  47884. */
  47885. export interface DDSInfo {
  47886. /**
  47887. * Width of the texture
  47888. */
  47889. width: number;
  47890. /**
  47891. * Width of the texture
  47892. */
  47893. height: number;
  47894. /**
  47895. * Number of Mipmaps for the texture
  47896. * @see https://en.wikipedia.org/wiki/Mipmap
  47897. */
  47898. mipmapCount: number;
  47899. /**
  47900. * If the textures format is a known fourCC format
  47901. * @see https://www.fourcc.org/
  47902. */
  47903. isFourCC: boolean;
  47904. /**
  47905. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  47906. */
  47907. isRGB: boolean;
  47908. /**
  47909. * If the texture is a lumincance format
  47910. */
  47911. isLuminance: boolean;
  47912. /**
  47913. * If this is a cube texture
  47914. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  47915. */
  47916. isCube: boolean;
  47917. /**
  47918. * If the texture is a compressed format eg. FOURCC_DXT1
  47919. */
  47920. isCompressed: boolean;
  47921. /**
  47922. * The dxgiFormat of the texture
  47923. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  47924. */
  47925. dxgiFormat: number;
  47926. /**
  47927. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  47928. */
  47929. textureType: number;
  47930. /**
  47931. * Sphericle polynomial created for the dds texture
  47932. */
  47933. sphericalPolynomial?: SphericalPolynomial;
  47934. }
  47935. /**
  47936. * Class used to provide DDS decompression tools
  47937. */
  47938. export class DDSTools {
  47939. /**
  47940. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  47941. */
  47942. static StoreLODInAlphaChannel: boolean;
  47943. /**
  47944. * Gets DDS information from an array buffer
  47945. * @param arrayBuffer defines the array buffer to read data from
  47946. * @returns the DDS information
  47947. */
  47948. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  47949. private static _FloatView;
  47950. private static _Int32View;
  47951. private static _ToHalfFloat;
  47952. private static _FromHalfFloat;
  47953. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  47954. private static _GetHalfFloatRGBAArrayBuffer;
  47955. private static _GetFloatRGBAArrayBuffer;
  47956. private static _GetFloatAsUIntRGBAArrayBuffer;
  47957. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  47958. private static _GetRGBAArrayBuffer;
  47959. private static _ExtractLongWordOrder;
  47960. private static _GetRGBArrayBuffer;
  47961. private static _GetLuminanceArrayBuffer;
  47962. /**
  47963. * Uploads DDS Levels to a Babylon Texture
  47964. * @hidden
  47965. */
  47966. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  47967. }
  47968. module "babylonjs/Engines/engine" {
  47969. interface Engine {
  47970. /**
  47971. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  47972. * @param rootUrl defines the url where the file to load is located
  47973. * @param scene defines the current scene
  47974. * @param lodScale defines scale to apply to the mip map selection
  47975. * @param lodOffset defines offset to apply to the mip map selection
  47976. * @param onLoad defines an optional callback raised when the texture is loaded
  47977. * @param onError defines an optional callback raised if there is an issue to load the texture
  47978. * @param format defines the format of the data
  47979. * @param forcedExtension defines the extension to use to pick the right loader
  47980. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  47981. * @returns the cube texture as an InternalTexture
  47982. */
  47983. 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;
  47984. }
  47985. }
  47986. }
  47987. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  47988. import { Nullable } from "babylonjs/types";
  47989. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47990. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  47991. /**
  47992. * Implementation of the DDS Texture Loader.
  47993. * @hidden
  47994. */
  47995. export class _DDSTextureLoader implements IInternalTextureLoader {
  47996. /**
  47997. * Defines wether the loader supports cascade loading the different faces.
  47998. */
  47999. readonly supportCascades: boolean;
  48000. /**
  48001. * This returns if the loader support the current file information.
  48002. * @param extension defines the file extension of the file being loaded
  48003. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48004. * @param fallback defines the fallback internal texture if any
  48005. * @param isBase64 defines whether the texture is encoded as a base64
  48006. * @param isBuffer defines whether the texture data are stored as a buffer
  48007. * @returns true if the loader can load the specified file
  48008. */
  48009. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48010. /**
  48011. * Transform the url before loading if required.
  48012. * @param rootUrl the url of the texture
  48013. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48014. * @returns the transformed texture
  48015. */
  48016. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48017. /**
  48018. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48019. * @param rootUrl the url of the texture
  48020. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48021. * @returns the fallback texture
  48022. */
  48023. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48024. /**
  48025. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48026. * @param data contains the texture data
  48027. * @param texture defines the BabylonJS internal texture
  48028. * @param createPolynomials will be true if polynomials have been requested
  48029. * @param onLoad defines the callback to trigger once the texture is ready
  48030. * @param onError defines the callback to trigger in case of error
  48031. */
  48032. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48033. /**
  48034. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48035. * @param data contains the texture data
  48036. * @param texture defines the BabylonJS internal texture
  48037. * @param callback defines the method to call once ready to upload
  48038. */
  48039. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48040. }
  48041. }
  48042. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  48043. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48044. /** @hidden */
  48045. export var rgbdEncodePixelShader: {
  48046. name: string;
  48047. shader: string;
  48048. };
  48049. }
  48050. declare module "babylonjs/Misc/environmentTextureTools" {
  48051. import { Nullable } from "babylonjs/types";
  48052. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48053. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48054. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  48055. import "babylonjs/Engines/Extensions/engine.renderTarget";
  48056. import "babylonjs/Shaders/rgbdEncode.fragment";
  48057. import "babylonjs/Shaders/rgbdDecode.fragment";
  48058. /**
  48059. * Raw texture data and descriptor sufficient for WebGL texture upload
  48060. */
  48061. export interface EnvironmentTextureInfo {
  48062. /**
  48063. * Version of the environment map
  48064. */
  48065. version: number;
  48066. /**
  48067. * Width of image
  48068. */
  48069. width: number;
  48070. /**
  48071. * Irradiance information stored in the file.
  48072. */
  48073. irradiance: any;
  48074. /**
  48075. * Specular information stored in the file.
  48076. */
  48077. specular: any;
  48078. }
  48079. /**
  48080. * Sets of helpers addressing the serialization and deserialization of environment texture
  48081. * stored in a BabylonJS env file.
  48082. * Those files are usually stored as .env files.
  48083. */
  48084. export class EnvironmentTextureTools {
  48085. /**
  48086. * Magic number identifying the env file.
  48087. */
  48088. private static _MagicBytes;
  48089. /**
  48090. * Gets the environment info from an env file.
  48091. * @param data The array buffer containing the .env bytes.
  48092. * @returns the environment file info (the json header) if successfully parsed.
  48093. */
  48094. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  48095. /**
  48096. * Creates an environment texture from a loaded cube texture.
  48097. * @param texture defines the cube texture to convert in env file
  48098. * @return a promise containing the environment data if succesfull.
  48099. */
  48100. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  48101. /**
  48102. * Creates a JSON representation of the spherical data.
  48103. * @param texture defines the texture containing the polynomials
  48104. * @return the JSON representation of the spherical info
  48105. */
  48106. private static _CreateEnvTextureIrradiance;
  48107. /**
  48108. * Uploads the texture info contained in the env file to the GPU.
  48109. * @param texture defines the internal texture to upload to
  48110. * @param arrayBuffer defines the buffer cotaining the data to load
  48111. * @param info defines the texture info retrieved through the GetEnvInfo method
  48112. * @returns a promise
  48113. */
  48114. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  48115. /**
  48116. * Uploads the levels of image data to the GPU.
  48117. * @param texture defines the internal texture to upload to
  48118. * @param imageData defines the array buffer views of image data [mipmap][face]
  48119. * @returns a promise
  48120. */
  48121. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  48122. /**
  48123. * Uploads spherical polynomials information to the texture.
  48124. * @param texture defines the texture we are trying to upload the information to
  48125. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  48126. */
  48127. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  48128. /** @hidden */
  48129. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  48130. }
  48131. }
  48132. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  48133. import { Nullable } from "babylonjs/types";
  48134. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48135. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48136. /**
  48137. * Implementation of the ENV Texture Loader.
  48138. * @hidden
  48139. */
  48140. export class _ENVTextureLoader implements IInternalTextureLoader {
  48141. /**
  48142. * Defines wether the loader supports cascade loading the different faces.
  48143. */
  48144. readonly supportCascades: boolean;
  48145. /**
  48146. * This returns if the loader support the current file information.
  48147. * @param extension defines the file extension of the file being loaded
  48148. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48149. * @param fallback defines the fallback internal texture if any
  48150. * @param isBase64 defines whether the texture is encoded as a base64
  48151. * @param isBuffer defines whether the texture data are stored as a buffer
  48152. * @returns true if the loader can load the specified file
  48153. */
  48154. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48155. /**
  48156. * Transform the url before loading if required.
  48157. * @param rootUrl the url of the texture
  48158. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48159. * @returns the transformed texture
  48160. */
  48161. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48162. /**
  48163. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48164. * @param rootUrl the url of the texture
  48165. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48166. * @returns the fallback texture
  48167. */
  48168. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48169. /**
  48170. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48171. * @param data contains the texture data
  48172. * @param texture defines the BabylonJS internal texture
  48173. * @param createPolynomials will be true if polynomials have been requested
  48174. * @param onLoad defines the callback to trigger once the texture is ready
  48175. * @param onError defines the callback to trigger in case of error
  48176. */
  48177. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48178. /**
  48179. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48180. * @param data contains the texture data
  48181. * @param texture defines the BabylonJS internal texture
  48182. * @param callback defines the method to call once ready to upload
  48183. */
  48184. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48185. }
  48186. }
  48187. declare module "babylonjs/Misc/khronosTextureContainer" {
  48188. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48189. /**
  48190. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  48191. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  48192. */
  48193. export class KhronosTextureContainer {
  48194. /** contents of the KTX container file */
  48195. arrayBuffer: any;
  48196. private static HEADER_LEN;
  48197. private static COMPRESSED_2D;
  48198. private static COMPRESSED_3D;
  48199. private static TEX_2D;
  48200. private static TEX_3D;
  48201. /**
  48202. * Gets the openGL type
  48203. */
  48204. glType: number;
  48205. /**
  48206. * Gets the openGL type size
  48207. */
  48208. glTypeSize: number;
  48209. /**
  48210. * Gets the openGL format
  48211. */
  48212. glFormat: number;
  48213. /**
  48214. * Gets the openGL internal format
  48215. */
  48216. glInternalFormat: number;
  48217. /**
  48218. * Gets the base internal format
  48219. */
  48220. glBaseInternalFormat: number;
  48221. /**
  48222. * Gets image width in pixel
  48223. */
  48224. pixelWidth: number;
  48225. /**
  48226. * Gets image height in pixel
  48227. */
  48228. pixelHeight: number;
  48229. /**
  48230. * Gets image depth in pixels
  48231. */
  48232. pixelDepth: number;
  48233. /**
  48234. * Gets the number of array elements
  48235. */
  48236. numberOfArrayElements: number;
  48237. /**
  48238. * Gets the number of faces
  48239. */
  48240. numberOfFaces: number;
  48241. /**
  48242. * Gets the number of mipmap levels
  48243. */
  48244. numberOfMipmapLevels: number;
  48245. /**
  48246. * Gets the bytes of key value data
  48247. */
  48248. bytesOfKeyValueData: number;
  48249. /**
  48250. * Gets the load type
  48251. */
  48252. loadType: number;
  48253. /**
  48254. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  48255. */
  48256. isInvalid: boolean;
  48257. /**
  48258. * Creates a new KhronosTextureContainer
  48259. * @param arrayBuffer contents of the KTX container file
  48260. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  48261. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  48262. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  48263. */
  48264. constructor(
  48265. /** contents of the KTX container file */
  48266. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  48267. /**
  48268. * Uploads KTX content to a Babylon Texture.
  48269. * It is assumed that the texture has already been created & is currently bound
  48270. * @hidden
  48271. */
  48272. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  48273. private _upload2DCompressedLevels;
  48274. }
  48275. }
  48276. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  48277. import { Nullable } from "babylonjs/types";
  48278. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48279. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48280. /**
  48281. * Implementation of the KTX Texture Loader.
  48282. * @hidden
  48283. */
  48284. export class _KTXTextureLoader implements IInternalTextureLoader {
  48285. /**
  48286. * Defines wether the loader supports cascade loading the different faces.
  48287. */
  48288. readonly supportCascades: boolean;
  48289. /**
  48290. * This returns if the loader support the current file information.
  48291. * @param extension defines the file extension of the file being loaded
  48292. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48293. * @param fallback defines the fallback internal texture if any
  48294. * @param isBase64 defines whether the texture is encoded as a base64
  48295. * @param isBuffer defines whether the texture data are stored as a buffer
  48296. * @returns true if the loader can load the specified file
  48297. */
  48298. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48299. /**
  48300. * Transform the url before loading if required.
  48301. * @param rootUrl the url of the texture
  48302. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48303. * @returns the transformed texture
  48304. */
  48305. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48306. /**
  48307. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48308. * @param rootUrl the url of the texture
  48309. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48310. * @returns the fallback texture
  48311. */
  48312. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48313. /**
  48314. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48315. * @param data contains the texture data
  48316. * @param texture defines the BabylonJS internal texture
  48317. * @param createPolynomials will be true if polynomials have been requested
  48318. * @param onLoad defines the callback to trigger once the texture is ready
  48319. * @param onError defines the callback to trigger in case of error
  48320. */
  48321. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48322. /**
  48323. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48324. * @param data contains the texture data
  48325. * @param texture defines the BabylonJS internal texture
  48326. * @param callback defines the method to call once ready to upload
  48327. */
  48328. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  48329. }
  48330. }
  48331. declare module "babylonjs/Helpers/sceneHelpers" {
  48332. import { Nullable } from "babylonjs/types";
  48333. import { Mesh } from "babylonjs/Meshes/mesh";
  48334. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48335. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  48336. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  48337. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  48338. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  48339. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  48340. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  48341. import "babylonjs/Meshes/Builders/boxBuilder";
  48342. /** @hidden */
  48343. export var _forceSceneHelpersToBundle: boolean;
  48344. module "babylonjs/scene" {
  48345. interface Scene {
  48346. /**
  48347. * Creates a default light for the scene.
  48348. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  48349. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  48350. */
  48351. createDefaultLight(replace?: boolean): void;
  48352. /**
  48353. * Creates a default camera for the scene.
  48354. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  48355. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  48356. * @param replace has default false, when true replaces the active camera in the scene
  48357. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  48358. */
  48359. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  48360. /**
  48361. * Creates a default camera and a default light.
  48362. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  48363. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  48364. * @param replace has the default false, when true replaces the active camera/light in the scene
  48365. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  48366. */
  48367. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  48368. /**
  48369. * Creates a new sky box
  48370. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  48371. * @param environmentTexture defines the texture to use as environment texture
  48372. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  48373. * @param scale defines the overall scale of the skybox
  48374. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  48375. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  48376. * @returns a new mesh holding the sky box
  48377. */
  48378. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  48379. /**
  48380. * Creates a new environment
  48381. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  48382. * @param options defines the options you can use to configure the environment
  48383. * @returns the new EnvironmentHelper
  48384. */
  48385. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  48386. /**
  48387. * Creates a new VREXperienceHelper
  48388. * @see http://doc.babylonjs.com/how_to/webvr_helper
  48389. * @param webVROptions defines the options used to create the new VREXperienceHelper
  48390. * @returns a new VREXperienceHelper
  48391. */
  48392. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  48393. /**
  48394. * Creates a new XREXperienceHelper
  48395. * @see http://doc.babylonjs.com/how_to/webxr
  48396. * @returns a promise for a new XREXperienceHelper
  48397. */
  48398. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  48399. }
  48400. }
  48401. }
  48402. declare module "babylonjs/Helpers/videoDome" {
  48403. import { Scene } from "babylonjs/scene";
  48404. import { TransformNode } from "babylonjs/Meshes/transformNode";
  48405. import { Mesh } from "babylonjs/Meshes/mesh";
  48406. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  48407. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  48408. import "babylonjs/Meshes/Builders/sphereBuilder";
  48409. /**
  48410. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  48411. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  48412. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  48413. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  48414. */
  48415. export class VideoDome extends TransformNode {
  48416. /**
  48417. * Define the video source as a Monoscopic panoramic 360 video.
  48418. */
  48419. static readonly MODE_MONOSCOPIC: number;
  48420. /**
  48421. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  48422. */
  48423. static readonly MODE_TOPBOTTOM: number;
  48424. /**
  48425. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  48426. */
  48427. static readonly MODE_SIDEBYSIDE: number;
  48428. private _useDirectMapping;
  48429. /**
  48430. * The video texture being displayed on the sphere
  48431. */
  48432. protected _videoTexture: VideoTexture;
  48433. /**
  48434. * Gets the video texture being displayed on the sphere
  48435. */
  48436. readonly videoTexture: VideoTexture;
  48437. /**
  48438. * The skybox material
  48439. */
  48440. protected _material: BackgroundMaterial;
  48441. /**
  48442. * The surface used for the skybox
  48443. */
  48444. protected _mesh: Mesh;
  48445. /**
  48446. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48447. * Also see the options.resolution property.
  48448. */
  48449. fovMultiplier: number;
  48450. private _videoMode;
  48451. /**
  48452. * Gets or set the current video mode for the video. It can be:
  48453. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  48454. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  48455. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  48456. */
  48457. videoMode: number;
  48458. /**
  48459. * Oberserver used in Stereoscopic VR Mode.
  48460. */
  48461. private _onBeforeCameraRenderObserver;
  48462. /**
  48463. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  48464. * @param name Element's name, child elements will append suffixes for their own names.
  48465. * @param urlsOrVideo defines the url(s) or the video element to use
  48466. * @param options An object containing optional or exposed sub element properties
  48467. */
  48468. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  48469. resolution?: number;
  48470. clickToPlay?: boolean;
  48471. autoPlay?: boolean;
  48472. loop?: boolean;
  48473. size?: number;
  48474. poster?: string;
  48475. faceForward?: boolean;
  48476. useDirectMapping?: boolean;
  48477. }, scene: Scene);
  48478. private _changeVideoMode;
  48479. /**
  48480. * Releases resources associated with this node.
  48481. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  48482. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  48483. */
  48484. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  48485. }
  48486. }
  48487. declare module "babylonjs/Helpers/index" {
  48488. export * from "babylonjs/Helpers/environmentHelper";
  48489. export * from "babylonjs/Helpers/photoDome";
  48490. export * from "babylonjs/Helpers/sceneHelpers";
  48491. export * from "babylonjs/Helpers/videoDome";
  48492. }
  48493. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  48494. import { PerfCounter } from "babylonjs/Misc/tools";
  48495. import { IDisposable } from "babylonjs/scene";
  48496. import { Engine } from "babylonjs/Engines/engine";
  48497. /**
  48498. * This class can be used to get instrumentation data from a Babylon engine
  48499. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  48500. */
  48501. export class EngineInstrumentation implements IDisposable {
  48502. /**
  48503. * Define the instrumented engine.
  48504. */
  48505. engine: Engine;
  48506. private _captureGPUFrameTime;
  48507. private _gpuFrameTimeToken;
  48508. private _gpuFrameTime;
  48509. private _captureShaderCompilationTime;
  48510. private _shaderCompilationTime;
  48511. private _onBeginFrameObserver;
  48512. private _onEndFrameObserver;
  48513. private _onBeforeShaderCompilationObserver;
  48514. private _onAfterShaderCompilationObserver;
  48515. /**
  48516. * Gets the perf counter used for GPU frame time
  48517. */
  48518. readonly gpuFrameTimeCounter: PerfCounter;
  48519. /**
  48520. * Gets the GPU frame time capture status
  48521. */
  48522. /**
  48523. * Enable or disable the GPU frame time capture
  48524. */
  48525. captureGPUFrameTime: boolean;
  48526. /**
  48527. * Gets the perf counter used for shader compilation time
  48528. */
  48529. readonly shaderCompilationTimeCounter: PerfCounter;
  48530. /**
  48531. * Gets the shader compilation time capture status
  48532. */
  48533. /**
  48534. * Enable or disable the shader compilation time capture
  48535. */
  48536. captureShaderCompilationTime: boolean;
  48537. /**
  48538. * Instantiates a new engine instrumentation.
  48539. * This class can be used to get instrumentation data from a Babylon engine
  48540. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  48541. * @param engine Defines the engine to instrument
  48542. */
  48543. constructor(
  48544. /**
  48545. * Define the instrumented engine.
  48546. */
  48547. engine: Engine);
  48548. /**
  48549. * Dispose and release associated resources.
  48550. */
  48551. dispose(): void;
  48552. }
  48553. }
  48554. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  48555. import { PerfCounter } from "babylonjs/Misc/tools";
  48556. import { Scene, IDisposable } from "babylonjs/scene";
  48557. /**
  48558. * This class can be used to get instrumentation data from a Babylon engine
  48559. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  48560. */
  48561. export class SceneInstrumentation implements IDisposable {
  48562. /**
  48563. * Defines the scene to instrument
  48564. */
  48565. scene: Scene;
  48566. private _captureActiveMeshesEvaluationTime;
  48567. private _activeMeshesEvaluationTime;
  48568. private _captureRenderTargetsRenderTime;
  48569. private _renderTargetsRenderTime;
  48570. private _captureFrameTime;
  48571. private _frameTime;
  48572. private _captureRenderTime;
  48573. private _renderTime;
  48574. private _captureInterFrameTime;
  48575. private _interFrameTime;
  48576. private _captureParticlesRenderTime;
  48577. private _particlesRenderTime;
  48578. private _captureSpritesRenderTime;
  48579. private _spritesRenderTime;
  48580. private _capturePhysicsTime;
  48581. private _physicsTime;
  48582. private _captureAnimationsTime;
  48583. private _animationsTime;
  48584. private _captureCameraRenderTime;
  48585. private _cameraRenderTime;
  48586. private _onBeforeActiveMeshesEvaluationObserver;
  48587. private _onAfterActiveMeshesEvaluationObserver;
  48588. private _onBeforeRenderTargetsRenderObserver;
  48589. private _onAfterRenderTargetsRenderObserver;
  48590. private _onAfterRenderObserver;
  48591. private _onBeforeDrawPhaseObserver;
  48592. private _onAfterDrawPhaseObserver;
  48593. private _onBeforeAnimationsObserver;
  48594. private _onBeforeParticlesRenderingObserver;
  48595. private _onAfterParticlesRenderingObserver;
  48596. private _onBeforeSpritesRenderingObserver;
  48597. private _onAfterSpritesRenderingObserver;
  48598. private _onBeforePhysicsObserver;
  48599. private _onAfterPhysicsObserver;
  48600. private _onAfterAnimationsObserver;
  48601. private _onBeforeCameraRenderObserver;
  48602. private _onAfterCameraRenderObserver;
  48603. /**
  48604. * Gets the perf counter used for active meshes evaluation time
  48605. */
  48606. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  48607. /**
  48608. * Gets the active meshes evaluation time capture status
  48609. */
  48610. /**
  48611. * Enable or disable the active meshes evaluation time capture
  48612. */
  48613. captureActiveMeshesEvaluationTime: boolean;
  48614. /**
  48615. * Gets the perf counter used for render targets render time
  48616. */
  48617. readonly renderTargetsRenderTimeCounter: PerfCounter;
  48618. /**
  48619. * Gets the render targets render time capture status
  48620. */
  48621. /**
  48622. * Enable or disable the render targets render time capture
  48623. */
  48624. captureRenderTargetsRenderTime: boolean;
  48625. /**
  48626. * Gets the perf counter used for particles render time
  48627. */
  48628. readonly particlesRenderTimeCounter: PerfCounter;
  48629. /**
  48630. * Gets the particles render time capture status
  48631. */
  48632. /**
  48633. * Enable or disable the particles render time capture
  48634. */
  48635. captureParticlesRenderTime: boolean;
  48636. /**
  48637. * Gets the perf counter used for sprites render time
  48638. */
  48639. readonly spritesRenderTimeCounter: PerfCounter;
  48640. /**
  48641. * Gets the sprites render time capture status
  48642. */
  48643. /**
  48644. * Enable or disable the sprites render time capture
  48645. */
  48646. captureSpritesRenderTime: boolean;
  48647. /**
  48648. * Gets the perf counter used for physics time
  48649. */
  48650. readonly physicsTimeCounter: PerfCounter;
  48651. /**
  48652. * Gets the physics time capture status
  48653. */
  48654. /**
  48655. * Enable or disable the physics time capture
  48656. */
  48657. capturePhysicsTime: boolean;
  48658. /**
  48659. * Gets the perf counter used for animations time
  48660. */
  48661. readonly animationsTimeCounter: PerfCounter;
  48662. /**
  48663. * Gets the animations time capture status
  48664. */
  48665. /**
  48666. * Enable or disable the animations time capture
  48667. */
  48668. captureAnimationsTime: boolean;
  48669. /**
  48670. * Gets the perf counter used for frame time capture
  48671. */
  48672. readonly frameTimeCounter: PerfCounter;
  48673. /**
  48674. * Gets the frame time capture status
  48675. */
  48676. /**
  48677. * Enable or disable the frame time capture
  48678. */
  48679. captureFrameTime: boolean;
  48680. /**
  48681. * Gets the perf counter used for inter-frames time capture
  48682. */
  48683. readonly interFrameTimeCounter: PerfCounter;
  48684. /**
  48685. * Gets the inter-frames time capture status
  48686. */
  48687. /**
  48688. * Enable or disable the inter-frames time capture
  48689. */
  48690. captureInterFrameTime: boolean;
  48691. /**
  48692. * Gets the perf counter used for render time capture
  48693. */
  48694. readonly renderTimeCounter: PerfCounter;
  48695. /**
  48696. * Gets the render time capture status
  48697. */
  48698. /**
  48699. * Enable or disable the render time capture
  48700. */
  48701. captureRenderTime: boolean;
  48702. /**
  48703. * Gets the perf counter used for camera render time capture
  48704. */
  48705. readonly cameraRenderTimeCounter: PerfCounter;
  48706. /**
  48707. * Gets the camera render time capture status
  48708. */
  48709. /**
  48710. * Enable or disable the camera render time capture
  48711. */
  48712. captureCameraRenderTime: boolean;
  48713. /**
  48714. * Gets the perf counter used for draw calls
  48715. */
  48716. readonly drawCallsCounter: PerfCounter;
  48717. /**
  48718. * Instantiates a new scene instrumentation.
  48719. * This class can be used to get instrumentation data from a Babylon engine
  48720. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  48721. * @param scene Defines the scene to instrument
  48722. */
  48723. constructor(
  48724. /**
  48725. * Defines the scene to instrument
  48726. */
  48727. scene: Scene);
  48728. /**
  48729. * Dispose and release associated resources.
  48730. */
  48731. dispose(): void;
  48732. }
  48733. }
  48734. declare module "babylonjs/Instrumentation/index" {
  48735. export * from "babylonjs/Instrumentation/engineInstrumentation";
  48736. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  48737. export * from "babylonjs/Instrumentation/timeToken";
  48738. }
  48739. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  48740. /** @hidden */
  48741. export var glowMapGenerationPixelShader: {
  48742. name: string;
  48743. shader: string;
  48744. };
  48745. }
  48746. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  48747. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  48748. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  48749. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  48750. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  48751. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  48752. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  48753. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  48754. /** @hidden */
  48755. export var glowMapGenerationVertexShader: {
  48756. name: string;
  48757. shader: string;
  48758. };
  48759. }
  48760. declare module "babylonjs/Layers/effectLayer" {
  48761. import { Observable } from "babylonjs/Misc/observable";
  48762. import { Nullable } from "babylonjs/types";
  48763. import { Camera } from "babylonjs/Cameras/camera";
  48764. import { Scene } from "babylonjs/scene";
  48765. import { Color4, ISize } from "babylonjs/Maths/math";
  48766. import { Engine } from "babylonjs/Engines/engine";
  48767. import { SubMesh } from "babylonjs/Meshes/subMesh";
  48768. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48769. import { Mesh } from "babylonjs/Meshes/mesh";
  48770. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  48771. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48772. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48773. import { Effect } from "babylonjs/Materials/effect";
  48774. import { Material } from "babylonjs/Materials/material";
  48775. import "babylonjs/Shaders/glowMapGeneration.fragment";
  48776. import "babylonjs/Shaders/glowMapGeneration.vertex";
  48777. /**
  48778. * Effect layer options. This helps customizing the behaviour
  48779. * of the effect layer.
  48780. */
  48781. export interface IEffectLayerOptions {
  48782. /**
  48783. * Multiplication factor apply to the canvas size to compute the render target size
  48784. * used to generated the objects (the smaller the faster).
  48785. */
  48786. mainTextureRatio: number;
  48787. /**
  48788. * Enforces a fixed size texture to ensure effect stability across devices.
  48789. */
  48790. mainTextureFixedSize?: number;
  48791. /**
  48792. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  48793. */
  48794. alphaBlendingMode: number;
  48795. /**
  48796. * The camera attached to the layer.
  48797. */
  48798. camera: Nullable<Camera>;
  48799. /**
  48800. * The rendering group to draw the layer in.
  48801. */
  48802. renderingGroupId: number;
  48803. }
  48804. /**
  48805. * The effect layer Helps adding post process effect blended with the main pass.
  48806. *
  48807. * This can be for instance use to generate glow or higlight effects on the scene.
  48808. *
  48809. * The effect layer class can not be used directly and is intented to inherited from to be
  48810. * customized per effects.
  48811. */
  48812. export abstract class EffectLayer {
  48813. private _vertexBuffers;
  48814. private _indexBuffer;
  48815. private _cachedDefines;
  48816. private _effectLayerMapGenerationEffect;
  48817. private _effectLayerOptions;
  48818. private _mergeEffect;
  48819. protected _scene: Scene;
  48820. protected _engine: Engine;
  48821. protected _maxSize: number;
  48822. protected _mainTextureDesiredSize: ISize;
  48823. protected _mainTexture: RenderTargetTexture;
  48824. protected _shouldRender: boolean;
  48825. protected _postProcesses: PostProcess[];
  48826. protected _textures: BaseTexture[];
  48827. protected _emissiveTextureAndColor: {
  48828. texture: Nullable<BaseTexture>;
  48829. color: Color4;
  48830. };
  48831. /**
  48832. * The name of the layer
  48833. */
  48834. name: string;
  48835. /**
  48836. * The clear color of the texture used to generate the glow map.
  48837. */
  48838. neutralColor: Color4;
  48839. /**
  48840. * Specifies wether the highlight layer is enabled or not.
  48841. */
  48842. isEnabled: boolean;
  48843. /**
  48844. * Gets the camera attached to the layer.
  48845. */
  48846. readonly camera: Nullable<Camera>;
  48847. /**
  48848. * Gets the rendering group id the layer should render in.
  48849. */
  48850. readonly renderingGroupId: number;
  48851. /**
  48852. * An event triggered when the effect layer has been disposed.
  48853. */
  48854. onDisposeObservable: Observable<EffectLayer>;
  48855. /**
  48856. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  48857. */
  48858. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  48859. /**
  48860. * An event triggered when the generated texture is being merged in the scene.
  48861. */
  48862. onBeforeComposeObservable: Observable<EffectLayer>;
  48863. /**
  48864. * An event triggered when the generated texture has been merged in the scene.
  48865. */
  48866. onAfterComposeObservable: Observable<EffectLayer>;
  48867. /**
  48868. * An event triggered when the efffect layer changes its size.
  48869. */
  48870. onSizeChangedObservable: Observable<EffectLayer>;
  48871. /** @hidden */
  48872. static _SceneComponentInitialization: (scene: Scene) => void;
  48873. /**
  48874. * Instantiates a new effect Layer and references it in the scene.
  48875. * @param name The name of the layer
  48876. * @param scene The scene to use the layer in
  48877. */
  48878. constructor(
  48879. /** The Friendly of the effect in the scene */
  48880. name: string, scene: Scene);
  48881. /**
  48882. * Get the effect name of the layer.
  48883. * @return The effect name
  48884. */
  48885. abstract getEffectName(): string;
  48886. /**
  48887. * Checks for the readiness of the element composing the layer.
  48888. * @param subMesh the mesh to check for
  48889. * @param useInstances specify wether or not to use instances to render the mesh
  48890. * @return true if ready otherwise, false
  48891. */
  48892. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  48893. /**
  48894. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  48895. * @returns true if the effect requires stencil during the main canvas render pass.
  48896. */
  48897. abstract needStencil(): boolean;
  48898. /**
  48899. * Create the merge effect. This is the shader use to blit the information back
  48900. * to the main canvas at the end of the scene rendering.
  48901. * @returns The effect containing the shader used to merge the effect on the main canvas
  48902. */
  48903. protected abstract _createMergeEffect(): Effect;
  48904. /**
  48905. * Creates the render target textures and post processes used in the effect layer.
  48906. */
  48907. protected abstract _createTextureAndPostProcesses(): void;
  48908. /**
  48909. * Implementation specific of rendering the generating effect on the main canvas.
  48910. * @param effect The effect used to render through
  48911. */
  48912. protected abstract _internalRender(effect: Effect): void;
  48913. /**
  48914. * Sets the required values for both the emissive texture and and the main color.
  48915. */
  48916. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  48917. /**
  48918. * Free any resources and references associated to a mesh.
  48919. * Internal use
  48920. * @param mesh The mesh to free.
  48921. */
  48922. abstract _disposeMesh(mesh: Mesh): void;
  48923. /**
  48924. * Serializes this layer (Glow or Highlight for example)
  48925. * @returns a serialized layer object
  48926. */
  48927. abstract serialize?(): any;
  48928. /**
  48929. * Initializes the effect layer with the required options.
  48930. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  48931. */
  48932. protected _init(options: Partial<IEffectLayerOptions>): void;
  48933. /**
  48934. * Generates the index buffer of the full screen quad blending to the main canvas.
  48935. */
  48936. private _generateIndexBuffer;
  48937. /**
  48938. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  48939. */
  48940. private _generateVertexBuffer;
  48941. /**
  48942. * Sets the main texture desired size which is the closest power of two
  48943. * of the engine canvas size.
  48944. */
  48945. private _setMainTextureSize;
  48946. /**
  48947. * Creates the main texture for the effect layer.
  48948. */
  48949. protected _createMainTexture(): void;
  48950. /**
  48951. * Adds specific effects defines.
  48952. * @param defines The defines to add specifics to.
  48953. */
  48954. protected _addCustomEffectDefines(defines: string[]): void;
  48955. /**
  48956. * Checks for the readiness of the element composing the layer.
  48957. * @param subMesh the mesh to check for
  48958. * @param useInstances specify wether or not to use instances to render the mesh
  48959. * @param emissiveTexture the associated emissive texture used to generate the glow
  48960. * @return true if ready otherwise, false
  48961. */
  48962. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  48963. /**
  48964. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  48965. */
  48966. render(): void;
  48967. /**
  48968. * Determine if a given mesh will be used in the current effect.
  48969. * @param mesh mesh to test
  48970. * @returns true if the mesh will be used
  48971. */
  48972. hasMesh(mesh: AbstractMesh): boolean;
  48973. /**
  48974. * Returns true if the layer contains information to display, otherwise false.
  48975. * @returns true if the glow layer should be rendered
  48976. */
  48977. shouldRender(): boolean;
  48978. /**
  48979. * Returns true if the mesh should render, otherwise false.
  48980. * @param mesh The mesh to render
  48981. * @returns true if it should render otherwise false
  48982. */
  48983. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  48984. /**
  48985. * Returns true if the mesh can be rendered, otherwise false.
  48986. * @param mesh The mesh to render
  48987. * @param material The material used on the mesh
  48988. * @returns true if it can be rendered otherwise false
  48989. */
  48990. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  48991. /**
  48992. * Returns true if the mesh should render, otherwise false.
  48993. * @param mesh The mesh to render
  48994. * @returns true if it should render otherwise false
  48995. */
  48996. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  48997. /**
  48998. * Renders the submesh passed in parameter to the generation map.
  48999. */
  49000. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  49001. /**
  49002. * Rebuild the required buffers.
  49003. * @hidden Internal use only.
  49004. */
  49005. _rebuild(): void;
  49006. /**
  49007. * Dispose only the render target textures and post process.
  49008. */
  49009. private _disposeTextureAndPostProcesses;
  49010. /**
  49011. * Dispose the highlight layer and free resources.
  49012. */
  49013. dispose(): void;
  49014. /**
  49015. * Gets the class name of the effect layer
  49016. * @returns the string with the class name of the effect layer
  49017. */
  49018. getClassName(): string;
  49019. /**
  49020. * Creates an effect layer from parsed effect layer data
  49021. * @param parsedEffectLayer defines effect layer data
  49022. * @param scene defines the current scene
  49023. * @param rootUrl defines the root URL containing the effect layer information
  49024. * @returns a parsed effect Layer
  49025. */
  49026. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  49027. }
  49028. }
  49029. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  49030. import { Scene } from "babylonjs/scene";
  49031. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  49032. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  49033. import { AbstractScene } from "babylonjs/abstractScene";
  49034. module "babylonjs/abstractScene" {
  49035. interface AbstractScene {
  49036. /**
  49037. * The list of effect layers (highlights/glow) added to the scene
  49038. * @see http://doc.babylonjs.com/how_to/highlight_layer
  49039. * @see http://doc.babylonjs.com/how_to/glow_layer
  49040. */
  49041. effectLayers: Array<EffectLayer>;
  49042. /**
  49043. * Removes the given effect layer from this scene.
  49044. * @param toRemove defines the effect layer to remove
  49045. * @returns the index of the removed effect layer
  49046. */
  49047. removeEffectLayer(toRemove: EffectLayer): number;
  49048. /**
  49049. * Adds the given effect layer to this scene
  49050. * @param newEffectLayer defines the effect layer to add
  49051. */
  49052. addEffectLayer(newEffectLayer: EffectLayer): void;
  49053. }
  49054. }
  49055. /**
  49056. * Defines the layer scene component responsible to manage any effect layers
  49057. * in a given scene.
  49058. */
  49059. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  49060. /**
  49061. * The component name helpfull to identify the component in the list of scene components.
  49062. */
  49063. readonly name: string;
  49064. /**
  49065. * The scene the component belongs to.
  49066. */
  49067. scene: Scene;
  49068. private _engine;
  49069. private _renderEffects;
  49070. private _needStencil;
  49071. private _previousStencilState;
  49072. /**
  49073. * Creates a new instance of the component for the given scene
  49074. * @param scene Defines the scene to register the component in
  49075. */
  49076. constructor(scene: Scene);
  49077. /**
  49078. * Registers the component in a given scene
  49079. */
  49080. register(): void;
  49081. /**
  49082. * Rebuilds the elements related to this component in case of
  49083. * context lost for instance.
  49084. */
  49085. rebuild(): void;
  49086. /**
  49087. * Serializes the component data to the specified json object
  49088. * @param serializationObject The object to serialize to
  49089. */
  49090. serialize(serializationObject: any): void;
  49091. /**
  49092. * Adds all the element from the container to the scene
  49093. * @param container the container holding the elements
  49094. */
  49095. addFromContainer(container: AbstractScene): void;
  49096. /**
  49097. * Removes all the elements in the container from the scene
  49098. * @param container contains the elements to remove
  49099. * @param dispose if the removed element should be disposed (default: false)
  49100. */
  49101. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49102. /**
  49103. * Disposes the component and the associated ressources.
  49104. */
  49105. dispose(): void;
  49106. private _isReadyForMesh;
  49107. private _renderMainTexture;
  49108. private _setStencil;
  49109. private _setStencilBack;
  49110. private _draw;
  49111. private _drawCamera;
  49112. private _drawRenderingGroup;
  49113. }
  49114. }
  49115. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  49116. /** @hidden */
  49117. export var glowMapMergePixelShader: {
  49118. name: string;
  49119. shader: string;
  49120. };
  49121. }
  49122. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  49123. /** @hidden */
  49124. export var glowMapMergeVertexShader: {
  49125. name: string;
  49126. shader: string;
  49127. };
  49128. }
  49129. declare module "babylonjs/Layers/glowLayer" {
  49130. import { Nullable } from "babylonjs/types";
  49131. import { Camera } from "babylonjs/Cameras/camera";
  49132. import { Scene } from "babylonjs/scene";
  49133. import { Color4 } from "babylonjs/Maths/math";
  49134. import { SubMesh } from "babylonjs/Meshes/subMesh";
  49135. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49136. import { Mesh } from "babylonjs/Meshes/mesh";
  49137. import { Texture } from "babylonjs/Materials/Textures/texture";
  49138. import { Effect } from "babylonjs/Materials/effect";
  49139. import { Material } from "babylonjs/Materials/material";
  49140. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  49141. import "babylonjs/Shaders/glowMapMerge.fragment";
  49142. import "babylonjs/Shaders/glowMapMerge.vertex";
  49143. import "babylonjs/Layers/effectLayerSceneComponent";
  49144. module "babylonjs/abstractScene" {
  49145. interface AbstractScene {
  49146. /**
  49147. * Return a the first highlight layer of the scene with a given name.
  49148. * @param name The name of the highlight layer to look for.
  49149. * @return The highlight layer if found otherwise null.
  49150. */
  49151. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  49152. }
  49153. }
  49154. /**
  49155. * Glow layer options. This helps customizing the behaviour
  49156. * of the glow layer.
  49157. */
  49158. export interface IGlowLayerOptions {
  49159. /**
  49160. * Multiplication factor apply to the canvas size to compute the render target size
  49161. * used to generated the glowing objects (the smaller the faster).
  49162. */
  49163. mainTextureRatio: number;
  49164. /**
  49165. * Enforces a fixed size texture to ensure resize independant blur.
  49166. */
  49167. mainTextureFixedSize?: number;
  49168. /**
  49169. * How big is the kernel of the blur texture.
  49170. */
  49171. blurKernelSize: number;
  49172. /**
  49173. * The camera attached to the layer.
  49174. */
  49175. camera: Nullable<Camera>;
  49176. /**
  49177. * Enable MSAA by chosing the number of samples.
  49178. */
  49179. mainTextureSamples?: number;
  49180. /**
  49181. * The rendering group to draw the layer in.
  49182. */
  49183. renderingGroupId: number;
  49184. }
  49185. /**
  49186. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  49187. *
  49188. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  49189. * glowy meshes to your scene.
  49190. *
  49191. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  49192. */
  49193. export class GlowLayer extends EffectLayer {
  49194. /**
  49195. * Effect Name of the layer.
  49196. */
  49197. static readonly EffectName: string;
  49198. /**
  49199. * The default blur kernel size used for the glow.
  49200. */
  49201. static DefaultBlurKernelSize: number;
  49202. /**
  49203. * The default texture size ratio used for the glow.
  49204. */
  49205. static DefaultTextureRatio: number;
  49206. /**
  49207. * Sets the kernel size of the blur.
  49208. */
  49209. /**
  49210. * Gets the kernel size of the blur.
  49211. */
  49212. blurKernelSize: number;
  49213. /**
  49214. * Sets the glow intensity.
  49215. */
  49216. /**
  49217. * Gets the glow intensity.
  49218. */
  49219. intensity: number;
  49220. private _options;
  49221. private _intensity;
  49222. private _horizontalBlurPostprocess1;
  49223. private _verticalBlurPostprocess1;
  49224. private _horizontalBlurPostprocess2;
  49225. private _verticalBlurPostprocess2;
  49226. private _blurTexture1;
  49227. private _blurTexture2;
  49228. private _postProcesses1;
  49229. private _postProcesses2;
  49230. private _includedOnlyMeshes;
  49231. private _excludedMeshes;
  49232. /**
  49233. * Callback used to let the user override the color selection on a per mesh basis
  49234. */
  49235. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  49236. /**
  49237. * Callback used to let the user override the texture selection on a per mesh basis
  49238. */
  49239. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  49240. /**
  49241. * Instantiates a new glow Layer and references it to the scene.
  49242. * @param name The name of the layer
  49243. * @param scene The scene to use the layer in
  49244. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  49245. */
  49246. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  49247. /**
  49248. * Get the effect name of the layer.
  49249. * @return The effect name
  49250. */
  49251. getEffectName(): string;
  49252. /**
  49253. * Create the merge effect. This is the shader use to blit the information back
  49254. * to the main canvas at the end of the scene rendering.
  49255. */
  49256. protected _createMergeEffect(): Effect;
  49257. /**
  49258. * Creates the render target textures and post processes used in the glow layer.
  49259. */
  49260. protected _createTextureAndPostProcesses(): void;
  49261. /**
  49262. * Checks for the readiness of the element composing the layer.
  49263. * @param subMesh the mesh to check for
  49264. * @param useInstances specify wether or not to use instances to render the mesh
  49265. * @param emissiveTexture the associated emissive texture used to generate the glow
  49266. * @return true if ready otherwise, false
  49267. */
  49268. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49269. /**
  49270. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49271. */
  49272. needStencil(): boolean;
  49273. /**
  49274. * Returns true if the mesh can be rendered, otherwise false.
  49275. * @param mesh The mesh to render
  49276. * @param material The material used on the mesh
  49277. * @returns true if it can be rendered otherwise false
  49278. */
  49279. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  49280. /**
  49281. * Implementation specific of rendering the generating effect on the main canvas.
  49282. * @param effect The effect used to render through
  49283. */
  49284. protected _internalRender(effect: Effect): void;
  49285. /**
  49286. * Sets the required values for both the emissive texture and and the main color.
  49287. */
  49288. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49289. /**
  49290. * Returns true if the mesh should render, otherwise false.
  49291. * @param mesh The mesh to render
  49292. * @returns true if it should render otherwise false
  49293. */
  49294. protected _shouldRenderMesh(mesh: Mesh): boolean;
  49295. /**
  49296. * Adds specific effects defines.
  49297. * @param defines The defines to add specifics to.
  49298. */
  49299. protected _addCustomEffectDefines(defines: string[]): void;
  49300. /**
  49301. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  49302. * @param mesh The mesh to exclude from the glow layer
  49303. */
  49304. addExcludedMesh(mesh: Mesh): void;
  49305. /**
  49306. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  49307. * @param mesh The mesh to remove
  49308. */
  49309. removeExcludedMesh(mesh: Mesh): void;
  49310. /**
  49311. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  49312. * @param mesh The mesh to include in the glow layer
  49313. */
  49314. addIncludedOnlyMesh(mesh: Mesh): void;
  49315. /**
  49316. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  49317. * @param mesh The mesh to remove
  49318. */
  49319. removeIncludedOnlyMesh(mesh: Mesh): void;
  49320. /**
  49321. * Determine if a given mesh will be used in the glow layer
  49322. * @param mesh The mesh to test
  49323. * @returns true if the mesh will be highlighted by the current glow layer
  49324. */
  49325. hasMesh(mesh: AbstractMesh): boolean;
  49326. /**
  49327. * Free any resources and references associated to a mesh.
  49328. * Internal use
  49329. * @param mesh The mesh to free.
  49330. * @hidden
  49331. */
  49332. _disposeMesh(mesh: Mesh): void;
  49333. /**
  49334. * Gets the class name of the effect layer
  49335. * @returns the string with the class name of the effect layer
  49336. */
  49337. getClassName(): string;
  49338. /**
  49339. * Serializes this glow layer
  49340. * @returns a serialized glow layer object
  49341. */
  49342. serialize(): any;
  49343. /**
  49344. * Creates a Glow Layer from parsed glow layer data
  49345. * @param parsedGlowLayer defines glow layer data
  49346. * @param scene defines the current scene
  49347. * @param rootUrl defines the root URL containing the glow layer information
  49348. * @returns a parsed Glow Layer
  49349. */
  49350. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  49351. }
  49352. }
  49353. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  49354. /** @hidden */
  49355. export var glowBlurPostProcessPixelShader: {
  49356. name: string;
  49357. shader: string;
  49358. };
  49359. }
  49360. declare module "babylonjs/Layers/highlightLayer" {
  49361. import { Observable } from "babylonjs/Misc/observable";
  49362. import { Nullable } from "babylonjs/types";
  49363. import { Camera } from "babylonjs/Cameras/camera";
  49364. import { Scene } from "babylonjs/scene";
  49365. import { Color3, Color4 } from "babylonjs/Maths/math";
  49366. import { SubMesh } from "babylonjs/Meshes/subMesh";
  49367. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49368. import { Mesh } from "babylonjs/Meshes/mesh";
  49369. import { Effect } from "babylonjs/Materials/effect";
  49370. import { Material } from "babylonjs/Materials/material";
  49371. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  49372. import "babylonjs/Shaders/glowMapMerge.fragment";
  49373. import "babylonjs/Shaders/glowMapMerge.vertex";
  49374. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  49375. module "babylonjs/abstractScene" {
  49376. interface AbstractScene {
  49377. /**
  49378. * Return a the first highlight layer of the scene with a given name.
  49379. * @param name The name of the highlight layer to look for.
  49380. * @return The highlight layer if found otherwise null.
  49381. */
  49382. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  49383. }
  49384. }
  49385. /**
  49386. * Highlight layer options. This helps customizing the behaviour
  49387. * of the highlight layer.
  49388. */
  49389. export interface IHighlightLayerOptions {
  49390. /**
  49391. * Multiplication factor apply to the canvas size to compute the render target size
  49392. * used to generated the glowing objects (the smaller the faster).
  49393. */
  49394. mainTextureRatio: number;
  49395. /**
  49396. * Enforces a fixed size texture to ensure resize independant blur.
  49397. */
  49398. mainTextureFixedSize?: number;
  49399. /**
  49400. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  49401. * of the picture to blur (the smaller the faster).
  49402. */
  49403. blurTextureSizeRatio: number;
  49404. /**
  49405. * How big in texel of the blur texture is the vertical blur.
  49406. */
  49407. blurVerticalSize: number;
  49408. /**
  49409. * How big in texel of the blur texture is the horizontal blur.
  49410. */
  49411. blurHorizontalSize: number;
  49412. /**
  49413. * Alpha blending mode used to apply the blur. Default is combine.
  49414. */
  49415. alphaBlendingMode: number;
  49416. /**
  49417. * The camera attached to the layer.
  49418. */
  49419. camera: Nullable<Camera>;
  49420. /**
  49421. * Should we display highlight as a solid stroke?
  49422. */
  49423. isStroke?: boolean;
  49424. /**
  49425. * The rendering group to draw the layer in.
  49426. */
  49427. renderingGroupId: number;
  49428. }
  49429. /**
  49430. * The highlight layer Helps adding a glow effect around a mesh.
  49431. *
  49432. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  49433. * glowy meshes to your scene.
  49434. *
  49435. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  49436. */
  49437. export class HighlightLayer extends EffectLayer {
  49438. name: string;
  49439. /**
  49440. * Effect Name of the highlight layer.
  49441. */
  49442. static readonly EffectName: string;
  49443. /**
  49444. * The neutral color used during the preparation of the glow effect.
  49445. * This is black by default as the blend operation is a blend operation.
  49446. */
  49447. static NeutralColor: Color4;
  49448. /**
  49449. * Stencil value used for glowing meshes.
  49450. */
  49451. static GlowingMeshStencilReference: number;
  49452. /**
  49453. * Stencil value used for the other meshes in the scene.
  49454. */
  49455. static NormalMeshStencilReference: number;
  49456. /**
  49457. * Specifies whether or not the inner glow is ACTIVE in the layer.
  49458. */
  49459. innerGlow: boolean;
  49460. /**
  49461. * Specifies whether or not the outer glow is ACTIVE in the layer.
  49462. */
  49463. outerGlow: boolean;
  49464. /**
  49465. * Specifies the horizontal size of the blur.
  49466. */
  49467. /**
  49468. * Gets the horizontal size of the blur.
  49469. */
  49470. blurHorizontalSize: number;
  49471. /**
  49472. * Specifies the vertical size of the blur.
  49473. */
  49474. /**
  49475. * Gets the vertical size of the blur.
  49476. */
  49477. blurVerticalSize: number;
  49478. /**
  49479. * An event triggered when the highlight layer is being blurred.
  49480. */
  49481. onBeforeBlurObservable: Observable<HighlightLayer>;
  49482. /**
  49483. * An event triggered when the highlight layer has been blurred.
  49484. */
  49485. onAfterBlurObservable: Observable<HighlightLayer>;
  49486. private _instanceGlowingMeshStencilReference;
  49487. private _options;
  49488. private _downSamplePostprocess;
  49489. private _horizontalBlurPostprocess;
  49490. private _verticalBlurPostprocess;
  49491. private _blurTexture;
  49492. private _meshes;
  49493. private _excludedMeshes;
  49494. /**
  49495. * Instantiates a new highlight Layer and references it to the scene..
  49496. * @param name The name of the layer
  49497. * @param scene The scene to use the layer in
  49498. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  49499. */
  49500. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  49501. /**
  49502. * Get the effect name of the layer.
  49503. * @return The effect name
  49504. */
  49505. getEffectName(): string;
  49506. /**
  49507. * Create the merge effect. This is the shader use to blit the information back
  49508. * to the main canvas at the end of the scene rendering.
  49509. */
  49510. protected _createMergeEffect(): Effect;
  49511. /**
  49512. * Creates the render target textures and post processes used in the highlight layer.
  49513. */
  49514. protected _createTextureAndPostProcesses(): void;
  49515. /**
  49516. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49517. */
  49518. needStencil(): boolean;
  49519. /**
  49520. * Checks for the readiness of the element composing the layer.
  49521. * @param subMesh the mesh to check for
  49522. * @param useInstances specify wether or not to use instances to render the mesh
  49523. * @param emissiveTexture the associated emissive texture used to generate the glow
  49524. * @return true if ready otherwise, false
  49525. */
  49526. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49527. /**
  49528. * Implementation specific of rendering the generating effect on the main canvas.
  49529. * @param effect The effect used to render through
  49530. */
  49531. protected _internalRender(effect: Effect): void;
  49532. /**
  49533. * Returns true if the layer contains information to display, otherwise false.
  49534. */
  49535. shouldRender(): boolean;
  49536. /**
  49537. * Returns true if the mesh should render, otherwise false.
  49538. * @param mesh The mesh to render
  49539. * @returns true if it should render otherwise false
  49540. */
  49541. protected _shouldRenderMesh(mesh: Mesh): boolean;
  49542. /**
  49543. * Sets the required values for both the emissive texture and and the main color.
  49544. */
  49545. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49546. /**
  49547. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  49548. * @param mesh The mesh to exclude from the highlight layer
  49549. */
  49550. addExcludedMesh(mesh: Mesh): void;
  49551. /**
  49552. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  49553. * @param mesh The mesh to highlight
  49554. */
  49555. removeExcludedMesh(mesh: Mesh): void;
  49556. /**
  49557. * Determine if a given mesh will be highlighted by the current HighlightLayer
  49558. * @param mesh mesh to test
  49559. * @returns true if the mesh will be highlighted by the current HighlightLayer
  49560. */
  49561. hasMesh(mesh: AbstractMesh): boolean;
  49562. /**
  49563. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  49564. * @param mesh The mesh to highlight
  49565. * @param color The color of the highlight
  49566. * @param glowEmissiveOnly Extract the glow from the emissive texture
  49567. */
  49568. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  49569. /**
  49570. * Remove a mesh from the highlight layer in order to make it stop glowing.
  49571. * @param mesh The mesh to highlight
  49572. */
  49573. removeMesh(mesh: Mesh): void;
  49574. /**
  49575. * Force the stencil to the normal expected value for none glowing parts
  49576. */
  49577. private _defaultStencilReference;
  49578. /**
  49579. * Free any resources and references associated to a mesh.
  49580. * Internal use
  49581. * @param mesh The mesh to free.
  49582. * @hidden
  49583. */
  49584. _disposeMesh(mesh: Mesh): void;
  49585. /**
  49586. * Dispose the highlight layer and free resources.
  49587. */
  49588. dispose(): void;
  49589. /**
  49590. * Gets the class name of the effect layer
  49591. * @returns the string with the class name of the effect layer
  49592. */
  49593. getClassName(): string;
  49594. /**
  49595. * Serializes this Highlight layer
  49596. * @returns a serialized Highlight layer object
  49597. */
  49598. serialize(): any;
  49599. /**
  49600. * Creates a Highlight layer from parsed Highlight layer data
  49601. * @param parsedHightlightLayer defines the Highlight layer data
  49602. * @param scene defines the current scene
  49603. * @param rootUrl defines the root URL containing the Highlight layer information
  49604. * @returns a parsed Highlight layer
  49605. */
  49606. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  49607. }
  49608. }
  49609. declare module "babylonjs/Layers/index" {
  49610. export * from "babylonjs/Layers/effectLayer";
  49611. export * from "babylonjs/Layers/effectLayerSceneComponent";
  49612. export * from "babylonjs/Layers/glowLayer";
  49613. export * from "babylonjs/Layers/highlightLayer";
  49614. export * from "babylonjs/Layers/layer";
  49615. export * from "babylonjs/Layers/layerSceneComponent";
  49616. }
  49617. declare module "babylonjs/Shaders/lensFlare.fragment" {
  49618. /** @hidden */
  49619. export var lensFlarePixelShader: {
  49620. name: string;
  49621. shader: string;
  49622. };
  49623. }
  49624. declare module "babylonjs/Shaders/lensFlare.vertex" {
  49625. /** @hidden */
  49626. export var lensFlareVertexShader: {
  49627. name: string;
  49628. shader: string;
  49629. };
  49630. }
  49631. declare module "babylonjs/LensFlares/lensFlareSystem" {
  49632. import { Scene } from "babylonjs/scene";
  49633. import { Vector3, Viewport } from "babylonjs/Maths/math";
  49634. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49635. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  49636. import "babylonjs/Shaders/lensFlare.fragment";
  49637. import "babylonjs/Shaders/lensFlare.vertex";
  49638. /**
  49639. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  49640. * It is usually composed of several `lensFlare`.
  49641. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49642. */
  49643. export class LensFlareSystem {
  49644. /**
  49645. * Define the name of the lens flare system
  49646. */
  49647. name: string;
  49648. /**
  49649. * List of lens flares used in this system.
  49650. */
  49651. lensFlares: LensFlare[];
  49652. /**
  49653. * Define a limit from the border the lens flare can be visible.
  49654. */
  49655. borderLimit: number;
  49656. /**
  49657. * Define a viewport border we do not want to see the lens flare in.
  49658. */
  49659. viewportBorder: number;
  49660. /**
  49661. * Define a predicate which could limit the list of meshes able to occlude the effect.
  49662. */
  49663. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  49664. /**
  49665. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  49666. */
  49667. layerMask: number;
  49668. /**
  49669. * Define the id of the lens flare system in the scene.
  49670. * (equal to name by default)
  49671. */
  49672. id: string;
  49673. private _scene;
  49674. private _emitter;
  49675. private _vertexBuffers;
  49676. private _indexBuffer;
  49677. private _effect;
  49678. private _positionX;
  49679. private _positionY;
  49680. private _isEnabled;
  49681. /** @hidden */
  49682. static _SceneComponentInitialization: (scene: Scene) => void;
  49683. /**
  49684. * Instantiates a lens flare system.
  49685. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  49686. * It is usually composed of several `lensFlare`.
  49687. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49688. * @param name Define the name of the lens flare system in the scene
  49689. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  49690. * @param scene Define the scene the lens flare system belongs to
  49691. */
  49692. constructor(
  49693. /**
  49694. * Define the name of the lens flare system
  49695. */
  49696. name: string, emitter: any, scene: Scene);
  49697. /**
  49698. * Define if the lens flare system is enabled.
  49699. */
  49700. isEnabled: boolean;
  49701. /**
  49702. * Get the scene the effects belongs to.
  49703. * @returns the scene holding the lens flare system
  49704. */
  49705. getScene(): Scene;
  49706. /**
  49707. * Get the emitter of the lens flare system.
  49708. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  49709. * @returns the emitter of the lens flare system
  49710. */
  49711. getEmitter(): any;
  49712. /**
  49713. * Set the emitter of the lens flare system.
  49714. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  49715. * @param newEmitter Define the new emitter of the system
  49716. */
  49717. setEmitter(newEmitter: any): void;
  49718. /**
  49719. * Get the lens flare system emitter position.
  49720. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  49721. * @returns the position
  49722. */
  49723. getEmitterPosition(): Vector3;
  49724. /**
  49725. * @hidden
  49726. */
  49727. computeEffectivePosition(globalViewport: Viewport): boolean;
  49728. /** @hidden */
  49729. _isVisible(): boolean;
  49730. /**
  49731. * @hidden
  49732. */
  49733. render(): boolean;
  49734. /**
  49735. * Dispose and release the lens flare with its associated resources.
  49736. */
  49737. dispose(): void;
  49738. /**
  49739. * Parse a lens flare system from a JSON repressentation
  49740. * @param parsedLensFlareSystem Define the JSON to parse
  49741. * @param scene Define the scene the parsed system should be instantiated in
  49742. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  49743. * @returns the parsed system
  49744. */
  49745. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  49746. /**
  49747. * Serialize the current Lens Flare System into a JSON representation.
  49748. * @returns the serialized JSON
  49749. */
  49750. serialize(): any;
  49751. }
  49752. }
  49753. declare module "babylonjs/LensFlares/lensFlare" {
  49754. import { Nullable } from "babylonjs/types";
  49755. import { Color3 } from "babylonjs/Maths/math";
  49756. import { Texture } from "babylonjs/Materials/Textures/texture";
  49757. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  49758. /**
  49759. * This represents one of the lens effect in a `lensFlareSystem`.
  49760. * It controls one of the indiviual texture used in the effect.
  49761. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49762. */
  49763. export class LensFlare {
  49764. /**
  49765. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  49766. */
  49767. size: number;
  49768. /**
  49769. * 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.
  49770. */
  49771. position: number;
  49772. /**
  49773. * Define the lens color.
  49774. */
  49775. color: Color3;
  49776. /**
  49777. * Define the lens texture.
  49778. */
  49779. texture: Nullable<Texture>;
  49780. /**
  49781. * Define the alpha mode to render this particular lens.
  49782. */
  49783. alphaMode: number;
  49784. private _system;
  49785. /**
  49786. * Creates a new Lens Flare.
  49787. * This represents one of the lens effect in a `lensFlareSystem`.
  49788. * It controls one of the indiviual texture used in the effect.
  49789. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49790. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  49791. * @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.
  49792. * @param color Define the lens color
  49793. * @param imgUrl Define the lens texture url
  49794. * @param system Define the `lensFlareSystem` this flare is part of
  49795. * @returns The newly created Lens Flare
  49796. */
  49797. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  49798. /**
  49799. * Instantiates a new Lens Flare.
  49800. * This represents one of the lens effect in a `lensFlareSystem`.
  49801. * It controls one of the indiviual texture used in the effect.
  49802. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49803. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  49804. * @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.
  49805. * @param color Define the lens color
  49806. * @param imgUrl Define the lens texture url
  49807. * @param system Define the `lensFlareSystem` this flare is part of
  49808. */
  49809. constructor(
  49810. /**
  49811. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  49812. */
  49813. size: number,
  49814. /**
  49815. * 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.
  49816. */
  49817. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  49818. /**
  49819. * Dispose and release the lens flare with its associated resources.
  49820. */
  49821. dispose(): void;
  49822. }
  49823. }
  49824. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  49825. import { Nullable } from "babylonjs/types";
  49826. import { Scene } from "babylonjs/scene";
  49827. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  49828. import { AbstractScene } from "babylonjs/abstractScene";
  49829. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  49830. module "babylonjs/abstractScene" {
  49831. interface AbstractScene {
  49832. /**
  49833. * The list of lens flare system added to the scene
  49834. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49835. */
  49836. lensFlareSystems: Array<LensFlareSystem>;
  49837. /**
  49838. * Removes the given lens flare system from this scene.
  49839. * @param toRemove The lens flare system to remove
  49840. * @returns The index of the removed lens flare system
  49841. */
  49842. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  49843. /**
  49844. * Adds the given lens flare system to this scene
  49845. * @param newLensFlareSystem The lens flare system to add
  49846. */
  49847. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  49848. /**
  49849. * Gets a lens flare system using its name
  49850. * @param name defines the name to look for
  49851. * @returns the lens flare system or null if not found
  49852. */
  49853. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  49854. /**
  49855. * Gets a lens flare system using its id
  49856. * @param id defines the id to look for
  49857. * @returns the lens flare system or null if not found
  49858. */
  49859. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  49860. }
  49861. }
  49862. /**
  49863. * Defines the lens flare scene component responsible to manage any lens flares
  49864. * in a given scene.
  49865. */
  49866. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  49867. /**
  49868. * The component name helpfull to identify the component in the list of scene components.
  49869. */
  49870. readonly name: string;
  49871. /**
  49872. * The scene the component belongs to.
  49873. */
  49874. scene: Scene;
  49875. /**
  49876. * Creates a new instance of the component for the given scene
  49877. * @param scene Defines the scene to register the component in
  49878. */
  49879. constructor(scene: Scene);
  49880. /**
  49881. * Registers the component in a given scene
  49882. */
  49883. register(): void;
  49884. /**
  49885. * Rebuilds the elements related to this component in case of
  49886. * context lost for instance.
  49887. */
  49888. rebuild(): void;
  49889. /**
  49890. * Adds all the element from the container to the scene
  49891. * @param container the container holding the elements
  49892. */
  49893. addFromContainer(container: AbstractScene): void;
  49894. /**
  49895. * Removes all the elements in the container from the scene
  49896. * @param container contains the elements to remove
  49897. * @param dispose if the removed element should be disposed (default: false)
  49898. */
  49899. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49900. /**
  49901. * Serializes the component data to the specified json object
  49902. * @param serializationObject The object to serialize to
  49903. */
  49904. serialize(serializationObject: any): void;
  49905. /**
  49906. * Disposes the component and the associated ressources.
  49907. */
  49908. dispose(): void;
  49909. private _draw;
  49910. }
  49911. }
  49912. declare module "babylonjs/LensFlares/index" {
  49913. export * from "babylonjs/LensFlares/lensFlare";
  49914. export * from "babylonjs/LensFlares/lensFlareSystem";
  49915. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  49916. }
  49917. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  49918. import { Scene } from "babylonjs/scene";
  49919. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  49920. import { AbstractScene } from "babylonjs/abstractScene";
  49921. /**
  49922. * Defines the shadow generator component responsible to manage any shadow generators
  49923. * in a given scene.
  49924. */
  49925. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  49926. /**
  49927. * The component name helpfull to identify the component in the list of scene components.
  49928. */
  49929. readonly name: string;
  49930. /**
  49931. * The scene the component belongs to.
  49932. */
  49933. scene: Scene;
  49934. /**
  49935. * Creates a new instance of the component for the given scene
  49936. * @param scene Defines the scene to register the component in
  49937. */
  49938. constructor(scene: Scene);
  49939. /**
  49940. * Registers the component in a given scene
  49941. */
  49942. register(): void;
  49943. /**
  49944. * Rebuilds the elements related to this component in case of
  49945. * context lost for instance.
  49946. */
  49947. rebuild(): void;
  49948. /**
  49949. * Serializes the component data to the specified json object
  49950. * @param serializationObject The object to serialize to
  49951. */
  49952. serialize(serializationObject: any): void;
  49953. /**
  49954. * Adds all the element from the container to the scene
  49955. * @param container the container holding the elements
  49956. */
  49957. addFromContainer(container: AbstractScene): void;
  49958. /**
  49959. * Removes all the elements in the container from the scene
  49960. * @param container contains the elements to remove
  49961. * @param dispose if the removed element should be disposed (default: false)
  49962. */
  49963. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49964. /**
  49965. * Rebuilds the elements related to this component in case of
  49966. * context lost for instance.
  49967. */
  49968. dispose(): void;
  49969. private _gatherRenderTargets;
  49970. }
  49971. }
  49972. declare module "babylonjs/Lights/Shadows/index" {
  49973. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  49974. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  49975. }
  49976. declare module "babylonjs/Lights/pointLight" {
  49977. import { Scene } from "babylonjs/scene";
  49978. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  49979. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49980. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  49981. import { Effect } from "babylonjs/Materials/effect";
  49982. /**
  49983. * A point light is a light defined by an unique point in world space.
  49984. * The light is emitted in every direction from this point.
  49985. * A good example of a point light is a standard light bulb.
  49986. * Documentation: https://doc.babylonjs.com/babylon101/lights
  49987. */
  49988. export class PointLight extends ShadowLight {
  49989. private _shadowAngle;
  49990. /**
  49991. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49992. * This specifies what angle the shadow will use to be created.
  49993. *
  49994. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  49995. */
  49996. /**
  49997. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49998. * This specifies what angle the shadow will use to be created.
  49999. *
  50000. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  50001. */
  50002. shadowAngle: number;
  50003. /**
  50004. * Gets the direction if it has been set.
  50005. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50006. */
  50007. /**
  50008. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50009. */
  50010. direction: Vector3;
  50011. /**
  50012. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  50013. * A PointLight emits the light in every direction.
  50014. * It can cast shadows.
  50015. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  50016. * ```javascript
  50017. * var pointLight = new PointLight("pl", camera.position, scene);
  50018. * ```
  50019. * Documentation : https://doc.babylonjs.com/babylon101/lights
  50020. * @param name The light friendly name
  50021. * @param position The position of the point light in the scene
  50022. * @param scene The scene the lights belongs to
  50023. */
  50024. constructor(name: string, position: Vector3, scene: Scene);
  50025. /**
  50026. * Returns the string "PointLight"
  50027. * @returns the class name
  50028. */
  50029. getClassName(): string;
  50030. /**
  50031. * Returns the integer 0.
  50032. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  50033. */
  50034. getTypeID(): number;
  50035. /**
  50036. * Specifies wether or not the shadowmap should be a cube texture.
  50037. * @returns true if the shadowmap needs to be a cube texture.
  50038. */
  50039. needCube(): boolean;
  50040. /**
  50041. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  50042. * @param faceIndex The index of the face we are computed the direction to generate shadow
  50043. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  50044. */
  50045. getShadowDirection(faceIndex?: number): Vector3;
  50046. /**
  50047. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  50048. * - fov = PI / 2
  50049. * - aspect ratio : 1.0
  50050. * - z-near and far equal to the active camera minZ and maxZ.
  50051. * Returns the PointLight.
  50052. */
  50053. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50054. protected _buildUniformLayout(): void;
  50055. /**
  50056. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  50057. * @param effect The effect to update
  50058. * @param lightIndex The index of the light in the effect to update
  50059. * @returns The point light
  50060. */
  50061. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  50062. /**
  50063. * Prepares the list of defines specific to the light type.
  50064. * @param defines the list of defines
  50065. * @param lightIndex defines the index of the light for the effect
  50066. */
  50067. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  50068. }
  50069. }
  50070. declare module "babylonjs/Lights/index" {
  50071. export * from "babylonjs/Lights/light";
  50072. export * from "babylonjs/Lights/shadowLight";
  50073. export * from "babylonjs/Lights/Shadows/index";
  50074. export * from "babylonjs/Lights/directionalLight";
  50075. export * from "babylonjs/Lights/hemisphericLight";
  50076. export * from "babylonjs/Lights/pointLight";
  50077. export * from "babylonjs/Lights/spotLight";
  50078. }
  50079. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  50080. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  50081. /**
  50082. * Header information of HDR texture files.
  50083. */
  50084. export interface HDRInfo {
  50085. /**
  50086. * The height of the texture in pixels.
  50087. */
  50088. height: number;
  50089. /**
  50090. * The width of the texture in pixels.
  50091. */
  50092. width: number;
  50093. /**
  50094. * The index of the beginning of the data in the binary file.
  50095. */
  50096. dataPosition: number;
  50097. }
  50098. /**
  50099. * This groups tools to convert HDR texture to native colors array.
  50100. */
  50101. export class HDRTools {
  50102. private static Ldexp;
  50103. private static Rgbe2float;
  50104. private static readStringLine;
  50105. /**
  50106. * Reads header information from an RGBE texture stored in a native array.
  50107. * More information on this format are available here:
  50108. * https://en.wikipedia.org/wiki/RGBE_image_format
  50109. *
  50110. * @param uint8array The binary file stored in native array.
  50111. * @return The header information.
  50112. */
  50113. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  50114. /**
  50115. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  50116. * This RGBE texture needs to store the information as a panorama.
  50117. *
  50118. * More information on this format are available here:
  50119. * https://en.wikipedia.org/wiki/RGBE_image_format
  50120. *
  50121. * @param buffer The binary file stored in an array buffer.
  50122. * @param size The expected size of the extracted cubemap.
  50123. * @return The Cube Map information.
  50124. */
  50125. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  50126. /**
  50127. * Returns the pixels data extracted from an RGBE texture.
  50128. * This pixels will be stored left to right up to down in the R G B order in one array.
  50129. *
  50130. * More information on this format are available here:
  50131. * https://en.wikipedia.org/wiki/RGBE_image_format
  50132. *
  50133. * @param uint8array The binary file stored in an array buffer.
  50134. * @param hdrInfo The header information of the file.
  50135. * @return The pixels data in RGB right to left up to down order.
  50136. */
  50137. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  50138. private static RGBE_ReadPixels_RLE;
  50139. }
  50140. }
  50141. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  50142. import { Nullable } from "babylonjs/types";
  50143. import { Scene } from "babylonjs/scene";
  50144. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  50145. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50146. import "babylonjs/Engines/Extensions/engine.rawTexture";
  50147. /**
  50148. * This represents a texture coming from an HDR input.
  50149. *
  50150. * The only supported format is currently panorama picture stored in RGBE format.
  50151. * Example of such files can be found on HDRLib: http://hdrlib.com/
  50152. */
  50153. export class HDRCubeTexture extends BaseTexture {
  50154. private static _facesMapping;
  50155. private _generateHarmonics;
  50156. private _noMipmap;
  50157. private _textureMatrix;
  50158. private _size;
  50159. private _onLoad;
  50160. private _onError;
  50161. /**
  50162. * The texture URL.
  50163. */
  50164. url: string;
  50165. /**
  50166. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  50167. */
  50168. coordinatesMode: number;
  50169. protected _isBlocking: boolean;
  50170. /**
  50171. * Sets wether or not the texture is blocking during loading.
  50172. */
  50173. /**
  50174. * Gets wether or not the texture is blocking during loading.
  50175. */
  50176. isBlocking: boolean;
  50177. protected _rotationY: number;
  50178. /**
  50179. * Sets texture matrix rotation angle around Y axis in radians.
  50180. */
  50181. /**
  50182. * Gets texture matrix rotation angle around Y axis radians.
  50183. */
  50184. rotationY: number;
  50185. /**
  50186. * Gets or sets the center of the bounding box associated with the cube texture
  50187. * It must define where the camera used to render the texture was set
  50188. */
  50189. boundingBoxPosition: Vector3;
  50190. private _boundingBoxSize;
  50191. /**
  50192. * Gets or sets the size of the bounding box associated with the cube texture
  50193. * When defined, the cubemap will switch to local mode
  50194. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  50195. * @example https://www.babylonjs-playground.com/#RNASML
  50196. */
  50197. boundingBoxSize: Vector3;
  50198. /**
  50199. * Instantiates an HDRTexture from the following parameters.
  50200. *
  50201. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  50202. * @param scene The scene the texture will be used in
  50203. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  50204. * @param noMipmap Forces to not generate the mipmap if true
  50205. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  50206. * @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)
  50207. * @param reserved Reserved flag for internal use.
  50208. */
  50209. 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>);
  50210. /**
  50211. * Get the current class name of the texture useful for serialization or dynamic coding.
  50212. * @returns "HDRCubeTexture"
  50213. */
  50214. getClassName(): string;
  50215. /**
  50216. * Occurs when the file is raw .hdr file.
  50217. */
  50218. private loadTexture;
  50219. clone(): HDRCubeTexture;
  50220. delayLoad(): void;
  50221. /**
  50222. * Get the texture reflection matrix used to rotate/transform the reflection.
  50223. * @returns the reflection matrix
  50224. */
  50225. getReflectionTextureMatrix(): Matrix;
  50226. /**
  50227. * Set the texture reflection matrix used to rotate/transform the reflection.
  50228. * @param value Define the reflection matrix to set
  50229. */
  50230. setReflectionTextureMatrix(value: Matrix): void;
  50231. /**
  50232. * Parses a JSON representation of an HDR Texture in order to create the texture
  50233. * @param parsedTexture Define the JSON representation
  50234. * @param scene Define the scene the texture should be created in
  50235. * @param rootUrl Define the root url in case we need to load relative dependencies
  50236. * @returns the newly created texture after parsing
  50237. */
  50238. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  50239. serialize(): any;
  50240. }
  50241. }
  50242. declare module "babylonjs/Physics/physicsEngine" {
  50243. import { Nullable } from "babylonjs/types";
  50244. import { Vector3 } from "babylonjs/Maths/math";
  50245. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  50246. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  50247. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  50248. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  50249. /**
  50250. * Class used to control physics engine
  50251. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  50252. */
  50253. export class PhysicsEngine implements IPhysicsEngine {
  50254. private _physicsPlugin;
  50255. /**
  50256. * Global value used to control the smallest number supported by the simulation
  50257. */
  50258. static Epsilon: number;
  50259. private _impostors;
  50260. private _joints;
  50261. /**
  50262. * Gets the gravity vector used by the simulation
  50263. */
  50264. gravity: Vector3;
  50265. /**
  50266. * Factory used to create the default physics plugin.
  50267. * @returns The default physics plugin
  50268. */
  50269. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  50270. /**
  50271. * Creates a new Physics Engine
  50272. * @param gravity defines the gravity vector used by the simulation
  50273. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  50274. */
  50275. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  50276. /**
  50277. * Sets the gravity vector used by the simulation
  50278. * @param gravity defines the gravity vector to use
  50279. */
  50280. setGravity(gravity: Vector3): void;
  50281. /**
  50282. * Set the time step of the physics engine.
  50283. * Default is 1/60.
  50284. * To slow it down, enter 1/600 for example.
  50285. * To speed it up, 1/30
  50286. * @param newTimeStep defines the new timestep to apply to this world.
  50287. */
  50288. setTimeStep(newTimeStep?: number): void;
  50289. /**
  50290. * Get the time step of the physics engine.
  50291. * @returns the current time step
  50292. */
  50293. getTimeStep(): number;
  50294. /**
  50295. * Release all resources
  50296. */
  50297. dispose(): void;
  50298. /**
  50299. * Gets the name of the current physics plugin
  50300. * @returns the name of the plugin
  50301. */
  50302. getPhysicsPluginName(): string;
  50303. /**
  50304. * Adding a new impostor for the impostor tracking.
  50305. * This will be done by the impostor itself.
  50306. * @param impostor the impostor to add
  50307. */
  50308. addImpostor(impostor: PhysicsImpostor): void;
  50309. /**
  50310. * Remove an impostor from the engine.
  50311. * This impostor and its mesh will not longer be updated by the physics engine.
  50312. * @param impostor the impostor to remove
  50313. */
  50314. removeImpostor(impostor: PhysicsImpostor): void;
  50315. /**
  50316. * Add a joint to the physics engine
  50317. * @param mainImpostor defines the main impostor to which the joint is added.
  50318. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  50319. * @param joint defines the joint that will connect both impostors.
  50320. */
  50321. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  50322. /**
  50323. * Removes a joint from the simulation
  50324. * @param mainImpostor defines the impostor used with the joint
  50325. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  50326. * @param joint defines the joint to remove
  50327. */
  50328. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  50329. /**
  50330. * Called by the scene. No need to call it.
  50331. * @param delta defines the timespam between frames
  50332. */
  50333. _step(delta: number): void;
  50334. /**
  50335. * Gets the current plugin used to run the simulation
  50336. * @returns current plugin
  50337. */
  50338. getPhysicsPlugin(): IPhysicsEnginePlugin;
  50339. /**
  50340. * Gets the list of physic impostors
  50341. * @returns an array of PhysicsImpostor
  50342. */
  50343. getImpostors(): Array<PhysicsImpostor>;
  50344. /**
  50345. * Gets the impostor for a physics enabled object
  50346. * @param object defines the object impersonated by the impostor
  50347. * @returns the PhysicsImpostor or null if not found
  50348. */
  50349. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  50350. /**
  50351. * Gets the impostor for a physics body object
  50352. * @param body defines physics body used by the impostor
  50353. * @returns the PhysicsImpostor or null if not found
  50354. */
  50355. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  50356. /**
  50357. * Does a raycast in the physics world
  50358. * @param from when should the ray start?
  50359. * @param to when should the ray end?
  50360. * @returns PhysicsRaycastResult
  50361. */
  50362. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50363. }
  50364. }
  50365. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  50366. import { Nullable } from "babylonjs/types";
  50367. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  50368. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50369. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  50370. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  50371. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  50372. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  50373. /** @hidden */
  50374. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  50375. private _useDeltaForWorldStep;
  50376. world: any;
  50377. name: string;
  50378. private _physicsMaterials;
  50379. private _fixedTimeStep;
  50380. private _cannonRaycastResult;
  50381. private _raycastResult;
  50382. private _removeAfterStep;
  50383. BJSCANNON: any;
  50384. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  50385. setGravity(gravity: Vector3): void;
  50386. setTimeStep(timeStep: number): void;
  50387. getTimeStep(): number;
  50388. executeStep(delta: number): void;
  50389. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50390. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50391. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50392. private _processChildMeshes;
  50393. removePhysicsBody(impostor: PhysicsImpostor): void;
  50394. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50395. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50396. private _addMaterial;
  50397. private _checkWithEpsilon;
  50398. private _createShape;
  50399. private _createHeightmap;
  50400. private _minus90X;
  50401. private _plus90X;
  50402. private _tmpPosition;
  50403. private _tmpDeltaPosition;
  50404. private _tmpUnityRotation;
  50405. private _updatePhysicsBodyTransformation;
  50406. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50407. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50408. isSupported(): boolean;
  50409. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50410. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50411. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50412. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50413. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50414. getBodyMass(impostor: PhysicsImpostor): number;
  50415. getBodyFriction(impostor: PhysicsImpostor): number;
  50416. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50417. getBodyRestitution(impostor: PhysicsImpostor): number;
  50418. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50419. sleepBody(impostor: PhysicsImpostor): void;
  50420. wakeUpBody(impostor: PhysicsImpostor): void;
  50421. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  50422. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  50423. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  50424. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50425. getRadius(impostor: PhysicsImpostor): number;
  50426. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50427. dispose(): void;
  50428. private _extendNamespace;
  50429. /**
  50430. * Does a raycast in the physics world
  50431. * @param from when should the ray start?
  50432. * @param to when should the ray end?
  50433. * @returns PhysicsRaycastResult
  50434. */
  50435. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50436. }
  50437. }
  50438. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  50439. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  50440. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  50441. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  50442. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50443. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  50444. import { Nullable } from "babylonjs/types";
  50445. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  50446. /** @hidden */
  50447. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  50448. world: any;
  50449. name: string;
  50450. BJSOIMO: any;
  50451. private _raycastResult;
  50452. constructor(iterations?: number, oimoInjection?: any);
  50453. setGravity(gravity: Vector3): void;
  50454. setTimeStep(timeStep: number): void;
  50455. getTimeStep(): number;
  50456. private _tmpImpostorsArray;
  50457. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  50458. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50459. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50460. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50461. private _tmpPositionVector;
  50462. removePhysicsBody(impostor: PhysicsImpostor): void;
  50463. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50464. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50465. isSupported(): boolean;
  50466. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50467. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50468. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50469. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50470. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50471. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50472. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50473. getBodyMass(impostor: PhysicsImpostor): number;
  50474. getBodyFriction(impostor: PhysicsImpostor): number;
  50475. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50476. getBodyRestitution(impostor: PhysicsImpostor): number;
  50477. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50478. sleepBody(impostor: PhysicsImpostor): void;
  50479. wakeUpBody(impostor: PhysicsImpostor): void;
  50480. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  50481. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  50482. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  50483. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50484. getRadius(impostor: PhysicsImpostor): number;
  50485. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50486. dispose(): void;
  50487. /**
  50488. * Does a raycast in the physics world
  50489. * @param from when should the ray start?
  50490. * @param to when should the ray end?
  50491. * @returns PhysicsRaycastResult
  50492. */
  50493. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50494. }
  50495. }
  50496. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  50497. import { Nullable } from "babylonjs/types";
  50498. import { Scene } from "babylonjs/scene";
  50499. import { Vector3, Vector2, Color4, Vector4 } from "babylonjs/Maths/math";
  50500. import { Mesh } from "babylonjs/Meshes/mesh";
  50501. /**
  50502. * Class containing static functions to help procedurally build meshes
  50503. */
  50504. export class RibbonBuilder {
  50505. /**
  50506. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50507. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  50508. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  50509. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  50510. * * 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
  50511. * * 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
  50512. * * 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
  50513. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50514. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50515. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50516. * * 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
  50517. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  50518. * * 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
  50519. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  50520. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50521. * @param name defines the name of the mesh
  50522. * @param options defines the options used to create the mesh
  50523. * @param scene defines the hosting scene
  50524. * @returns the ribbon mesh
  50525. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  50526. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50527. */
  50528. static CreateRibbon(name: string, options: {
  50529. pathArray: Vector3[][];
  50530. closeArray?: boolean;
  50531. closePath?: boolean;
  50532. offset?: number;
  50533. updatable?: boolean;
  50534. sideOrientation?: number;
  50535. frontUVs?: Vector4;
  50536. backUVs?: Vector4;
  50537. instance?: Mesh;
  50538. invertUV?: boolean;
  50539. uvs?: Vector2[];
  50540. colors?: Color4[];
  50541. }, scene?: Nullable<Scene>): Mesh;
  50542. }
  50543. }
  50544. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  50545. import { Nullable } from "babylonjs/types";
  50546. import { Scene } from "babylonjs/scene";
  50547. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  50548. import { Mesh } from "babylonjs/Meshes/mesh";
  50549. /**
  50550. * Class containing static functions to help procedurally build meshes
  50551. */
  50552. export class ShapeBuilder {
  50553. /**
  50554. * 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.
  50555. * * 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.
  50556. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50557. * * 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.
  50558. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  50559. * * 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
  50560. * * 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
  50561. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  50562. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50563. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50564. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  50565. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50566. * @param name defines the name of the mesh
  50567. * @param options defines the options used to create the mesh
  50568. * @param scene defines the hosting scene
  50569. * @returns the extruded shape mesh
  50570. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50571. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50572. */
  50573. static ExtrudeShape(name: string, options: {
  50574. shape: Vector3[];
  50575. path: Vector3[];
  50576. scale?: number;
  50577. rotation?: number;
  50578. cap?: number;
  50579. updatable?: boolean;
  50580. sideOrientation?: number;
  50581. frontUVs?: Vector4;
  50582. backUVs?: Vector4;
  50583. instance?: Mesh;
  50584. invertUV?: boolean;
  50585. }, scene?: Nullable<Scene>): Mesh;
  50586. /**
  50587. * Creates an custom extruded shape mesh.
  50588. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  50589. * * 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.
  50590. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50591. * * 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
  50592. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  50593. * * 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
  50594. * * It must returns a float value that will be the scale value applied to the shape on each path point
  50595. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  50596. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  50597. * * 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
  50598. * * 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
  50599. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  50600. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50601. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50602. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50603. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50604. * @param name defines the name of the mesh
  50605. * @param options defines the options used to create the mesh
  50606. * @param scene defines the hosting scene
  50607. * @returns the custom extruded shape mesh
  50608. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  50609. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50610. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50611. */
  50612. static ExtrudeShapeCustom(name: string, options: {
  50613. shape: Vector3[];
  50614. path: Vector3[];
  50615. scaleFunction?: any;
  50616. rotationFunction?: any;
  50617. ribbonCloseArray?: boolean;
  50618. ribbonClosePath?: boolean;
  50619. cap?: number;
  50620. updatable?: boolean;
  50621. sideOrientation?: number;
  50622. frontUVs?: Vector4;
  50623. backUVs?: Vector4;
  50624. instance?: Mesh;
  50625. invertUV?: boolean;
  50626. }, scene?: Nullable<Scene>): Mesh;
  50627. private static _ExtrudeShapeGeneric;
  50628. }
  50629. }
  50630. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  50631. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  50632. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  50633. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  50634. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  50635. import { Nullable } from "babylonjs/types";
  50636. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50637. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  50638. /**
  50639. * AmmoJS Physics plugin
  50640. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50641. * @see https://github.com/kripken/ammo.js/
  50642. */
  50643. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  50644. private _useDeltaForWorldStep;
  50645. /**
  50646. * Reference to the Ammo library
  50647. */
  50648. bjsAMMO: any;
  50649. /**
  50650. * Created ammoJS world which physics bodies are added to
  50651. */
  50652. world: any;
  50653. /**
  50654. * Name of the plugin
  50655. */
  50656. name: string;
  50657. private _timeStep;
  50658. private _fixedTimeStep;
  50659. private _maxSteps;
  50660. private _tmpQuaternion;
  50661. private _tmpAmmoTransform;
  50662. private _tmpAmmoQuaternion;
  50663. private _tmpAmmoConcreteContactResultCallback;
  50664. private _collisionConfiguration;
  50665. private _dispatcher;
  50666. private _overlappingPairCache;
  50667. private _solver;
  50668. private _softBodySolver;
  50669. private _tmpAmmoVectorA;
  50670. private _tmpAmmoVectorB;
  50671. private _tmpAmmoVectorC;
  50672. private _tmpAmmoVectorD;
  50673. private _tmpContactCallbackResult;
  50674. private _tmpAmmoVectorRCA;
  50675. private _tmpAmmoVectorRCB;
  50676. private _raycastResult;
  50677. private static readonly DISABLE_COLLISION_FLAG;
  50678. private static readonly KINEMATIC_FLAG;
  50679. private static readonly DISABLE_DEACTIVATION_FLAG;
  50680. /**
  50681. * Initializes the ammoJS plugin
  50682. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  50683. * @param ammoInjection can be used to inject your own ammo reference
  50684. */
  50685. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  50686. /**
  50687. * Sets the gravity of the physics world (m/(s^2))
  50688. * @param gravity Gravity to set
  50689. */
  50690. setGravity(gravity: Vector3): void;
  50691. /**
  50692. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  50693. * @param timeStep timestep to use in seconds
  50694. */
  50695. setTimeStep(timeStep: number): void;
  50696. /**
  50697. * 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)
  50698. * @param fixedTimeStep fixedTimeStep to use in seconds
  50699. */
  50700. setFixedTimeStep(fixedTimeStep: number): void;
  50701. /**
  50702. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  50703. * @param maxSteps the maximum number of steps by the physics engine per frame
  50704. */
  50705. setMaxSteps(maxSteps: number): void;
  50706. /**
  50707. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  50708. * @returns the current timestep in seconds
  50709. */
  50710. getTimeStep(): number;
  50711. private _isImpostorInContact;
  50712. private _isImpostorPairInContact;
  50713. private _stepSimulation;
  50714. /**
  50715. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  50716. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  50717. * After the step the babylon meshes are set to the position of the physics imposters
  50718. * @param delta amount of time to step forward
  50719. * @param impostors array of imposters to update before/after the step
  50720. */
  50721. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  50722. /**
  50723. * Update babylon mesh to match physics world object
  50724. * @param impostor imposter to match
  50725. */
  50726. private _afterSoftStep;
  50727. /**
  50728. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  50729. * @param impostor imposter to match
  50730. */
  50731. private _ropeStep;
  50732. /**
  50733. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  50734. * @param impostor imposter to match
  50735. */
  50736. private _softbodyOrClothStep;
  50737. private _tmpVector;
  50738. private _tmpMatrix;
  50739. /**
  50740. * Applies an impulse on the imposter
  50741. * @param impostor imposter to apply impulse to
  50742. * @param force amount of force to be applied to the imposter
  50743. * @param contactPoint the location to apply the impulse on the imposter
  50744. */
  50745. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50746. /**
  50747. * Applies a force on the imposter
  50748. * @param impostor imposter to apply force
  50749. * @param force amount of force to be applied to the imposter
  50750. * @param contactPoint the location to apply the force on the imposter
  50751. */
  50752. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50753. /**
  50754. * Creates a physics body using the plugin
  50755. * @param impostor the imposter to create the physics body on
  50756. */
  50757. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50758. /**
  50759. * Removes the physics body from the imposter and disposes of the body's memory
  50760. * @param impostor imposter to remove the physics body from
  50761. */
  50762. removePhysicsBody(impostor: PhysicsImpostor): void;
  50763. /**
  50764. * Generates a joint
  50765. * @param impostorJoint the imposter joint to create the joint with
  50766. */
  50767. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50768. /**
  50769. * Removes a joint
  50770. * @param impostorJoint the imposter joint to remove the joint from
  50771. */
  50772. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50773. private _addMeshVerts;
  50774. /**
  50775. * Initialise the soft body vertices to match its object's (mesh) vertices
  50776. * Softbody vertices (nodes) are in world space and to match this
  50777. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  50778. * @param impostor to create the softbody for
  50779. */
  50780. private _softVertexData;
  50781. /**
  50782. * Create an impostor's soft body
  50783. * @param impostor to create the softbody for
  50784. */
  50785. private _createSoftbody;
  50786. /**
  50787. * Create cloth for an impostor
  50788. * @param impostor to create the softbody for
  50789. */
  50790. private _createCloth;
  50791. /**
  50792. * Create rope for an impostor
  50793. * @param impostor to create the softbody for
  50794. */
  50795. private _createRope;
  50796. private _addHullVerts;
  50797. private _createShape;
  50798. /**
  50799. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  50800. * @param impostor imposter containing the physics body and babylon object
  50801. */
  50802. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50803. /**
  50804. * Sets the babylon object's position/rotation from the physics body's position/rotation
  50805. * @param impostor imposter containing the physics body and babylon object
  50806. * @param newPosition new position
  50807. * @param newRotation new rotation
  50808. */
  50809. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50810. /**
  50811. * If this plugin is supported
  50812. * @returns true if its supported
  50813. */
  50814. isSupported(): boolean;
  50815. /**
  50816. * Sets the linear velocity of the physics body
  50817. * @param impostor imposter to set the velocity on
  50818. * @param velocity velocity to set
  50819. */
  50820. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50821. /**
  50822. * Sets the angular velocity of the physics body
  50823. * @param impostor imposter to set the velocity on
  50824. * @param velocity velocity to set
  50825. */
  50826. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50827. /**
  50828. * gets the linear velocity
  50829. * @param impostor imposter to get linear velocity from
  50830. * @returns linear velocity
  50831. */
  50832. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50833. /**
  50834. * gets the angular velocity
  50835. * @param impostor imposter to get angular velocity from
  50836. * @returns angular velocity
  50837. */
  50838. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50839. /**
  50840. * Sets the mass of physics body
  50841. * @param impostor imposter to set the mass on
  50842. * @param mass mass to set
  50843. */
  50844. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50845. /**
  50846. * Gets the mass of the physics body
  50847. * @param impostor imposter to get the mass from
  50848. * @returns mass
  50849. */
  50850. getBodyMass(impostor: PhysicsImpostor): number;
  50851. /**
  50852. * Gets friction of the impostor
  50853. * @param impostor impostor to get friction from
  50854. * @returns friction value
  50855. */
  50856. getBodyFriction(impostor: PhysicsImpostor): number;
  50857. /**
  50858. * Sets friction of the impostor
  50859. * @param impostor impostor to set friction on
  50860. * @param friction friction value
  50861. */
  50862. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50863. /**
  50864. * Gets restitution of the impostor
  50865. * @param impostor impostor to get restitution from
  50866. * @returns restitution value
  50867. */
  50868. getBodyRestitution(impostor: PhysicsImpostor): number;
  50869. /**
  50870. * Sets resitution of the impostor
  50871. * @param impostor impostor to set resitution on
  50872. * @param restitution resitution value
  50873. */
  50874. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50875. /**
  50876. * Gets pressure inside the impostor
  50877. * @param impostor impostor to get pressure from
  50878. * @returns pressure value
  50879. */
  50880. getBodyPressure(impostor: PhysicsImpostor): number;
  50881. /**
  50882. * Sets pressure inside a soft body impostor
  50883. * Cloth and rope must remain 0 pressure
  50884. * @param impostor impostor to set pressure on
  50885. * @param pressure pressure value
  50886. */
  50887. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  50888. /**
  50889. * Gets stiffness of the impostor
  50890. * @param impostor impostor to get stiffness from
  50891. * @returns pressure value
  50892. */
  50893. getBodyStiffness(impostor: PhysicsImpostor): number;
  50894. /**
  50895. * Sets stiffness of the impostor
  50896. * @param impostor impostor to set stiffness on
  50897. * @param stiffness stiffness value from 0 to 1
  50898. */
  50899. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  50900. /**
  50901. * Gets velocityIterations of the impostor
  50902. * @param impostor impostor to get velocity iterations from
  50903. * @returns velocityIterations value
  50904. */
  50905. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  50906. /**
  50907. * Sets velocityIterations of the impostor
  50908. * @param impostor impostor to set velocity iterations on
  50909. * @param velocityIterations velocityIterations value
  50910. */
  50911. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  50912. /**
  50913. * Gets positionIterations of the impostor
  50914. * @param impostor impostor to get position iterations from
  50915. * @returns positionIterations value
  50916. */
  50917. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  50918. /**
  50919. * Sets positionIterations of the impostor
  50920. * @param impostor impostor to set position on
  50921. * @param positionIterations positionIterations value
  50922. */
  50923. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  50924. /**
  50925. * Append an anchor to a cloth object
  50926. * @param impostor is the cloth impostor to add anchor to
  50927. * @param otherImpostor is the rigid impostor to anchor to
  50928. * @param width ratio across width from 0 to 1
  50929. * @param height ratio up height from 0 to 1
  50930. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  50931. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  50932. */
  50933. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  50934. /**
  50935. * Append an hook to a rope object
  50936. * @param impostor is the rope impostor to add hook to
  50937. * @param otherImpostor is the rigid impostor to hook to
  50938. * @param length ratio along the rope from 0 to 1
  50939. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  50940. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  50941. */
  50942. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  50943. /**
  50944. * Sleeps the physics body and stops it from being active
  50945. * @param impostor impostor to sleep
  50946. */
  50947. sleepBody(impostor: PhysicsImpostor): void;
  50948. /**
  50949. * Activates the physics body
  50950. * @param impostor impostor to activate
  50951. */
  50952. wakeUpBody(impostor: PhysicsImpostor): void;
  50953. /**
  50954. * Updates the distance parameters of the joint
  50955. * @param joint joint to update
  50956. * @param maxDistance maximum distance of the joint
  50957. * @param minDistance minimum distance of the joint
  50958. */
  50959. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  50960. /**
  50961. * Sets a motor on the joint
  50962. * @param joint joint to set motor on
  50963. * @param speed speed of the motor
  50964. * @param maxForce maximum force of the motor
  50965. * @param motorIndex index of the motor
  50966. */
  50967. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  50968. /**
  50969. * Sets the motors limit
  50970. * @param joint joint to set limit on
  50971. * @param upperLimit upper limit
  50972. * @param lowerLimit lower limit
  50973. */
  50974. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  50975. /**
  50976. * Syncs the position and rotation of a mesh with the impostor
  50977. * @param mesh mesh to sync
  50978. * @param impostor impostor to update the mesh with
  50979. */
  50980. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50981. /**
  50982. * Gets the radius of the impostor
  50983. * @param impostor impostor to get radius from
  50984. * @returns the radius
  50985. */
  50986. getRadius(impostor: PhysicsImpostor): number;
  50987. /**
  50988. * Gets the box size of the impostor
  50989. * @param impostor impostor to get box size from
  50990. * @param result the resulting box size
  50991. */
  50992. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50993. /**
  50994. * Disposes of the impostor
  50995. */
  50996. dispose(): void;
  50997. /**
  50998. * Does a raycast in the physics world
  50999. * @param from when should the ray start?
  51000. * @param to when should the ray end?
  51001. * @returns PhysicsRaycastResult
  51002. */
  51003. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51004. }
  51005. }
  51006. declare module "babylonjs/Probes/reflectionProbe" {
  51007. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51008. import { Vector3 } from "babylonjs/Maths/math";
  51009. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51010. import { Nullable } from "babylonjs/types";
  51011. import { Scene } from "babylonjs/scene";
  51012. module "babylonjs/abstractScene" {
  51013. interface AbstractScene {
  51014. /**
  51015. * The list of reflection probes added to the scene
  51016. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  51017. */
  51018. reflectionProbes: Array<ReflectionProbe>;
  51019. /**
  51020. * Removes the given reflection probe from this scene.
  51021. * @param toRemove The reflection probe to remove
  51022. * @returns The index of the removed reflection probe
  51023. */
  51024. removeReflectionProbe(toRemove: ReflectionProbe): number;
  51025. /**
  51026. * Adds the given reflection probe to this scene.
  51027. * @param newReflectionProbe The reflection probe to add
  51028. */
  51029. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  51030. }
  51031. }
  51032. /**
  51033. * Class used to generate realtime reflection / refraction cube textures
  51034. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  51035. */
  51036. export class ReflectionProbe {
  51037. /** defines the name of the probe */
  51038. name: string;
  51039. private _scene;
  51040. private _renderTargetTexture;
  51041. private _projectionMatrix;
  51042. private _viewMatrix;
  51043. private _target;
  51044. private _add;
  51045. private _attachedMesh;
  51046. private _invertYAxis;
  51047. /** Gets or sets probe position (center of the cube map) */
  51048. position: Vector3;
  51049. /**
  51050. * Creates a new reflection probe
  51051. * @param name defines the name of the probe
  51052. * @param size defines the texture resolution (for each face)
  51053. * @param scene defines the hosting scene
  51054. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  51055. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  51056. */
  51057. constructor(
  51058. /** defines the name of the probe */
  51059. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  51060. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  51061. samples: number;
  51062. /** Gets or sets the refresh rate to use (on every frame by default) */
  51063. refreshRate: number;
  51064. /**
  51065. * Gets the hosting scene
  51066. * @returns a Scene
  51067. */
  51068. getScene(): Scene;
  51069. /** Gets the internal CubeTexture used to render to */
  51070. readonly cubeTexture: RenderTargetTexture;
  51071. /** Gets the list of meshes to render */
  51072. readonly renderList: Nullable<AbstractMesh[]>;
  51073. /**
  51074. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  51075. * @param mesh defines the mesh to attach to
  51076. */
  51077. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  51078. /**
  51079. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  51080. * @param renderingGroupId The rendering group id corresponding to its index
  51081. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  51082. */
  51083. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  51084. /**
  51085. * Clean all associated resources
  51086. */
  51087. dispose(): void;
  51088. /**
  51089. * Converts the reflection probe information to a readable string for debug purpose.
  51090. * @param fullDetails Supports for multiple levels of logging within scene loading
  51091. * @returns the human readable reflection probe info
  51092. */
  51093. toString(fullDetails?: boolean): string;
  51094. /**
  51095. * Get the class name of the relfection probe.
  51096. * @returns "ReflectionProbe"
  51097. */
  51098. getClassName(): string;
  51099. /**
  51100. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  51101. * @returns The JSON representation of the texture
  51102. */
  51103. serialize(): any;
  51104. /**
  51105. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  51106. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  51107. * @param scene Define the scene the parsed reflection probe should be instantiated in
  51108. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  51109. * @returns The parsed reflection probe if successful
  51110. */
  51111. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  51112. }
  51113. }
  51114. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  51115. /** @hidden */
  51116. export var _BabylonLoaderRegistered: boolean;
  51117. }
  51118. declare module "babylonjs/Loading/Plugins/index" {
  51119. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  51120. }
  51121. declare module "babylonjs/Loading/index" {
  51122. export * from "babylonjs/Loading/loadingScreen";
  51123. export * from "babylonjs/Loading/Plugins/index";
  51124. export * from "babylonjs/Loading/sceneLoader";
  51125. export * from "babylonjs/Loading/sceneLoaderFlags";
  51126. }
  51127. declare module "babylonjs/Materials/Background/index" {
  51128. export * from "babylonjs/Materials/Background/backgroundMaterial";
  51129. }
  51130. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  51131. import { Scene } from "babylonjs/scene";
  51132. import { Color3 } from "babylonjs/Maths/math";
  51133. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  51134. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51135. /**
  51136. * The Physically based simple base material of BJS.
  51137. *
  51138. * This enables better naming and convention enforcements on top of the pbrMaterial.
  51139. * It is used as the base class for both the specGloss and metalRough conventions.
  51140. */
  51141. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  51142. /**
  51143. * Number of Simultaneous lights allowed on the material.
  51144. */
  51145. maxSimultaneousLights: number;
  51146. /**
  51147. * If sets to true, disables all the lights affecting the material.
  51148. */
  51149. disableLighting: boolean;
  51150. /**
  51151. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  51152. */
  51153. environmentTexture: BaseTexture;
  51154. /**
  51155. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  51156. */
  51157. invertNormalMapX: boolean;
  51158. /**
  51159. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  51160. */
  51161. invertNormalMapY: boolean;
  51162. /**
  51163. * Normal map used in the model.
  51164. */
  51165. normalTexture: BaseTexture;
  51166. /**
  51167. * Emissivie color used to self-illuminate the model.
  51168. */
  51169. emissiveColor: Color3;
  51170. /**
  51171. * Emissivie texture used to self-illuminate the model.
  51172. */
  51173. emissiveTexture: BaseTexture;
  51174. /**
  51175. * Occlusion Channel Strenght.
  51176. */
  51177. occlusionStrength: number;
  51178. /**
  51179. * Occlusion Texture of the material (adding extra occlusion effects).
  51180. */
  51181. occlusionTexture: BaseTexture;
  51182. /**
  51183. * Defines the alpha limits in alpha test mode.
  51184. */
  51185. alphaCutOff: number;
  51186. /**
  51187. * Gets the current double sided mode.
  51188. */
  51189. /**
  51190. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51191. */
  51192. doubleSided: boolean;
  51193. /**
  51194. * Stores the pre-calculated light information of a mesh in a texture.
  51195. */
  51196. lightmapTexture: BaseTexture;
  51197. /**
  51198. * If true, the light map contains occlusion information instead of lighting info.
  51199. */
  51200. useLightmapAsShadowmap: boolean;
  51201. /**
  51202. * Instantiates a new PBRMaterial instance.
  51203. *
  51204. * @param name The material name
  51205. * @param scene The scene the material will be use in.
  51206. */
  51207. constructor(name: string, scene: Scene);
  51208. getClassName(): string;
  51209. }
  51210. }
  51211. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  51212. import { Scene } from "babylonjs/scene";
  51213. import { Color3 } from "babylonjs/Maths/math";
  51214. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51215. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  51216. /**
  51217. * The PBR material of BJS following the metal roughness convention.
  51218. *
  51219. * This fits to the PBR convention in the GLTF definition:
  51220. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  51221. */
  51222. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  51223. /**
  51224. * The base color has two different interpretations depending on the value of metalness.
  51225. * When the material is a metal, the base color is the specific measured reflectance value
  51226. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  51227. * of the material.
  51228. */
  51229. baseColor: Color3;
  51230. /**
  51231. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  51232. * well as opacity information in the alpha channel.
  51233. */
  51234. baseTexture: BaseTexture;
  51235. /**
  51236. * Specifies the metallic scalar value of the material.
  51237. * Can also be used to scale the metalness values of the metallic texture.
  51238. */
  51239. metallic: number;
  51240. /**
  51241. * Specifies the roughness scalar value of the material.
  51242. * Can also be used to scale the roughness values of the metallic texture.
  51243. */
  51244. roughness: number;
  51245. /**
  51246. * Texture containing both the metallic value in the B channel and the
  51247. * roughness value in the G channel to keep better precision.
  51248. */
  51249. metallicRoughnessTexture: BaseTexture;
  51250. /**
  51251. * Instantiates a new PBRMetalRoughnessMaterial instance.
  51252. *
  51253. * @param name The material name
  51254. * @param scene The scene the material will be use in.
  51255. */
  51256. constructor(name: string, scene: Scene);
  51257. /**
  51258. * Return the currrent class name of the material.
  51259. */
  51260. getClassName(): string;
  51261. /**
  51262. * Makes a duplicate of the current material.
  51263. * @param name - name to use for the new material.
  51264. */
  51265. clone(name: string): PBRMetallicRoughnessMaterial;
  51266. /**
  51267. * Serialize the material to a parsable JSON object.
  51268. */
  51269. serialize(): any;
  51270. /**
  51271. * Parses a JSON object correponding to the serialize function.
  51272. */
  51273. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  51274. }
  51275. }
  51276. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  51277. import { Scene } from "babylonjs/scene";
  51278. import { Color3 } from "babylonjs/Maths/math";
  51279. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51280. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  51281. /**
  51282. * The PBR material of BJS following the specular glossiness convention.
  51283. *
  51284. * This fits to the PBR convention in the GLTF definition:
  51285. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  51286. */
  51287. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  51288. /**
  51289. * Specifies the diffuse color of the material.
  51290. */
  51291. diffuseColor: Color3;
  51292. /**
  51293. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  51294. * channel.
  51295. */
  51296. diffuseTexture: BaseTexture;
  51297. /**
  51298. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  51299. */
  51300. specularColor: Color3;
  51301. /**
  51302. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  51303. */
  51304. glossiness: number;
  51305. /**
  51306. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  51307. */
  51308. specularGlossinessTexture: BaseTexture;
  51309. /**
  51310. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  51311. *
  51312. * @param name The material name
  51313. * @param scene The scene the material will be use in.
  51314. */
  51315. constructor(name: string, scene: Scene);
  51316. /**
  51317. * Return the currrent class name of the material.
  51318. */
  51319. getClassName(): string;
  51320. /**
  51321. * Makes a duplicate of the current material.
  51322. * @param name - name to use for the new material.
  51323. */
  51324. clone(name: string): PBRSpecularGlossinessMaterial;
  51325. /**
  51326. * Serialize the material to a parsable JSON object.
  51327. */
  51328. serialize(): any;
  51329. /**
  51330. * Parses a JSON object correponding to the serialize function.
  51331. */
  51332. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  51333. }
  51334. }
  51335. declare module "babylonjs/Materials/PBR/index" {
  51336. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  51337. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  51338. export * from "babylonjs/Materials/PBR/pbrMaterial";
  51339. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  51340. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  51341. }
  51342. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  51343. import { Nullable } from "babylonjs/types";
  51344. import { Scene } from "babylonjs/scene";
  51345. import { Matrix } from "babylonjs/Maths/math";
  51346. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51347. /**
  51348. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  51349. * It can help converting any input color in a desired output one. This can then be used to create effects
  51350. * from sepia, black and white to sixties or futuristic rendering...
  51351. *
  51352. * The only supported format is currently 3dl.
  51353. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  51354. */
  51355. export class ColorGradingTexture extends BaseTexture {
  51356. /**
  51357. * The current texture matrix. (will always be identity in color grading texture)
  51358. */
  51359. private _textureMatrix;
  51360. /**
  51361. * The texture URL.
  51362. */
  51363. url: string;
  51364. /**
  51365. * Empty line regex stored for GC.
  51366. */
  51367. private static _noneEmptyLineRegex;
  51368. private _engine;
  51369. /**
  51370. * Instantiates a ColorGradingTexture from the following parameters.
  51371. *
  51372. * @param url The location of the color gradind data (currently only supporting 3dl)
  51373. * @param scene The scene the texture will be used in
  51374. */
  51375. constructor(url: string, scene: Scene);
  51376. /**
  51377. * Returns the texture matrix used in most of the material.
  51378. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  51379. */
  51380. getTextureMatrix(): Matrix;
  51381. /**
  51382. * Occurs when the file being loaded is a .3dl LUT file.
  51383. */
  51384. private load3dlTexture;
  51385. /**
  51386. * Starts the loading process of the texture.
  51387. */
  51388. private loadTexture;
  51389. /**
  51390. * Clones the color gradind texture.
  51391. */
  51392. clone(): ColorGradingTexture;
  51393. /**
  51394. * Called during delayed load for textures.
  51395. */
  51396. delayLoad(): void;
  51397. /**
  51398. * Parses a color grading texture serialized by Babylon.
  51399. * @param parsedTexture The texture information being parsedTexture
  51400. * @param scene The scene to load the texture in
  51401. * @param rootUrl The root url of the data assets to load
  51402. * @return A color gradind texture
  51403. */
  51404. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  51405. /**
  51406. * Serializes the LUT texture to json format.
  51407. */
  51408. serialize(): any;
  51409. }
  51410. }
  51411. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  51412. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51413. import { Scene } from "babylonjs/scene";
  51414. import { Nullable } from "babylonjs/types";
  51415. import "babylonjs/Engines/Extensions/engine.rawTexture";
  51416. /**
  51417. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  51418. */
  51419. export class EquiRectangularCubeTexture extends BaseTexture {
  51420. /** The six faces of the cube. */
  51421. private static _FacesMapping;
  51422. private _noMipmap;
  51423. private _onLoad;
  51424. private _onError;
  51425. /** The size of the cubemap. */
  51426. private _size;
  51427. /** The buffer of the image. */
  51428. private _buffer;
  51429. /** The width of the input image. */
  51430. private _width;
  51431. /** The height of the input image. */
  51432. private _height;
  51433. /** The URL to the image. */
  51434. url: string;
  51435. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  51436. coordinatesMode: number;
  51437. /**
  51438. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  51439. * @param url The location of the image
  51440. * @param scene The scene the texture will be used in
  51441. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  51442. * @param noMipmap Forces to not generate the mipmap if true
  51443. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  51444. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  51445. * @param onLoad — defines a callback called when texture is loaded
  51446. * @param onError — defines a callback called if there is an error
  51447. */
  51448. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  51449. /**
  51450. * Load the image data, by putting the image on a canvas and extracting its buffer.
  51451. */
  51452. private loadImage;
  51453. /**
  51454. * Convert the image buffer into a cubemap and create a CubeTexture.
  51455. */
  51456. private loadTexture;
  51457. /**
  51458. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  51459. * @param buffer The ArrayBuffer that should be converted.
  51460. * @returns The buffer as Float32Array.
  51461. */
  51462. private getFloat32ArrayFromArrayBuffer;
  51463. /**
  51464. * Get the current class name of the texture useful for serialization or dynamic coding.
  51465. * @returns "EquiRectangularCubeTexture"
  51466. */
  51467. getClassName(): string;
  51468. /**
  51469. * Create a clone of the current EquiRectangularCubeTexture and return it.
  51470. * @returns A clone of the current EquiRectangularCubeTexture.
  51471. */
  51472. clone(): EquiRectangularCubeTexture;
  51473. }
  51474. }
  51475. declare module "babylonjs/Misc/tga" {
  51476. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51477. /**
  51478. * Based on jsTGALoader - Javascript loader for TGA file
  51479. * By Vincent Thibault
  51480. * @see http://blog.robrowser.com/javascript-tga-loader.html
  51481. */
  51482. export class TGATools {
  51483. private static _TYPE_INDEXED;
  51484. private static _TYPE_RGB;
  51485. private static _TYPE_GREY;
  51486. private static _TYPE_RLE_INDEXED;
  51487. private static _TYPE_RLE_RGB;
  51488. private static _TYPE_RLE_GREY;
  51489. private static _ORIGIN_MASK;
  51490. private static _ORIGIN_SHIFT;
  51491. private static _ORIGIN_BL;
  51492. private static _ORIGIN_BR;
  51493. private static _ORIGIN_UL;
  51494. private static _ORIGIN_UR;
  51495. /**
  51496. * Gets the header of a TGA file
  51497. * @param data defines the TGA data
  51498. * @returns the header
  51499. */
  51500. static GetTGAHeader(data: Uint8Array): any;
  51501. /**
  51502. * Uploads TGA content to a Babylon Texture
  51503. * @hidden
  51504. */
  51505. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  51506. /** @hidden */
  51507. 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;
  51508. /** @hidden */
  51509. 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;
  51510. /** @hidden */
  51511. 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;
  51512. /** @hidden */
  51513. 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;
  51514. /** @hidden */
  51515. 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;
  51516. /** @hidden */
  51517. 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;
  51518. }
  51519. }
  51520. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  51521. import { Nullable } from "babylonjs/types";
  51522. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51523. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  51524. /**
  51525. * Implementation of the TGA Texture Loader.
  51526. * @hidden
  51527. */
  51528. export class _TGATextureLoader implements IInternalTextureLoader {
  51529. /**
  51530. * Defines wether the loader supports cascade loading the different faces.
  51531. */
  51532. readonly supportCascades: boolean;
  51533. /**
  51534. * This returns if the loader support the current file information.
  51535. * @param extension defines the file extension of the file being loaded
  51536. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51537. * @param fallback defines the fallback internal texture if any
  51538. * @param isBase64 defines whether the texture is encoded as a base64
  51539. * @param isBuffer defines whether the texture data are stored as a buffer
  51540. * @returns true if the loader can load the specified file
  51541. */
  51542. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51543. /**
  51544. * Transform the url before loading if required.
  51545. * @param rootUrl the url of the texture
  51546. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51547. * @returns the transformed texture
  51548. */
  51549. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51550. /**
  51551. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51552. * @param rootUrl the url of the texture
  51553. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51554. * @returns the fallback texture
  51555. */
  51556. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51557. /**
  51558. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51559. * @param data contains the texture data
  51560. * @param texture defines the BabylonJS internal texture
  51561. * @param createPolynomials will be true if polynomials have been requested
  51562. * @param onLoad defines the callback to trigger once the texture is ready
  51563. * @param onError defines the callback to trigger in case of error
  51564. */
  51565. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51566. /**
  51567. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51568. * @param data contains the texture data
  51569. * @param texture defines the BabylonJS internal texture
  51570. * @param callback defines the method to call once ready to upload
  51571. */
  51572. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  51573. }
  51574. }
  51575. declare module "babylonjs/Materials/Textures/Loaders/index" {
  51576. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  51577. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  51578. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  51579. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  51580. }
  51581. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  51582. import { Scene } from "babylonjs/scene";
  51583. import { Texture } from "babylonjs/Materials/Textures/texture";
  51584. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  51585. /**
  51586. * 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.
  51587. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  51588. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  51589. */
  51590. export class CustomProceduralTexture extends ProceduralTexture {
  51591. private _animate;
  51592. private _time;
  51593. private _config;
  51594. private _texturePath;
  51595. /**
  51596. * Instantiates a new Custom Procedural Texture.
  51597. * 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.
  51598. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  51599. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  51600. * @param name Define the name of the texture
  51601. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  51602. * @param size Define the size of the texture to create
  51603. * @param scene Define the scene the texture belongs to
  51604. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  51605. * @param generateMipMaps Define if the texture should creates mip maps or not
  51606. */
  51607. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  51608. private _loadJson;
  51609. /**
  51610. * Is the texture ready to be used ? (rendered at least once)
  51611. * @returns true if ready, otherwise, false.
  51612. */
  51613. isReady(): boolean;
  51614. /**
  51615. * Render the texture to its associated render target.
  51616. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  51617. */
  51618. render(useCameraPostProcess?: boolean): void;
  51619. /**
  51620. * Update the list of dependant textures samplers in the shader.
  51621. */
  51622. updateTextures(): void;
  51623. /**
  51624. * Update the uniform values of the procedural texture in the shader.
  51625. */
  51626. updateShaderUniforms(): void;
  51627. /**
  51628. * Define if the texture animates or not.
  51629. */
  51630. animate: boolean;
  51631. }
  51632. }
  51633. declare module "babylonjs/Shaders/noise.fragment" {
  51634. /** @hidden */
  51635. export var noisePixelShader: {
  51636. name: string;
  51637. shader: string;
  51638. };
  51639. }
  51640. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  51641. import { Nullable } from "babylonjs/types";
  51642. import { Scene } from "babylonjs/scene";
  51643. import { Texture } from "babylonjs/Materials/Textures/texture";
  51644. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  51645. import "babylonjs/Shaders/noise.fragment";
  51646. /**
  51647. * Class used to generate noise procedural textures
  51648. */
  51649. export class NoiseProceduralTexture extends ProceduralTexture {
  51650. private _time;
  51651. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  51652. brightness: number;
  51653. /** Defines the number of octaves to process */
  51654. octaves: number;
  51655. /** Defines the level of persistence (0.8 by default) */
  51656. persistence: number;
  51657. /** Gets or sets animation speed factor (default is 1) */
  51658. animationSpeedFactor: number;
  51659. /**
  51660. * Creates a new NoiseProceduralTexture
  51661. * @param name defines the name fo the texture
  51662. * @param size defines the size of the texture (default is 256)
  51663. * @param scene defines the hosting scene
  51664. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  51665. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  51666. */
  51667. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  51668. private _updateShaderUniforms;
  51669. protected _getDefines(): string;
  51670. /** Generate the current state of the procedural texture */
  51671. render(useCameraPostProcess?: boolean): void;
  51672. /**
  51673. * Serializes this noise procedural texture
  51674. * @returns a serialized noise procedural texture object
  51675. */
  51676. serialize(): any;
  51677. /**
  51678. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  51679. * @param parsedTexture defines parsed texture data
  51680. * @param scene defines the current scene
  51681. * @param rootUrl defines the root URL containing noise procedural texture information
  51682. * @returns a parsed NoiseProceduralTexture
  51683. */
  51684. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  51685. }
  51686. }
  51687. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  51688. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  51689. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  51690. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  51691. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  51692. }
  51693. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  51694. import { Nullable } from "babylonjs/types";
  51695. import { Scene } from "babylonjs/scene";
  51696. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  51697. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51698. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  51699. import "babylonjs/Engines/Extensions/engine.rawTexture";
  51700. /**
  51701. * Raw cube texture where the raw buffers are passed in
  51702. */
  51703. export class RawCubeTexture extends CubeTexture {
  51704. /**
  51705. * Creates a cube texture where the raw buffers are passed in.
  51706. * @param scene defines the scene the texture is attached to
  51707. * @param data defines the array of data to use to create each face
  51708. * @param size defines the size of the textures
  51709. * @param format defines the format of the data
  51710. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  51711. * @param generateMipMaps defines if the engine should generate the mip levels
  51712. * @param invertY defines if data must be stored with Y axis inverted
  51713. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  51714. * @param compression defines the compression used (null by default)
  51715. */
  51716. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  51717. /**
  51718. * Updates the raw cube texture.
  51719. * @param data defines the data to store
  51720. * @param format defines the data format
  51721. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  51722. * @param invertY defines if data must be stored with Y axis inverted
  51723. * @param compression defines the compression used (null by default)
  51724. * @param level defines which level of the texture to update
  51725. */
  51726. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  51727. /**
  51728. * Updates a raw cube texture with RGBD encoded data.
  51729. * @param data defines the array of data [mipmap][face] to use to create each face
  51730. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  51731. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  51732. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  51733. * @returns a promsie that resolves when the operation is complete
  51734. */
  51735. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  51736. /**
  51737. * Clones the raw cube texture.
  51738. * @return a new cube texture
  51739. */
  51740. clone(): CubeTexture;
  51741. /** @hidden */
  51742. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  51743. }
  51744. }
  51745. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  51746. import { Scene } from "babylonjs/scene";
  51747. import { Texture } from "babylonjs/Materials/Textures/texture";
  51748. import "babylonjs/Engines/Extensions/engine.rawTexture";
  51749. /**
  51750. * Class used to store 3D textures containing user data
  51751. */
  51752. export class RawTexture3D extends Texture {
  51753. /** Gets or sets the texture format to use */
  51754. format: number;
  51755. private _engine;
  51756. /**
  51757. * Create a new RawTexture3D
  51758. * @param data defines the data of the texture
  51759. * @param width defines the width of the texture
  51760. * @param height defines the height of the texture
  51761. * @param depth defines the depth of the texture
  51762. * @param format defines the texture format to use
  51763. * @param scene defines the hosting scene
  51764. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  51765. * @param invertY defines if texture must be stored with Y axis inverted
  51766. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  51767. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  51768. */
  51769. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  51770. /** Gets or sets the texture format to use */
  51771. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  51772. /**
  51773. * Update the texture with new data
  51774. * @param data defines the data to store in the texture
  51775. */
  51776. update(data: ArrayBufferView): void;
  51777. }
  51778. }
  51779. declare module "babylonjs/Materials/Textures/refractionTexture" {
  51780. import { Scene } from "babylonjs/scene";
  51781. import { Plane } from "babylonjs/Maths/math";
  51782. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51783. /**
  51784. * Creates a refraction texture used by refraction channel of the standard material.
  51785. * It is like a mirror but to see through a material.
  51786. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51787. */
  51788. export class RefractionTexture extends RenderTargetTexture {
  51789. /**
  51790. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  51791. * 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.
  51792. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51793. */
  51794. refractionPlane: Plane;
  51795. /**
  51796. * Define how deep under the surface we should see.
  51797. */
  51798. depth: number;
  51799. /**
  51800. * Creates a refraction texture used by refraction channel of the standard material.
  51801. * It is like a mirror but to see through a material.
  51802. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51803. * @param name Define the texture name
  51804. * @param size Define the size of the underlying texture
  51805. * @param scene Define the scene the refraction belongs to
  51806. * @param generateMipMaps Define if we need to generate mips level for the refraction
  51807. */
  51808. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  51809. /**
  51810. * Clone the refraction texture.
  51811. * @returns the cloned texture
  51812. */
  51813. clone(): RefractionTexture;
  51814. /**
  51815. * Serialize the texture to a JSON representation you could use in Parse later on
  51816. * @returns the serialized JSON representation
  51817. */
  51818. serialize(): any;
  51819. }
  51820. }
  51821. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  51822. import { Nullable } from "babylonjs/types";
  51823. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51824. import { Matrix } from "babylonjs/Maths/math";
  51825. import { Engine } from "babylonjs/Engines/engine";
  51826. import { Scene } from "babylonjs/scene";
  51827. /**
  51828. * Defines the options related to the creation of an HtmlElementTexture
  51829. */
  51830. export interface IHtmlElementTextureOptions {
  51831. /**
  51832. * Defines wether mip maps should be created or not.
  51833. */
  51834. generateMipMaps?: boolean;
  51835. /**
  51836. * Defines the sampling mode of the texture.
  51837. */
  51838. samplingMode?: number;
  51839. /**
  51840. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  51841. */
  51842. engine: Nullable<Engine>;
  51843. /**
  51844. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  51845. */
  51846. scene: Nullable<Scene>;
  51847. }
  51848. /**
  51849. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  51850. * To be as efficient as possible depending on your constraints nothing aside the first upload
  51851. * is automatically managed.
  51852. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  51853. * in your application.
  51854. *
  51855. * As the update is not automatic, you need to call them manually.
  51856. */
  51857. export class HtmlElementTexture extends BaseTexture {
  51858. /**
  51859. * The texture URL.
  51860. */
  51861. element: HTMLVideoElement | HTMLCanvasElement;
  51862. private static readonly DefaultOptions;
  51863. private _textureMatrix;
  51864. private _engine;
  51865. private _isVideo;
  51866. private _generateMipMaps;
  51867. private _samplingMode;
  51868. /**
  51869. * Instantiates a HtmlElementTexture from the following parameters.
  51870. *
  51871. * @param name Defines the name of the texture
  51872. * @param element Defines the video or canvas the texture is filled with
  51873. * @param options Defines the other none mandatory texture creation options
  51874. */
  51875. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  51876. private _createInternalTexture;
  51877. /**
  51878. * Returns the texture matrix used in most of the material.
  51879. */
  51880. getTextureMatrix(): Matrix;
  51881. /**
  51882. * Updates the content of the texture.
  51883. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  51884. */
  51885. update(invertY?: Nullable<boolean>): void;
  51886. }
  51887. }
  51888. declare module "babylonjs/Materials/Textures/index" {
  51889. export * from "babylonjs/Materials/Textures/baseTexture";
  51890. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  51891. export * from "babylonjs/Materials/Textures/cubeTexture";
  51892. export * from "babylonjs/Materials/Textures/dynamicTexture";
  51893. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  51894. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  51895. export * from "babylonjs/Materials/Textures/internalTexture";
  51896. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  51897. export * from "babylonjs/Materials/Textures/Loaders/index";
  51898. export * from "babylonjs/Materials/Textures/mirrorTexture";
  51899. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  51900. export * from "babylonjs/Materials/Textures/Procedurals/index";
  51901. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  51902. export * from "babylonjs/Materials/Textures/rawTexture";
  51903. export * from "babylonjs/Materials/Textures/rawTexture3D";
  51904. export * from "babylonjs/Materials/Textures/refractionTexture";
  51905. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  51906. export * from "babylonjs/Materials/Textures/texture";
  51907. export * from "babylonjs/Materials/Textures/videoTexture";
  51908. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  51909. }
  51910. declare module "babylonjs/Materials/index" {
  51911. export * from "babylonjs/Materials/Background/index";
  51912. export * from "babylonjs/Materials/colorCurves";
  51913. export * from "babylonjs/Materials/effect";
  51914. export * from "babylonjs/Materials/fresnelParameters";
  51915. export * from "babylonjs/Materials/imageProcessingConfiguration";
  51916. export * from "babylonjs/Materials/material";
  51917. export * from "babylonjs/Materials/materialDefines";
  51918. export * from "babylonjs/Materials/materialHelper";
  51919. export * from "babylonjs/Materials/multiMaterial";
  51920. export * from "babylonjs/Materials/PBR/index";
  51921. export * from "babylonjs/Materials/pushMaterial";
  51922. export * from "babylonjs/Materials/shaderMaterial";
  51923. export * from "babylonjs/Materials/standardMaterial";
  51924. export * from "babylonjs/Materials/Textures/index";
  51925. export * from "babylonjs/Materials/uniformBuffer";
  51926. export * from "babylonjs/Materials/materialFlags";
  51927. }
  51928. declare module "babylonjs/Maths/index" {
  51929. export * from "babylonjs/Maths/math.scalar";
  51930. export * from "babylonjs/Maths/math";
  51931. export * from "babylonjs/Maths/sphericalPolynomial";
  51932. }
  51933. declare module "babylonjs/Misc/workerPool" {
  51934. import { IDisposable } from "babylonjs/scene";
  51935. /**
  51936. * Helper class to push actions to a pool of workers.
  51937. */
  51938. export class WorkerPool implements IDisposable {
  51939. private _workerInfos;
  51940. private _pendingActions;
  51941. /**
  51942. * Constructor
  51943. * @param workers Array of workers to use for actions
  51944. */
  51945. constructor(workers: Array<Worker>);
  51946. /**
  51947. * Terminates all workers and clears any pending actions.
  51948. */
  51949. dispose(): void;
  51950. /**
  51951. * Pushes an action to the worker pool. If all the workers are active, the action will be
  51952. * pended until a worker has completed its action.
  51953. * @param action The action to perform. Call onComplete when the action is complete.
  51954. */
  51955. push(action: (worker: Worker, onComplete: () => void) => void): void;
  51956. private _execute;
  51957. }
  51958. }
  51959. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  51960. import { IDisposable } from "babylonjs/scene";
  51961. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  51962. /**
  51963. * Configuration for Draco compression
  51964. */
  51965. export interface IDracoCompressionConfiguration {
  51966. /**
  51967. * Configuration for the decoder.
  51968. */
  51969. decoder: {
  51970. /**
  51971. * The url to the WebAssembly module.
  51972. */
  51973. wasmUrl?: string;
  51974. /**
  51975. * The url to the WebAssembly binary.
  51976. */
  51977. wasmBinaryUrl?: string;
  51978. /**
  51979. * The url to the fallback JavaScript module.
  51980. */
  51981. fallbackUrl?: string;
  51982. };
  51983. }
  51984. /**
  51985. * Draco compression (https://google.github.io/draco/)
  51986. *
  51987. * This class wraps the Draco module.
  51988. *
  51989. * **Encoder**
  51990. *
  51991. * The encoder is not currently implemented.
  51992. *
  51993. * **Decoder**
  51994. *
  51995. * 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.
  51996. *
  51997. * To update the configuration, use the following code:
  51998. * ```javascript
  51999. * DracoCompression.Configuration = {
  52000. * decoder: {
  52001. * wasmUrl: "<url to the WebAssembly library>",
  52002. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  52003. * fallbackUrl: "<url to the fallback JavaScript library>",
  52004. * }
  52005. * };
  52006. * ```
  52007. *
  52008. * 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.
  52009. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  52010. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  52011. *
  52012. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  52013. * ```javascript
  52014. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  52015. * ```
  52016. *
  52017. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  52018. */
  52019. export class DracoCompression implements IDisposable {
  52020. private _workerPoolPromise?;
  52021. private _decoderModulePromise?;
  52022. /**
  52023. * The configuration. Defaults to the following urls:
  52024. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  52025. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  52026. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  52027. */
  52028. static Configuration: IDracoCompressionConfiguration;
  52029. /**
  52030. * Returns true if the decoder configuration is available.
  52031. */
  52032. static readonly DecoderAvailable: boolean;
  52033. /**
  52034. * Default number of workers to create when creating the draco compression object.
  52035. */
  52036. static DefaultNumWorkers: number;
  52037. private static GetDefaultNumWorkers;
  52038. private static _Default;
  52039. /**
  52040. * Default instance for the draco compression object.
  52041. */
  52042. static readonly Default: DracoCompression;
  52043. /**
  52044. * Constructor
  52045. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  52046. */
  52047. constructor(numWorkers?: number);
  52048. /**
  52049. * Stop all async operations and release resources.
  52050. */
  52051. dispose(): void;
  52052. /**
  52053. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  52054. * @returns a promise that resolves when ready
  52055. */
  52056. whenReadyAsync(): Promise<void>;
  52057. /**
  52058. * Decode Draco compressed mesh data to vertex data.
  52059. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  52060. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  52061. * @returns A promise that resolves with the decoded vertex data
  52062. */
  52063. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  52064. [kind: string]: number;
  52065. }): Promise<VertexData>;
  52066. }
  52067. }
  52068. declare module "babylonjs/Meshes/Compression/index" {
  52069. export * from "babylonjs/Meshes/Compression/dracoCompression";
  52070. }
  52071. declare module "babylonjs/Meshes/csg" {
  52072. import { Nullable } from "babylonjs/types";
  52073. import { Scene } from "babylonjs/scene";
  52074. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  52075. import { Mesh } from "babylonjs/Meshes/mesh";
  52076. import { Material } from "babylonjs/Materials/material";
  52077. /**
  52078. * Class for building Constructive Solid Geometry
  52079. */
  52080. export class CSG {
  52081. private polygons;
  52082. /**
  52083. * The world matrix
  52084. */
  52085. matrix: Matrix;
  52086. /**
  52087. * Stores the position
  52088. */
  52089. position: Vector3;
  52090. /**
  52091. * Stores the rotation
  52092. */
  52093. rotation: Vector3;
  52094. /**
  52095. * Stores the rotation quaternion
  52096. */
  52097. rotationQuaternion: Nullable<Quaternion>;
  52098. /**
  52099. * Stores the scaling vector
  52100. */
  52101. scaling: Vector3;
  52102. /**
  52103. * Convert the Mesh to CSG
  52104. * @param mesh The Mesh to convert to CSG
  52105. * @returns A new CSG from the Mesh
  52106. */
  52107. static FromMesh(mesh: Mesh): CSG;
  52108. /**
  52109. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  52110. * @param polygons Polygons used to construct a CSG solid
  52111. */
  52112. private static FromPolygons;
  52113. /**
  52114. * Clones, or makes a deep copy, of the CSG
  52115. * @returns A new CSG
  52116. */
  52117. clone(): CSG;
  52118. /**
  52119. * Unions this CSG with another CSG
  52120. * @param csg The CSG to union against this CSG
  52121. * @returns The unioned CSG
  52122. */
  52123. union(csg: CSG): CSG;
  52124. /**
  52125. * Unions this CSG with another CSG in place
  52126. * @param csg The CSG to union against this CSG
  52127. */
  52128. unionInPlace(csg: CSG): void;
  52129. /**
  52130. * Subtracts this CSG with another CSG
  52131. * @param csg The CSG to subtract against this CSG
  52132. * @returns A new CSG
  52133. */
  52134. subtract(csg: CSG): CSG;
  52135. /**
  52136. * Subtracts this CSG with another CSG in place
  52137. * @param csg The CSG to subtact against this CSG
  52138. */
  52139. subtractInPlace(csg: CSG): void;
  52140. /**
  52141. * Intersect this CSG with another CSG
  52142. * @param csg The CSG to intersect against this CSG
  52143. * @returns A new CSG
  52144. */
  52145. intersect(csg: CSG): CSG;
  52146. /**
  52147. * Intersects this CSG with another CSG in place
  52148. * @param csg The CSG to intersect against this CSG
  52149. */
  52150. intersectInPlace(csg: CSG): void;
  52151. /**
  52152. * Return a new CSG solid with solid and empty space switched. This solid is
  52153. * not modified.
  52154. * @returns A new CSG solid with solid and empty space switched
  52155. */
  52156. inverse(): CSG;
  52157. /**
  52158. * Inverses the CSG in place
  52159. */
  52160. inverseInPlace(): void;
  52161. /**
  52162. * This is used to keep meshes transformations so they can be restored
  52163. * when we build back a Babylon Mesh
  52164. * NB : All CSG operations are performed in world coordinates
  52165. * @param csg The CSG to copy the transform attributes from
  52166. * @returns This CSG
  52167. */
  52168. copyTransformAttributes(csg: CSG): CSG;
  52169. /**
  52170. * Build Raw mesh from CSG
  52171. * Coordinates here are in world space
  52172. * @param name The name of the mesh geometry
  52173. * @param scene The Scene
  52174. * @param keepSubMeshes Specifies if the submeshes should be kept
  52175. * @returns A new Mesh
  52176. */
  52177. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  52178. /**
  52179. * Build Mesh from CSG taking material and transforms into account
  52180. * @param name The name of the Mesh
  52181. * @param material The material of the Mesh
  52182. * @param scene The Scene
  52183. * @param keepSubMeshes Specifies if submeshes should be kept
  52184. * @returns The new Mesh
  52185. */
  52186. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  52187. }
  52188. }
  52189. declare module "babylonjs/Meshes/trailMesh" {
  52190. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52191. import { Mesh } from "babylonjs/Meshes/mesh";
  52192. import { Scene } from "babylonjs/scene";
  52193. /**
  52194. * Class used to create a trail following a mesh
  52195. */
  52196. export class TrailMesh extends Mesh {
  52197. private _generator;
  52198. private _autoStart;
  52199. private _running;
  52200. private _diameter;
  52201. private _length;
  52202. private _sectionPolygonPointsCount;
  52203. private _sectionVectors;
  52204. private _sectionNormalVectors;
  52205. private _beforeRenderObserver;
  52206. /**
  52207. * @constructor
  52208. * @param name The value used by scene.getMeshByName() to do a lookup.
  52209. * @param generator The mesh to generate a trail.
  52210. * @param scene The scene to add this mesh to.
  52211. * @param diameter Diameter of trailing mesh. Default is 1.
  52212. * @param length Length of trailing mesh. Default is 60.
  52213. * @param autoStart Automatically start trailing mesh. Default true.
  52214. */
  52215. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  52216. /**
  52217. * "TrailMesh"
  52218. * @returns "TrailMesh"
  52219. */
  52220. getClassName(): string;
  52221. private _createMesh;
  52222. /**
  52223. * Start trailing mesh.
  52224. */
  52225. start(): void;
  52226. /**
  52227. * Stop trailing mesh.
  52228. */
  52229. stop(): void;
  52230. /**
  52231. * Update trailing mesh geometry.
  52232. */
  52233. update(): void;
  52234. /**
  52235. * Returns a new TrailMesh object.
  52236. * @param name is a string, the name given to the new mesh
  52237. * @param newGenerator use new generator object for cloned trail mesh
  52238. * @returns a new mesh
  52239. */
  52240. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  52241. /**
  52242. * Serializes this trail mesh
  52243. * @param serializationObject object to write serialization to
  52244. */
  52245. serialize(serializationObject: any): void;
  52246. /**
  52247. * Parses a serialized trail mesh
  52248. * @param parsedMesh the serialized mesh
  52249. * @param scene the scene to create the trail mesh in
  52250. * @returns the created trail mesh
  52251. */
  52252. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  52253. }
  52254. }
  52255. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  52256. import { Vector4 } from "babylonjs/Maths/math";
  52257. import { Mesh } from "babylonjs/Meshes/mesh";
  52258. /**
  52259. * Class containing static functions to help procedurally build meshes
  52260. */
  52261. export class TorusKnotBuilder {
  52262. /**
  52263. * Creates a torus knot mesh
  52264. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  52265. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  52266. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  52267. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  52268. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52269. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52270. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52271. * @param name defines the name of the mesh
  52272. * @param options defines the options used to create the mesh
  52273. * @param scene defines the hosting scene
  52274. * @returns the torus knot mesh
  52275. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  52276. */
  52277. static CreateTorusKnot(name: string, options: {
  52278. radius?: number;
  52279. tube?: number;
  52280. radialSegments?: number;
  52281. tubularSegments?: number;
  52282. p?: number;
  52283. q?: number;
  52284. updatable?: boolean;
  52285. sideOrientation?: number;
  52286. frontUVs?: Vector4;
  52287. backUVs?: Vector4;
  52288. }, scene: any): Mesh;
  52289. }
  52290. }
  52291. declare module "babylonjs/Meshes/polygonMesh" {
  52292. import { Scene } from "babylonjs/scene";
  52293. import { Vector2, Path2 } from "babylonjs/Maths/math";
  52294. import { Mesh } from "babylonjs/Meshes/mesh";
  52295. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  52296. /**
  52297. * Polygon
  52298. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  52299. */
  52300. export class Polygon {
  52301. /**
  52302. * Creates a rectangle
  52303. * @param xmin bottom X coord
  52304. * @param ymin bottom Y coord
  52305. * @param xmax top X coord
  52306. * @param ymax top Y coord
  52307. * @returns points that make the resulting rectation
  52308. */
  52309. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  52310. /**
  52311. * Creates a circle
  52312. * @param radius radius of circle
  52313. * @param cx scale in x
  52314. * @param cy scale in y
  52315. * @param numberOfSides number of sides that make up the circle
  52316. * @returns points that make the resulting circle
  52317. */
  52318. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  52319. /**
  52320. * Creates a polygon from input string
  52321. * @param input Input polygon data
  52322. * @returns the parsed points
  52323. */
  52324. static Parse(input: string): Vector2[];
  52325. /**
  52326. * Starts building a polygon from x and y coordinates
  52327. * @param x x coordinate
  52328. * @param y y coordinate
  52329. * @returns the started path2
  52330. */
  52331. static StartingAt(x: number, y: number): Path2;
  52332. }
  52333. /**
  52334. * Builds a polygon
  52335. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  52336. */
  52337. export class PolygonMeshBuilder {
  52338. private _points;
  52339. private _outlinepoints;
  52340. private _holes;
  52341. private _name;
  52342. private _scene;
  52343. private _epoints;
  52344. private _eholes;
  52345. private _addToepoint;
  52346. /**
  52347. * Babylon reference to the earcut plugin.
  52348. */
  52349. bjsEarcut: any;
  52350. /**
  52351. * Creates a PolygonMeshBuilder
  52352. * @param name name of the builder
  52353. * @param contours Path of the polygon
  52354. * @param scene scene to add to when creating the mesh
  52355. * @param earcutInjection can be used to inject your own earcut reference
  52356. */
  52357. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  52358. /**
  52359. * Adds a whole within the polygon
  52360. * @param hole Array of points defining the hole
  52361. * @returns this
  52362. */
  52363. addHole(hole: Vector2[]): PolygonMeshBuilder;
  52364. /**
  52365. * Creates the polygon
  52366. * @param updatable If the mesh should be updatable
  52367. * @param depth The depth of the mesh created
  52368. * @returns the created mesh
  52369. */
  52370. build(updatable?: boolean, depth?: number): Mesh;
  52371. /**
  52372. * Creates the polygon
  52373. * @param depth The depth of the mesh created
  52374. * @returns the created VertexData
  52375. */
  52376. buildVertexData(depth?: number): VertexData;
  52377. /**
  52378. * Adds a side to the polygon
  52379. * @param positions points that make the polygon
  52380. * @param normals normals of the polygon
  52381. * @param uvs uvs of the polygon
  52382. * @param indices indices of the polygon
  52383. * @param bounds bounds of the polygon
  52384. * @param points points of the polygon
  52385. * @param depth depth of the polygon
  52386. * @param flip flip of the polygon
  52387. */
  52388. private addSide;
  52389. }
  52390. }
  52391. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  52392. import { Scene } from "babylonjs/scene";
  52393. import { Vector3, Color4, Vector4 } from "babylonjs/Maths/math";
  52394. import { Mesh } from "babylonjs/Meshes/mesh";
  52395. import { Nullable } from "babylonjs/types";
  52396. /**
  52397. * Class containing static functions to help procedurally build meshes
  52398. */
  52399. export class PolygonBuilder {
  52400. /**
  52401. * Creates a polygon mesh
  52402. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  52403. * * 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
  52404. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  52405. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52406. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  52407. * * Remember you can only change the shape positions, not their number when updating a polygon
  52408. * @param name defines the name of the mesh
  52409. * @param options defines the options used to create the mesh
  52410. * @param scene defines the hosting scene
  52411. * @param earcutInjection can be used to inject your own earcut reference
  52412. * @returns the polygon mesh
  52413. */
  52414. static CreatePolygon(name: string, options: {
  52415. shape: Vector3[];
  52416. holes?: Vector3[][];
  52417. depth?: number;
  52418. faceUV?: Vector4[];
  52419. faceColors?: Color4[];
  52420. updatable?: boolean;
  52421. sideOrientation?: number;
  52422. frontUVs?: Vector4;
  52423. backUVs?: Vector4;
  52424. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  52425. /**
  52426. * Creates an extruded polygon mesh, with depth in the Y direction.
  52427. * * 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)
  52428. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  52429. * @param name defines the name of the mesh
  52430. * @param options defines the options used to create the mesh
  52431. * @param scene defines the hosting scene
  52432. * @param earcutInjection can be used to inject your own earcut reference
  52433. * @returns the polygon mesh
  52434. */
  52435. static ExtrudePolygon(name: string, options: {
  52436. shape: Vector3[];
  52437. holes?: Vector3[][];
  52438. depth?: number;
  52439. faceUV?: Vector4[];
  52440. faceColors?: Color4[];
  52441. updatable?: boolean;
  52442. sideOrientation?: number;
  52443. frontUVs?: Vector4;
  52444. backUVs?: Vector4;
  52445. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  52446. }
  52447. }
  52448. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  52449. import { Scene } from "babylonjs/scene";
  52450. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  52451. import { Mesh } from "babylonjs/Meshes/mesh";
  52452. import { Nullable } from "babylonjs/types";
  52453. /**
  52454. * Class containing static functions to help procedurally build meshes
  52455. */
  52456. export class LatheBuilder {
  52457. /**
  52458. * Creates lathe mesh.
  52459. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  52460. * * 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
  52461. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  52462. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  52463. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  52464. * * 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
  52465. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  52466. * * 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
  52467. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52468. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52469. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  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 lathe mesh
  52475. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  52476. */
  52477. static CreateLathe(name: string, options: {
  52478. shape: Vector3[];
  52479. radius?: number;
  52480. tessellation?: number;
  52481. clip?: number;
  52482. arc?: number;
  52483. closed?: boolean;
  52484. updatable?: boolean;
  52485. sideOrientation?: number;
  52486. frontUVs?: Vector4;
  52487. backUVs?: Vector4;
  52488. cap?: number;
  52489. invertUV?: boolean;
  52490. }, scene?: Nullable<Scene>): Mesh;
  52491. }
  52492. }
  52493. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  52494. import { Nullable } from "babylonjs/types";
  52495. import { Scene } from "babylonjs/scene";
  52496. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  52497. import { Mesh } from "babylonjs/Meshes/mesh";
  52498. /**
  52499. * Class containing static functions to help procedurally build meshes
  52500. */
  52501. export class TubeBuilder {
  52502. /**
  52503. * Creates a tube mesh.
  52504. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  52505. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  52506. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  52507. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  52508. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  52509. * * 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)
  52510. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  52511. * * 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
  52512. * * 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
  52513. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52514. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52515. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52516. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52517. * @param name defines the name of the mesh
  52518. * @param options defines the options used to create the mesh
  52519. * @param scene defines the hosting scene
  52520. * @returns the tube mesh
  52521. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52522. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  52523. */
  52524. static CreateTube(name: string, options: {
  52525. path: Vector3[];
  52526. radius?: number;
  52527. tessellation?: number;
  52528. radiusFunction?: {
  52529. (i: number, distance: number): number;
  52530. };
  52531. cap?: number;
  52532. arc?: number;
  52533. updatable?: boolean;
  52534. sideOrientation?: number;
  52535. frontUVs?: Vector4;
  52536. backUVs?: Vector4;
  52537. instance?: Mesh;
  52538. invertUV?: boolean;
  52539. }, scene?: Nullable<Scene>): Mesh;
  52540. }
  52541. }
  52542. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  52543. import { Scene } from "babylonjs/scene";
  52544. import { Vector4 } from "babylonjs/Maths/math";
  52545. import { Mesh } from "babylonjs/Meshes/mesh";
  52546. import { Nullable } from "babylonjs/types";
  52547. /**
  52548. * Class containing static functions to help procedurally build meshes
  52549. */
  52550. export class IcoSphereBuilder {
  52551. /**
  52552. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  52553. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  52554. * * 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`)
  52555. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  52556. * * 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
  52557. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52558. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52559. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52560. * @param name defines the name of the mesh
  52561. * @param options defines the options used to create the mesh
  52562. * @param scene defines the hosting scene
  52563. * @returns the icosahedron mesh
  52564. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  52565. */
  52566. static CreateIcoSphere(name: string, options: {
  52567. radius?: number;
  52568. radiusX?: number;
  52569. radiusY?: number;
  52570. radiusZ?: number;
  52571. flat?: boolean;
  52572. subdivisions?: number;
  52573. sideOrientation?: number;
  52574. frontUVs?: Vector4;
  52575. backUVs?: Vector4;
  52576. updatable?: boolean;
  52577. }, scene?: Nullable<Scene>): Mesh;
  52578. }
  52579. }
  52580. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  52581. import { Vector3 } from "babylonjs/Maths/math";
  52582. import { Mesh } from "babylonjs/Meshes/mesh";
  52583. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52584. /**
  52585. * Class containing static functions to help procedurally build meshes
  52586. */
  52587. export class DecalBuilder {
  52588. /**
  52589. * Creates a decal mesh.
  52590. * 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
  52591. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  52592. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  52593. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  52594. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  52595. * @param name defines the name of the mesh
  52596. * @param sourceMesh defines the mesh where the decal must be applied
  52597. * @param options defines the options used to create the mesh
  52598. * @param scene defines the hosting scene
  52599. * @returns the decal mesh
  52600. * @see https://doc.babylonjs.com/how_to/decals
  52601. */
  52602. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  52603. position?: Vector3;
  52604. normal?: Vector3;
  52605. size?: Vector3;
  52606. angle?: number;
  52607. }): Mesh;
  52608. }
  52609. }
  52610. declare module "babylonjs/Meshes/meshBuilder" {
  52611. import { Vector4, Color4, Vector3, Vector2, Plane, Color3 } from "babylonjs/Maths/math";
  52612. import { Nullable } from "babylonjs/types";
  52613. import { Scene } from "babylonjs/scene";
  52614. import { Mesh } from "babylonjs/Meshes/mesh";
  52615. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  52616. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  52617. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52618. /**
  52619. * Class containing static functions to help procedurally build meshes
  52620. */
  52621. export class MeshBuilder {
  52622. /**
  52623. * Creates a box mesh
  52624. * * The parameter `size` sets the size (float) of each box side (default 1)
  52625. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  52626. * * 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)
  52627. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  52628. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52629. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52630. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52631. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  52632. * @param name defines the name of the mesh
  52633. * @param options defines the options used to create the mesh
  52634. * @param scene defines the hosting scene
  52635. * @returns the box mesh
  52636. */
  52637. static CreateBox(name: string, options: {
  52638. size?: number;
  52639. width?: number;
  52640. height?: number;
  52641. depth?: number;
  52642. faceUV?: Vector4[];
  52643. faceColors?: Color4[];
  52644. sideOrientation?: number;
  52645. frontUVs?: Vector4;
  52646. backUVs?: Vector4;
  52647. updatable?: boolean;
  52648. }, scene?: Nullable<Scene>): Mesh;
  52649. /**
  52650. * Creates a sphere mesh
  52651. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  52652. * * 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`)
  52653. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  52654. * * 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
  52655. * * 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)
  52656. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52657. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52658. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52659. * @param name defines the name of the mesh
  52660. * @param options defines the options used to create the mesh
  52661. * @param scene defines the hosting scene
  52662. * @returns the sphere mesh
  52663. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  52664. */
  52665. static CreateSphere(name: string, options: {
  52666. segments?: number;
  52667. diameter?: number;
  52668. diameterX?: number;
  52669. diameterY?: number;
  52670. diameterZ?: number;
  52671. arc?: number;
  52672. slice?: number;
  52673. sideOrientation?: number;
  52674. frontUVs?: Vector4;
  52675. backUVs?: Vector4;
  52676. updatable?: boolean;
  52677. }, scene?: Nullable<Scene>): Mesh;
  52678. /**
  52679. * Creates a plane polygonal mesh. By default, this is a disc
  52680. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  52681. * * 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
  52682. * * 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
  52683. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52684. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52685. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52686. * @param name defines the name of the mesh
  52687. * @param options defines the options used to create the mesh
  52688. * @param scene defines the hosting scene
  52689. * @returns the plane polygonal mesh
  52690. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  52691. */
  52692. static CreateDisc(name: string, options: {
  52693. radius?: number;
  52694. tessellation?: number;
  52695. arc?: number;
  52696. updatable?: boolean;
  52697. sideOrientation?: number;
  52698. frontUVs?: Vector4;
  52699. backUVs?: Vector4;
  52700. }, scene?: Nullable<Scene>): Mesh;
  52701. /**
  52702. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  52703. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  52704. * * 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`)
  52705. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  52706. * * 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
  52707. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52708. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52709. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52710. * @param name defines the name of the mesh
  52711. * @param options defines the options used to create the mesh
  52712. * @param scene defines the hosting scene
  52713. * @returns the icosahedron mesh
  52714. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  52715. */
  52716. static CreateIcoSphere(name: string, options: {
  52717. radius?: number;
  52718. radiusX?: number;
  52719. radiusY?: number;
  52720. radiusZ?: number;
  52721. flat?: boolean;
  52722. subdivisions?: number;
  52723. sideOrientation?: number;
  52724. frontUVs?: Vector4;
  52725. backUVs?: Vector4;
  52726. updatable?: boolean;
  52727. }, scene?: Nullable<Scene>): Mesh;
  52728. /**
  52729. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  52730. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  52731. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  52732. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  52733. * * 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
  52734. * * 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
  52735. * * 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
  52736. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52737. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52738. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52739. * * 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
  52740. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  52741. * * 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
  52742. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  52743. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52744. * @param name defines the name of the mesh
  52745. * @param options defines the options used to create the mesh
  52746. * @param scene defines the hosting scene
  52747. * @returns the ribbon mesh
  52748. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  52749. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52750. */
  52751. static CreateRibbon(name: string, options: {
  52752. pathArray: Vector3[][];
  52753. closeArray?: boolean;
  52754. closePath?: boolean;
  52755. offset?: number;
  52756. updatable?: boolean;
  52757. sideOrientation?: number;
  52758. frontUVs?: Vector4;
  52759. backUVs?: Vector4;
  52760. instance?: Mesh;
  52761. invertUV?: boolean;
  52762. uvs?: Vector2[];
  52763. colors?: Color4[];
  52764. }, scene?: Nullable<Scene>): Mesh;
  52765. /**
  52766. * Creates a cylinder or a cone mesh
  52767. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  52768. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  52769. * * 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.
  52770. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  52771. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  52772. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  52773. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  52774. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  52775. * * 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).
  52776. * * 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
  52777. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  52778. * * 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
  52779. * * 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.
  52780. * * If `enclose` is false, a ring surface is one element.
  52781. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  52782. * * 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
  52783. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52784. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52785. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52786. * @param name defines the name of the mesh
  52787. * @param options defines the options used to create the mesh
  52788. * @param scene defines the hosting scene
  52789. * @returns the cylinder mesh
  52790. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  52791. */
  52792. static CreateCylinder(name: string, options: {
  52793. height?: number;
  52794. diameterTop?: number;
  52795. diameterBottom?: number;
  52796. diameter?: number;
  52797. tessellation?: number;
  52798. subdivisions?: number;
  52799. arc?: number;
  52800. faceColors?: Color4[];
  52801. faceUV?: Vector4[];
  52802. updatable?: boolean;
  52803. hasRings?: boolean;
  52804. enclose?: boolean;
  52805. sideOrientation?: number;
  52806. frontUVs?: Vector4;
  52807. backUVs?: Vector4;
  52808. }, scene?: Nullable<Scene>): Mesh;
  52809. /**
  52810. * Creates a torus mesh
  52811. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  52812. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  52813. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  52814. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52815. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52816. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52817. * @param name defines the name of the mesh
  52818. * @param options defines the options used to create the mesh
  52819. * @param scene defines the hosting scene
  52820. * @returns the torus mesh
  52821. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  52822. */
  52823. static CreateTorus(name: string, options: {
  52824. diameter?: number;
  52825. thickness?: number;
  52826. tessellation?: number;
  52827. updatable?: boolean;
  52828. sideOrientation?: number;
  52829. frontUVs?: Vector4;
  52830. backUVs?: Vector4;
  52831. }, scene?: Nullable<Scene>): Mesh;
  52832. /**
  52833. * Creates a torus knot mesh
  52834. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  52835. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  52836. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  52837. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  52838. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52839. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52840. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52841. * @param name defines the name of the mesh
  52842. * @param options defines the options used to create the mesh
  52843. * @param scene defines the hosting scene
  52844. * @returns the torus knot mesh
  52845. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  52846. */
  52847. static CreateTorusKnot(name: string, options: {
  52848. radius?: number;
  52849. tube?: number;
  52850. radialSegments?: number;
  52851. tubularSegments?: number;
  52852. p?: number;
  52853. q?: number;
  52854. updatable?: boolean;
  52855. sideOrientation?: number;
  52856. frontUVs?: Vector4;
  52857. backUVs?: Vector4;
  52858. }, scene?: Nullable<Scene>): Mesh;
  52859. /**
  52860. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  52861. * * 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
  52862. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  52863. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  52864. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  52865. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  52866. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  52867. * * 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
  52868. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  52869. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52870. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  52871. * @param name defines the name of the new line system
  52872. * @param options defines the options used to create the line system
  52873. * @param scene defines the hosting scene
  52874. * @returns a new line system mesh
  52875. */
  52876. static CreateLineSystem(name: string, options: {
  52877. lines: Vector3[][];
  52878. updatable?: boolean;
  52879. instance?: Nullable<LinesMesh>;
  52880. colors?: Nullable<Color4[][]>;
  52881. useVertexAlpha?: boolean;
  52882. }, scene: Nullable<Scene>): LinesMesh;
  52883. /**
  52884. * Creates a line mesh
  52885. * 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
  52886. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  52887. * * The parameter `points` is an array successive Vector3
  52888. * * 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
  52889. * * The optional parameter `colors` is an array of successive Color4, one per line point
  52890. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  52891. * * When updating an instance, remember that only point positions can change, not the number of points
  52892. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52893. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  52894. * @param name defines the name of the new line system
  52895. * @param options defines the options used to create the line system
  52896. * @param scene defines the hosting scene
  52897. * @returns a new line mesh
  52898. */
  52899. static CreateLines(name: string, options: {
  52900. points: Vector3[];
  52901. updatable?: boolean;
  52902. instance?: Nullable<LinesMesh>;
  52903. colors?: Color4[];
  52904. useVertexAlpha?: boolean;
  52905. }, scene?: Nullable<Scene>): LinesMesh;
  52906. /**
  52907. * Creates a dashed line mesh
  52908. * * 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
  52909. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  52910. * * The parameter `points` is an array successive Vector3
  52911. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  52912. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  52913. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  52914. * * 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
  52915. * * When updating an instance, remember that only point positions can change, not the number of points
  52916. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52917. * @param name defines the name of the mesh
  52918. * @param options defines the options used to create the mesh
  52919. * @param scene defines the hosting scene
  52920. * @returns the dashed line mesh
  52921. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  52922. */
  52923. static CreateDashedLines(name: string, options: {
  52924. points: Vector3[];
  52925. dashSize?: number;
  52926. gapSize?: number;
  52927. dashNb?: number;
  52928. updatable?: boolean;
  52929. instance?: LinesMesh;
  52930. }, scene?: Nullable<Scene>): LinesMesh;
  52931. /**
  52932. * 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.
  52933. * * 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.
  52934. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52935. * * 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.
  52936. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  52937. * * 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
  52938. * * 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
  52939. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  52940. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52941. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52942. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  52943. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52944. * @param name defines the name of the mesh
  52945. * @param options defines the options used to create the mesh
  52946. * @param scene defines the hosting scene
  52947. * @returns the extruded shape mesh
  52948. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52949. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52950. */
  52951. static ExtrudeShape(name: string, options: {
  52952. shape: Vector3[];
  52953. path: Vector3[];
  52954. scale?: number;
  52955. rotation?: number;
  52956. cap?: number;
  52957. updatable?: boolean;
  52958. sideOrientation?: number;
  52959. frontUVs?: Vector4;
  52960. backUVs?: Vector4;
  52961. instance?: Mesh;
  52962. invertUV?: boolean;
  52963. }, scene?: Nullable<Scene>): Mesh;
  52964. /**
  52965. * Creates an custom extruded shape mesh.
  52966. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  52967. * * 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.
  52968. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52969. * * 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
  52970. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  52971. * * 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
  52972. * * It must returns a float value that will be the scale value applied to the shape on each path point
  52973. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  52974. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  52975. * * 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
  52976. * * 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
  52977. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  52978. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52979. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52980. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52981. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52982. * @param name defines the name of the mesh
  52983. * @param options defines the options used to create the mesh
  52984. * @param scene defines the hosting scene
  52985. * @returns the custom extruded shape mesh
  52986. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  52987. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52988. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52989. */
  52990. static ExtrudeShapeCustom(name: string, options: {
  52991. shape: Vector3[];
  52992. path: Vector3[];
  52993. scaleFunction?: any;
  52994. rotationFunction?: any;
  52995. ribbonCloseArray?: boolean;
  52996. ribbonClosePath?: boolean;
  52997. cap?: number;
  52998. updatable?: boolean;
  52999. sideOrientation?: number;
  53000. frontUVs?: Vector4;
  53001. backUVs?: Vector4;
  53002. instance?: Mesh;
  53003. invertUV?: boolean;
  53004. }, scene?: Nullable<Scene>): Mesh;
  53005. /**
  53006. * Creates lathe mesh.
  53007. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  53008. * * 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
  53009. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  53010. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  53011. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  53012. * * 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
  53013. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  53014. * * 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
  53015. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53016. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53017. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53018. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53019. * @param name defines the name of the mesh
  53020. * @param options defines the options used to create the mesh
  53021. * @param scene defines the hosting scene
  53022. * @returns the lathe mesh
  53023. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  53024. */
  53025. static CreateLathe(name: string, options: {
  53026. shape: Vector3[];
  53027. radius?: number;
  53028. tessellation?: number;
  53029. clip?: number;
  53030. arc?: number;
  53031. closed?: boolean;
  53032. updatable?: boolean;
  53033. sideOrientation?: number;
  53034. frontUVs?: Vector4;
  53035. backUVs?: Vector4;
  53036. cap?: number;
  53037. invertUV?: boolean;
  53038. }, scene?: Nullable<Scene>): Mesh;
  53039. /**
  53040. * Creates a plane mesh
  53041. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  53042. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  53043. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  53044. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53045. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53046. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53047. * @param name defines the name of the mesh
  53048. * @param options defines the options used to create the mesh
  53049. * @param scene defines the hosting scene
  53050. * @returns the plane mesh
  53051. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  53052. */
  53053. static CreatePlane(name: string, options: {
  53054. size?: number;
  53055. width?: number;
  53056. height?: number;
  53057. sideOrientation?: number;
  53058. frontUVs?: Vector4;
  53059. backUVs?: Vector4;
  53060. updatable?: boolean;
  53061. sourcePlane?: Plane;
  53062. }, scene?: Nullable<Scene>): Mesh;
  53063. /**
  53064. * Creates a ground mesh
  53065. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  53066. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  53067. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53068. * @param name defines the name of the mesh
  53069. * @param options defines the options used to create the mesh
  53070. * @param scene defines the hosting scene
  53071. * @returns the ground mesh
  53072. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  53073. */
  53074. static CreateGround(name: string, options: {
  53075. width?: number;
  53076. height?: number;
  53077. subdivisions?: number;
  53078. subdivisionsX?: number;
  53079. subdivisionsY?: number;
  53080. updatable?: boolean;
  53081. }, scene?: Nullable<Scene>): Mesh;
  53082. /**
  53083. * Creates a tiled ground mesh
  53084. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  53085. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  53086. * * 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
  53087. * * 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
  53088. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53089. * @param name defines the name of the mesh
  53090. * @param options defines the options used to create the mesh
  53091. * @param scene defines the hosting scene
  53092. * @returns the tiled ground mesh
  53093. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  53094. */
  53095. static CreateTiledGround(name: string, options: {
  53096. xmin: number;
  53097. zmin: number;
  53098. xmax: number;
  53099. zmax: number;
  53100. subdivisions?: {
  53101. w: number;
  53102. h: number;
  53103. };
  53104. precision?: {
  53105. w: number;
  53106. h: number;
  53107. };
  53108. updatable?: boolean;
  53109. }, scene?: Nullable<Scene>): Mesh;
  53110. /**
  53111. * Creates a ground mesh from a height map
  53112. * * The parameter `url` sets the URL of the height map image resource.
  53113. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  53114. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  53115. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  53116. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  53117. * * 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.
  53118. * * 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).
  53119. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  53120. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53121. * @param name defines the name of the mesh
  53122. * @param url defines the url to the height map
  53123. * @param options defines the options used to create the mesh
  53124. * @param scene defines the hosting scene
  53125. * @returns the ground mesh
  53126. * @see https://doc.babylonjs.com/babylon101/height_map
  53127. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  53128. */
  53129. static CreateGroundFromHeightMap(name: string, url: string, options: {
  53130. width?: number;
  53131. height?: number;
  53132. subdivisions?: number;
  53133. minHeight?: number;
  53134. maxHeight?: number;
  53135. colorFilter?: Color3;
  53136. alphaFilter?: number;
  53137. updatable?: boolean;
  53138. onReady?: (mesh: GroundMesh) => void;
  53139. }, scene?: Nullable<Scene>): GroundMesh;
  53140. /**
  53141. * Creates a polygon mesh
  53142. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  53143. * * 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
  53144. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  53145. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53146. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  53147. * * Remember you can only change the shape positions, not their number when updating a polygon
  53148. * @param name defines the name of the mesh
  53149. * @param options defines the options used to create the mesh
  53150. * @param scene defines the hosting scene
  53151. * @param earcutInjection can be used to inject your own earcut reference
  53152. * @returns the polygon mesh
  53153. */
  53154. static CreatePolygon(name: string, options: {
  53155. shape: Vector3[];
  53156. holes?: Vector3[][];
  53157. depth?: number;
  53158. faceUV?: Vector4[];
  53159. faceColors?: Color4[];
  53160. updatable?: boolean;
  53161. sideOrientation?: number;
  53162. frontUVs?: Vector4;
  53163. backUVs?: Vector4;
  53164. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  53165. /**
  53166. * Creates an extruded polygon mesh, with depth in the Y direction.
  53167. * * 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)
  53168. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  53169. * @param name defines the name of the mesh
  53170. * @param options defines the options used to create the mesh
  53171. * @param scene defines the hosting scene
  53172. * @param earcutInjection can be used to inject your own earcut reference
  53173. * @returns the polygon mesh
  53174. */
  53175. static ExtrudePolygon(name: string, options: {
  53176. shape: Vector3[];
  53177. holes?: Vector3[][];
  53178. depth?: number;
  53179. faceUV?: Vector4[];
  53180. faceColors?: Color4[];
  53181. updatable?: boolean;
  53182. sideOrientation?: number;
  53183. frontUVs?: Vector4;
  53184. backUVs?: Vector4;
  53185. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  53186. /**
  53187. * Creates a tube mesh.
  53188. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  53189. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  53190. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  53191. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  53192. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  53193. * * 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)
  53194. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  53195. * * 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
  53196. * * 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
  53197. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53198. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53199. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53200. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53201. * @param name defines the name of the mesh
  53202. * @param options defines the options used to create the mesh
  53203. * @param scene defines the hosting scene
  53204. * @returns the tube mesh
  53205. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53206. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  53207. */
  53208. static CreateTube(name: string, options: {
  53209. path: Vector3[];
  53210. radius?: number;
  53211. tessellation?: number;
  53212. radiusFunction?: {
  53213. (i: number, distance: number): number;
  53214. };
  53215. cap?: number;
  53216. arc?: number;
  53217. updatable?: boolean;
  53218. sideOrientation?: number;
  53219. frontUVs?: Vector4;
  53220. backUVs?: Vector4;
  53221. instance?: Mesh;
  53222. invertUV?: boolean;
  53223. }, scene?: Nullable<Scene>): Mesh;
  53224. /**
  53225. * Creates a polyhedron mesh
  53226. * * 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
  53227. * * The parameter `size` (positive float, default 1) sets the polygon size
  53228. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  53229. * * 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`
  53230. * * 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
  53231. * * 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)`)
  53232. * * 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
  53233. * * 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
  53234. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53235. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53236. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53237. * @param name defines the name of the mesh
  53238. * @param options defines the options used to create the mesh
  53239. * @param scene defines the hosting scene
  53240. * @returns the polyhedron mesh
  53241. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  53242. */
  53243. static CreatePolyhedron(name: string, options: {
  53244. type?: number;
  53245. size?: number;
  53246. sizeX?: number;
  53247. sizeY?: number;
  53248. sizeZ?: number;
  53249. custom?: any;
  53250. faceUV?: Vector4[];
  53251. faceColors?: Color4[];
  53252. flat?: boolean;
  53253. updatable?: boolean;
  53254. sideOrientation?: number;
  53255. frontUVs?: Vector4;
  53256. backUVs?: Vector4;
  53257. }, scene?: Nullable<Scene>): Mesh;
  53258. /**
  53259. * Creates a decal mesh.
  53260. * 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
  53261. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  53262. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  53263. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  53264. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  53265. * @param name defines the name of the mesh
  53266. * @param sourceMesh defines the mesh where the decal must be applied
  53267. * @param options defines the options used to create the mesh
  53268. * @param scene defines the hosting scene
  53269. * @returns the decal mesh
  53270. * @see https://doc.babylonjs.com/how_to/decals
  53271. */
  53272. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  53273. position?: Vector3;
  53274. normal?: Vector3;
  53275. size?: Vector3;
  53276. angle?: number;
  53277. }): Mesh;
  53278. }
  53279. }
  53280. declare module "babylonjs/Meshes/meshSimplification" {
  53281. import { Mesh } from "babylonjs/Meshes/mesh";
  53282. /**
  53283. * A simplifier interface for future simplification implementations
  53284. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53285. */
  53286. export interface ISimplifier {
  53287. /**
  53288. * Simplification of a given mesh according to the given settings.
  53289. * Since this requires computation, it is assumed that the function runs async.
  53290. * @param settings The settings of the simplification, including quality and distance
  53291. * @param successCallback A callback that will be called after the mesh was simplified.
  53292. * @param errorCallback in case of an error, this callback will be called. optional.
  53293. */
  53294. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  53295. }
  53296. /**
  53297. * Expected simplification settings.
  53298. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  53299. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53300. */
  53301. export interface ISimplificationSettings {
  53302. /**
  53303. * Gets or sets the expected quality
  53304. */
  53305. quality: number;
  53306. /**
  53307. * Gets or sets the distance when this optimized version should be used
  53308. */
  53309. distance: number;
  53310. /**
  53311. * Gets an already optimized mesh
  53312. */
  53313. optimizeMesh?: boolean;
  53314. }
  53315. /**
  53316. * Class used to specify simplification options
  53317. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53318. */
  53319. export class SimplificationSettings implements ISimplificationSettings {
  53320. /** expected quality */
  53321. quality: number;
  53322. /** distance when this optimized version should be used */
  53323. distance: number;
  53324. /** already optimized mesh */
  53325. optimizeMesh?: boolean | undefined;
  53326. /**
  53327. * Creates a SimplificationSettings
  53328. * @param quality expected quality
  53329. * @param distance distance when this optimized version should be used
  53330. * @param optimizeMesh already optimized mesh
  53331. */
  53332. constructor(
  53333. /** expected quality */
  53334. quality: number,
  53335. /** distance when this optimized version should be used */
  53336. distance: number,
  53337. /** already optimized mesh */
  53338. optimizeMesh?: boolean | undefined);
  53339. }
  53340. /**
  53341. * Interface used to define a simplification task
  53342. */
  53343. export interface ISimplificationTask {
  53344. /**
  53345. * Array of settings
  53346. */
  53347. settings: Array<ISimplificationSettings>;
  53348. /**
  53349. * Simplification type
  53350. */
  53351. simplificationType: SimplificationType;
  53352. /**
  53353. * Mesh to simplify
  53354. */
  53355. mesh: Mesh;
  53356. /**
  53357. * Callback called on success
  53358. */
  53359. successCallback?: () => void;
  53360. /**
  53361. * Defines if parallel processing can be used
  53362. */
  53363. parallelProcessing: boolean;
  53364. }
  53365. /**
  53366. * Queue used to order the simplification tasks
  53367. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53368. */
  53369. export class SimplificationQueue {
  53370. private _simplificationArray;
  53371. /**
  53372. * Gets a boolean indicating that the process is still running
  53373. */
  53374. running: boolean;
  53375. /**
  53376. * Creates a new queue
  53377. */
  53378. constructor();
  53379. /**
  53380. * Adds a new simplification task
  53381. * @param task defines a task to add
  53382. */
  53383. addTask(task: ISimplificationTask): void;
  53384. /**
  53385. * Execute next task
  53386. */
  53387. executeNext(): void;
  53388. /**
  53389. * Execute a simplification task
  53390. * @param task defines the task to run
  53391. */
  53392. runSimplification(task: ISimplificationTask): void;
  53393. private getSimplifier;
  53394. }
  53395. /**
  53396. * The implemented types of simplification
  53397. * At the moment only Quadratic Error Decimation is implemented
  53398. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53399. */
  53400. export enum SimplificationType {
  53401. /** Quadratic error decimation */
  53402. QUADRATIC = 0
  53403. }
  53404. }
  53405. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  53406. import { Scene } from "babylonjs/scene";
  53407. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  53408. import { ISceneComponent } from "babylonjs/sceneComponent";
  53409. module "babylonjs/scene" {
  53410. interface Scene {
  53411. /** @hidden (Backing field) */
  53412. _simplificationQueue: SimplificationQueue;
  53413. /**
  53414. * Gets or sets the simplification queue attached to the scene
  53415. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53416. */
  53417. simplificationQueue: SimplificationQueue;
  53418. }
  53419. }
  53420. module "babylonjs/Meshes/mesh" {
  53421. interface Mesh {
  53422. /**
  53423. * Simplify the mesh according to the given array of settings.
  53424. * Function will return immediately and will simplify async
  53425. * @param settings a collection of simplification settings
  53426. * @param parallelProcessing should all levels calculate parallel or one after the other
  53427. * @param simplificationType the type of simplification to run
  53428. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  53429. * @returns the current mesh
  53430. */
  53431. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  53432. }
  53433. }
  53434. /**
  53435. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  53436. * created in a scene
  53437. */
  53438. export class SimplicationQueueSceneComponent implements ISceneComponent {
  53439. /**
  53440. * The component name helpfull to identify the component in the list of scene components.
  53441. */
  53442. readonly name: string;
  53443. /**
  53444. * The scene the component belongs to.
  53445. */
  53446. scene: Scene;
  53447. /**
  53448. * Creates a new instance of the component for the given scene
  53449. * @param scene Defines the scene to register the component in
  53450. */
  53451. constructor(scene: Scene);
  53452. /**
  53453. * Registers the component in a given scene
  53454. */
  53455. register(): void;
  53456. /**
  53457. * Rebuilds the elements related to this component in case of
  53458. * context lost for instance.
  53459. */
  53460. rebuild(): void;
  53461. /**
  53462. * Disposes the component and the associated ressources
  53463. */
  53464. dispose(): void;
  53465. private _beforeCameraUpdate;
  53466. }
  53467. }
  53468. declare module "babylonjs/Meshes/Builders/index" {
  53469. export * from "babylonjs/Meshes/Builders/boxBuilder";
  53470. export * from "babylonjs/Meshes/Builders/discBuilder";
  53471. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  53472. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  53473. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  53474. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  53475. export * from "babylonjs/Meshes/Builders/torusBuilder";
  53476. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  53477. export * from "babylonjs/Meshes/Builders/linesBuilder";
  53478. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  53479. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  53480. export * from "babylonjs/Meshes/Builders/latheBuilder";
  53481. export * from "babylonjs/Meshes/Builders/planeBuilder";
  53482. export * from "babylonjs/Meshes/Builders/groundBuilder";
  53483. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  53484. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  53485. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  53486. export * from "babylonjs/Meshes/Builders/decalBuilder";
  53487. }
  53488. declare module "babylonjs/Meshes/index" {
  53489. export * from "babylonjs/Meshes/abstractMesh";
  53490. export * from "babylonjs/Meshes/buffer";
  53491. export * from "babylonjs/Meshes/Compression/index";
  53492. export * from "babylonjs/Meshes/csg";
  53493. export * from "babylonjs/Meshes/geometry";
  53494. export * from "babylonjs/Meshes/groundMesh";
  53495. export * from "babylonjs/Meshes/trailMesh";
  53496. export * from "babylonjs/Meshes/instancedMesh";
  53497. export * from "babylonjs/Meshes/linesMesh";
  53498. export * from "babylonjs/Meshes/mesh";
  53499. export * from "babylonjs/Meshes/mesh.vertexData";
  53500. export * from "babylonjs/Meshes/meshBuilder";
  53501. export * from "babylonjs/Meshes/meshSimplification";
  53502. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  53503. export * from "babylonjs/Meshes/polygonMesh";
  53504. export * from "babylonjs/Meshes/subMesh";
  53505. export * from "babylonjs/Meshes/meshLODLevel";
  53506. export * from "babylonjs/Meshes/transformNode";
  53507. export * from "babylonjs/Meshes/Builders/index";
  53508. export * from "babylonjs/Meshes/dataBuffer";
  53509. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  53510. }
  53511. declare module "babylonjs/Morph/index" {
  53512. export * from "babylonjs/Morph/morphTarget";
  53513. export * from "babylonjs/Morph/morphTargetManager";
  53514. }
  53515. declare module "babylonjs/Offline/database" {
  53516. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  53517. /**
  53518. * Class used to enable access to IndexedDB
  53519. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  53520. */
  53521. export class Database implements IOfflineProvider {
  53522. private _callbackManifestChecked;
  53523. private _currentSceneUrl;
  53524. private _db;
  53525. private _enableSceneOffline;
  53526. private _enableTexturesOffline;
  53527. private _manifestVersionFound;
  53528. private _mustUpdateRessources;
  53529. private _hasReachedQuota;
  53530. private _isSupported;
  53531. private _idbFactory;
  53532. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  53533. private static IsUASupportingBlobStorage;
  53534. /**
  53535. * Gets a boolean indicating if Database storate is enabled (off by default)
  53536. */
  53537. static IDBStorageEnabled: boolean;
  53538. /**
  53539. * Gets a boolean indicating if scene must be saved in the database
  53540. */
  53541. readonly enableSceneOffline: boolean;
  53542. /**
  53543. * Gets a boolean indicating if textures must be saved in the database
  53544. */
  53545. readonly enableTexturesOffline: boolean;
  53546. /**
  53547. * Creates a new Database
  53548. * @param urlToScene defines the url to load the scene
  53549. * @param callbackManifestChecked defines the callback to use when manifest is checked
  53550. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  53551. */
  53552. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  53553. private static _ParseURL;
  53554. private static _ReturnFullUrlLocation;
  53555. private _checkManifestFile;
  53556. /**
  53557. * Open the database and make it available
  53558. * @param successCallback defines the callback to call on success
  53559. * @param errorCallback defines the callback to call on error
  53560. */
  53561. open(successCallback: () => void, errorCallback: () => void): void;
  53562. /**
  53563. * Loads an image from the database
  53564. * @param url defines the url to load from
  53565. * @param image defines the target DOM image
  53566. */
  53567. loadImage(url: string, image: HTMLImageElement): void;
  53568. private _loadImageFromDBAsync;
  53569. private _saveImageIntoDBAsync;
  53570. private _checkVersionFromDB;
  53571. private _loadVersionFromDBAsync;
  53572. private _saveVersionIntoDBAsync;
  53573. /**
  53574. * Loads a file from database
  53575. * @param url defines the URL to load from
  53576. * @param sceneLoaded defines a callback to call on success
  53577. * @param progressCallBack defines a callback to call when progress changed
  53578. * @param errorCallback defines a callback to call on error
  53579. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  53580. */
  53581. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  53582. private _loadFileAsync;
  53583. private _saveFileAsync;
  53584. /**
  53585. * Validates if xhr data is correct
  53586. * @param xhr defines the request to validate
  53587. * @param dataType defines the expected data type
  53588. * @returns true if data is correct
  53589. */
  53590. private static _ValidateXHRData;
  53591. }
  53592. }
  53593. declare module "babylonjs/Offline/index" {
  53594. export * from "babylonjs/Offline/database";
  53595. export * from "babylonjs/Offline/IOfflineProvider";
  53596. }
  53597. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  53598. /** @hidden */
  53599. export var gpuUpdateParticlesPixelShader: {
  53600. name: string;
  53601. shader: string;
  53602. };
  53603. }
  53604. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  53605. /** @hidden */
  53606. export var gpuUpdateParticlesVertexShader: {
  53607. name: string;
  53608. shader: string;
  53609. };
  53610. }
  53611. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  53612. /** @hidden */
  53613. export var clipPlaneFragmentDeclaration2: {
  53614. name: string;
  53615. shader: string;
  53616. };
  53617. }
  53618. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  53619. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  53620. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  53621. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53622. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  53623. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  53624. /** @hidden */
  53625. export var gpuRenderParticlesPixelShader: {
  53626. name: string;
  53627. shader: string;
  53628. };
  53629. }
  53630. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  53631. /** @hidden */
  53632. export var clipPlaneVertexDeclaration2: {
  53633. name: string;
  53634. shader: string;
  53635. };
  53636. }
  53637. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  53638. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  53639. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  53640. /** @hidden */
  53641. export var gpuRenderParticlesVertexShader: {
  53642. name: string;
  53643. shader: string;
  53644. };
  53645. }
  53646. declare module "babylonjs/Particles/gpuParticleSystem" {
  53647. import { Nullable } from "babylonjs/types";
  53648. import { IAnimatable, IValueGradient, Color3Gradient } from "babylonjs/Misc/tools";
  53649. import { Observable } from "babylonjs/Misc/observable";
  53650. import { Color4, Color3 } from "babylonjs/Maths/math";
  53651. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  53652. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  53653. import { Scene, IDisposable } from "babylonjs/scene";
  53654. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  53655. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  53656. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  53657. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  53658. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  53659. /**
  53660. * This represents a GPU particle system in Babylon
  53661. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  53662. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  53663. */
  53664. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  53665. /**
  53666. * The layer mask we are rendering the particles through.
  53667. */
  53668. layerMask: number;
  53669. private _capacity;
  53670. private _activeCount;
  53671. private _currentActiveCount;
  53672. private _accumulatedCount;
  53673. private _renderEffect;
  53674. private _updateEffect;
  53675. private _buffer0;
  53676. private _buffer1;
  53677. private _spriteBuffer;
  53678. private _updateVAO;
  53679. private _renderVAO;
  53680. private _targetIndex;
  53681. private _sourceBuffer;
  53682. private _targetBuffer;
  53683. private _engine;
  53684. private _currentRenderId;
  53685. private _started;
  53686. private _stopped;
  53687. private _timeDelta;
  53688. private _randomTexture;
  53689. private _randomTexture2;
  53690. private _attributesStrideSize;
  53691. private _updateEffectOptions;
  53692. private _randomTextureSize;
  53693. private _actualFrame;
  53694. private readonly _rawTextureWidth;
  53695. /**
  53696. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  53697. */
  53698. static readonly IsSupported: boolean;
  53699. /**
  53700. * An event triggered when the system is disposed.
  53701. */
  53702. onDisposeObservable: Observable<GPUParticleSystem>;
  53703. /**
  53704. * Gets the maximum number of particles active at the same time.
  53705. * @returns The max number of active particles.
  53706. */
  53707. getCapacity(): number;
  53708. /**
  53709. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  53710. * to override the particles.
  53711. */
  53712. forceDepthWrite: boolean;
  53713. /**
  53714. * Gets or set the number of active particles
  53715. */
  53716. activeParticleCount: number;
  53717. private _preWarmDone;
  53718. /**
  53719. * Is this system ready to be used/rendered
  53720. * @return true if the system is ready
  53721. */
  53722. isReady(): boolean;
  53723. /**
  53724. * Gets if the system has been started. (Note: this will still be true after stop is called)
  53725. * @returns True if it has been started, otherwise false.
  53726. */
  53727. isStarted(): boolean;
  53728. /**
  53729. * Starts the particle system and begins to emit
  53730. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  53731. */
  53732. start(delay?: number): void;
  53733. /**
  53734. * Stops the particle system.
  53735. */
  53736. stop(): void;
  53737. /**
  53738. * Remove all active particles
  53739. */
  53740. reset(): void;
  53741. /**
  53742. * Returns the string "GPUParticleSystem"
  53743. * @returns a string containing the class name
  53744. */
  53745. getClassName(): string;
  53746. private _colorGradientsTexture;
  53747. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  53748. /**
  53749. * Adds a new color gradient
  53750. * @param gradient defines the gradient to use (between 0 and 1)
  53751. * @param color1 defines the color to affect to the specified gradient
  53752. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  53753. * @returns the current particle system
  53754. */
  53755. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  53756. /**
  53757. * Remove a specific color gradient
  53758. * @param gradient defines the gradient to remove
  53759. * @returns the current particle system
  53760. */
  53761. removeColorGradient(gradient: number): GPUParticleSystem;
  53762. private _angularSpeedGradientsTexture;
  53763. private _sizeGradientsTexture;
  53764. private _velocityGradientsTexture;
  53765. private _limitVelocityGradientsTexture;
  53766. private _dragGradientsTexture;
  53767. private _addFactorGradient;
  53768. /**
  53769. * Adds a new size gradient
  53770. * @param gradient defines the gradient to use (between 0 and 1)
  53771. * @param factor defines the size factor to affect to the specified gradient
  53772. * @returns the current particle system
  53773. */
  53774. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  53775. /**
  53776. * Remove a specific size gradient
  53777. * @param gradient defines the gradient to remove
  53778. * @returns the current particle system
  53779. */
  53780. removeSizeGradient(gradient: number): GPUParticleSystem;
  53781. /**
  53782. * Adds a new angular speed gradient
  53783. * @param gradient defines the gradient to use (between 0 and 1)
  53784. * @param factor defines the angular speed to affect to the specified gradient
  53785. * @returns the current particle system
  53786. */
  53787. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  53788. /**
  53789. * Remove a specific angular speed gradient
  53790. * @param gradient defines the gradient to remove
  53791. * @returns the current particle system
  53792. */
  53793. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  53794. /**
  53795. * Adds a new velocity gradient
  53796. * @param gradient defines the gradient to use (between 0 and 1)
  53797. * @param factor defines the velocity to affect to the specified gradient
  53798. * @returns the current particle system
  53799. */
  53800. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  53801. /**
  53802. * Remove a specific velocity gradient
  53803. * @param gradient defines the gradient to remove
  53804. * @returns the current particle system
  53805. */
  53806. removeVelocityGradient(gradient: number): GPUParticleSystem;
  53807. /**
  53808. * Adds a new limit velocity gradient
  53809. * @param gradient defines the gradient to use (between 0 and 1)
  53810. * @param factor defines the limit velocity value to affect to the specified gradient
  53811. * @returns the current particle system
  53812. */
  53813. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  53814. /**
  53815. * Remove a specific limit velocity gradient
  53816. * @param gradient defines the gradient to remove
  53817. * @returns the current particle system
  53818. */
  53819. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  53820. /**
  53821. * Adds a new drag gradient
  53822. * @param gradient defines the gradient to use (between 0 and 1)
  53823. * @param factor defines the drag value to affect to the specified gradient
  53824. * @returns the current particle system
  53825. */
  53826. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  53827. /**
  53828. * Remove a specific drag gradient
  53829. * @param gradient defines the gradient to remove
  53830. * @returns the current particle system
  53831. */
  53832. removeDragGradient(gradient: number): GPUParticleSystem;
  53833. /**
  53834. * Not supported by GPUParticleSystem
  53835. * @param gradient defines the gradient to use (between 0 and 1)
  53836. * @param factor defines the emit rate value to affect to the specified gradient
  53837. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  53838. * @returns the current particle system
  53839. */
  53840. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  53841. /**
  53842. * Not supported by GPUParticleSystem
  53843. * @param gradient defines the gradient to remove
  53844. * @returns the current particle system
  53845. */
  53846. removeEmitRateGradient(gradient: number): IParticleSystem;
  53847. /**
  53848. * Not supported by GPUParticleSystem
  53849. * @param gradient defines the gradient to use (between 0 and 1)
  53850. * @param factor defines the start size value to affect to the specified gradient
  53851. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  53852. * @returns the current particle system
  53853. */
  53854. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  53855. /**
  53856. * Not supported by GPUParticleSystem
  53857. * @param gradient defines the gradient to remove
  53858. * @returns the current particle system
  53859. */
  53860. removeStartSizeGradient(gradient: number): IParticleSystem;
  53861. /**
  53862. * Not supported by GPUParticleSystem
  53863. * @param gradient defines the gradient to use (between 0 and 1)
  53864. * @param min defines the color remap minimal range
  53865. * @param max defines the color remap maximal range
  53866. * @returns the current particle system
  53867. */
  53868. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  53869. /**
  53870. * Not supported by GPUParticleSystem
  53871. * @param gradient defines the gradient to remove
  53872. * @returns the current particle system
  53873. */
  53874. removeColorRemapGradient(): IParticleSystem;
  53875. /**
  53876. * Not supported by GPUParticleSystem
  53877. * @param gradient defines the gradient to use (between 0 and 1)
  53878. * @param min defines the alpha remap minimal range
  53879. * @param max defines the alpha remap maximal range
  53880. * @returns the current particle system
  53881. */
  53882. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  53883. /**
  53884. * Not supported by GPUParticleSystem
  53885. * @param gradient defines the gradient to remove
  53886. * @returns the current particle system
  53887. */
  53888. removeAlphaRemapGradient(): IParticleSystem;
  53889. /**
  53890. * Not supported by GPUParticleSystem
  53891. * @param gradient defines the gradient to use (between 0 and 1)
  53892. * @param color defines the color to affect to the specified gradient
  53893. * @returns the current particle system
  53894. */
  53895. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  53896. /**
  53897. * Not supported by GPUParticleSystem
  53898. * @param gradient defines the gradient to remove
  53899. * @returns the current particle system
  53900. */
  53901. removeRampGradient(): IParticleSystem;
  53902. /**
  53903. * Not supported by GPUParticleSystem
  53904. * @returns the list of ramp gradients
  53905. */
  53906. getRampGradients(): Nullable<Array<Color3Gradient>>;
  53907. /**
  53908. * Not supported by GPUParticleSystem
  53909. * Gets or sets a boolean indicating that ramp gradients must be used
  53910. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  53911. */
  53912. useRampGradients: boolean;
  53913. /**
  53914. * Not supported by GPUParticleSystem
  53915. * @param gradient defines the gradient to use (between 0 and 1)
  53916. * @param factor defines the life time factor to affect to the specified gradient
  53917. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  53918. * @returns the current particle system
  53919. */
  53920. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  53921. /**
  53922. * Not supported by GPUParticleSystem
  53923. * @param gradient defines the gradient to remove
  53924. * @returns the current particle system
  53925. */
  53926. removeLifeTimeGradient(gradient: number): IParticleSystem;
  53927. /**
  53928. * Instantiates a GPU particle system.
  53929. * 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.
  53930. * @param name The name of the particle system
  53931. * @param options The options used to create the system
  53932. * @param scene The scene the particle system belongs to
  53933. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  53934. */
  53935. constructor(name: string, options: Partial<{
  53936. capacity: number;
  53937. randomTextureSize: number;
  53938. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  53939. protected _reset(): void;
  53940. private _createUpdateVAO;
  53941. private _createRenderVAO;
  53942. private _initialize;
  53943. /** @hidden */
  53944. _recreateUpdateEffect(): void;
  53945. /** @hidden */
  53946. _recreateRenderEffect(): void;
  53947. /**
  53948. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  53949. * @param preWarm defines if we are in the pre-warmimg phase
  53950. */
  53951. animate(preWarm?: boolean): void;
  53952. private _createFactorGradientTexture;
  53953. private _createSizeGradientTexture;
  53954. private _createAngularSpeedGradientTexture;
  53955. private _createVelocityGradientTexture;
  53956. private _createLimitVelocityGradientTexture;
  53957. private _createDragGradientTexture;
  53958. private _createColorGradientTexture;
  53959. /**
  53960. * Renders the particle system in its current state
  53961. * @param preWarm defines if the system should only update the particles but not render them
  53962. * @returns the current number of particles
  53963. */
  53964. render(preWarm?: boolean): number;
  53965. /**
  53966. * Rebuilds the particle system
  53967. */
  53968. rebuild(): void;
  53969. private _releaseBuffers;
  53970. private _releaseVAOs;
  53971. /**
  53972. * Disposes the particle system and free the associated resources
  53973. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  53974. */
  53975. dispose(disposeTexture?: boolean): void;
  53976. /**
  53977. * Clones the particle system.
  53978. * @param name The name of the cloned object
  53979. * @param newEmitter The new emitter to use
  53980. * @returns the cloned particle system
  53981. */
  53982. clone(name: string, newEmitter: any): GPUParticleSystem;
  53983. /**
  53984. * Serializes the particle system to a JSON object.
  53985. * @returns the JSON object
  53986. */
  53987. serialize(): any;
  53988. /**
  53989. * Parses a JSON object to create a GPU particle system.
  53990. * @param parsedParticleSystem The JSON object to parse
  53991. * @param scene The scene to create the particle system in
  53992. * @param rootUrl The root url to use to load external dependencies like texture
  53993. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  53994. * @returns the parsed GPU particle system
  53995. */
  53996. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  53997. }
  53998. }
  53999. declare module "babylonjs/Particles/particleSystemSet" {
  54000. import { Nullable } from "babylonjs/types";
  54001. import { Color3 } from "babylonjs/Maths/math";
  54002. import { TransformNode } from "babylonjs/Meshes/transformNode";
  54003. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54004. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  54005. import { Scene, IDisposable } from "babylonjs/scene";
  54006. /**
  54007. * Represents a set of particle systems working together to create a specific effect
  54008. */
  54009. export class ParticleSystemSet implements IDisposable {
  54010. private _emitterCreationOptions;
  54011. private _emitterNode;
  54012. /**
  54013. * Gets the particle system list
  54014. */
  54015. systems: IParticleSystem[];
  54016. /**
  54017. * Gets the emitter node used with this set
  54018. */
  54019. readonly emitterNode: Nullable<TransformNode>;
  54020. /**
  54021. * Creates a new emitter mesh as a sphere
  54022. * @param options defines the options used to create the sphere
  54023. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  54024. * @param scene defines the hosting scene
  54025. */
  54026. setEmitterAsSphere(options: {
  54027. diameter: number;
  54028. segments: number;
  54029. color: Color3;
  54030. }, renderingGroupId: number, scene: Scene): void;
  54031. /**
  54032. * Starts all particle systems of the set
  54033. * @param emitter defines an optional mesh to use as emitter for the particle systems
  54034. */
  54035. start(emitter?: AbstractMesh): void;
  54036. /**
  54037. * Release all associated resources
  54038. */
  54039. dispose(): void;
  54040. /**
  54041. * Serialize the set into a JSON compatible object
  54042. * @returns a JSON compatible representation of the set
  54043. */
  54044. serialize(): any;
  54045. /**
  54046. * Parse a new ParticleSystemSet from a serialized source
  54047. * @param data defines a JSON compatible representation of the set
  54048. * @param scene defines the hosting scene
  54049. * @param gpu defines if we want GPU particles or CPU particles
  54050. * @returns a new ParticleSystemSet
  54051. */
  54052. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  54053. }
  54054. }
  54055. declare module "babylonjs/Particles/particleHelper" {
  54056. import { Nullable } from "babylonjs/types";
  54057. import { Scene } from "babylonjs/scene";
  54058. import { Vector3 } from "babylonjs/Maths/math";
  54059. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54060. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  54061. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  54062. /**
  54063. * This class is made for on one-liner static method to help creating particle system set.
  54064. */
  54065. export class ParticleHelper {
  54066. /**
  54067. * Gets or sets base Assets URL
  54068. */
  54069. static BaseAssetsUrl: string;
  54070. /**
  54071. * Create a default particle system that you can tweak
  54072. * @param emitter defines the emitter to use
  54073. * @param capacity defines the system capacity (default is 500 particles)
  54074. * @param scene defines the hosting scene
  54075. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  54076. * @returns the new Particle system
  54077. */
  54078. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  54079. /**
  54080. * This is the main static method (one-liner) of this helper to create different particle systems
  54081. * @param type This string represents the type to the particle system to create
  54082. * @param scene The scene where the particle system should live
  54083. * @param gpu If the system will use gpu
  54084. * @returns the ParticleSystemSet created
  54085. */
  54086. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  54087. /**
  54088. * Static function used to export a particle system to a ParticleSystemSet variable.
  54089. * Please note that the emitter shape is not exported
  54090. * @param systems defines the particle systems to export
  54091. * @returns the created particle system set
  54092. */
  54093. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  54094. }
  54095. }
  54096. declare module "babylonjs/Particles/particleSystemComponent" {
  54097. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  54098. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  54099. import "babylonjs/Shaders/particles.vertex";
  54100. module "babylonjs/Engines/engine" {
  54101. interface Engine {
  54102. /**
  54103. * Create an effect to use with particle systems.
  54104. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  54105. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  54106. * @param uniformsNames defines a list of attribute names
  54107. * @param samplers defines an array of string used to represent textures
  54108. * @param defines defines the string containing the defines to use to compile the shaders
  54109. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  54110. * @param onCompiled defines a function to call when the effect creation is successful
  54111. * @param onError defines a function to call when the effect creation has failed
  54112. * @returns the new Effect
  54113. */
  54114. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  54115. }
  54116. }
  54117. module "babylonjs/Meshes/mesh" {
  54118. interface Mesh {
  54119. /**
  54120. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  54121. * @returns an array of IParticleSystem
  54122. */
  54123. getEmittedParticleSystems(): IParticleSystem[];
  54124. /**
  54125. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  54126. * @returns an array of IParticleSystem
  54127. */
  54128. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  54129. }
  54130. }
  54131. /**
  54132. * @hidden
  54133. */
  54134. export var _IDoNeedToBeInTheBuild: number;
  54135. }
  54136. declare module "babylonjs/Particles/index" {
  54137. export * from "babylonjs/Particles/baseParticleSystem";
  54138. export * from "babylonjs/Particles/EmitterTypes/index";
  54139. export * from "babylonjs/Particles/gpuParticleSystem";
  54140. export * from "babylonjs/Particles/IParticleSystem";
  54141. export * from "babylonjs/Particles/particle";
  54142. export * from "babylonjs/Particles/particleHelper";
  54143. export * from "babylonjs/Particles/particleSystem";
  54144. export * from "babylonjs/Particles/particleSystemComponent";
  54145. export * from "babylonjs/Particles/particleSystemSet";
  54146. export * from "babylonjs/Particles/solidParticle";
  54147. export * from "babylonjs/Particles/solidParticleSystem";
  54148. export * from "babylonjs/Particles/subEmitter";
  54149. }
  54150. declare module "babylonjs/Physics/physicsEngineComponent" {
  54151. import { Nullable } from "babylonjs/types";
  54152. import { Observable, Observer } from "babylonjs/Misc/observable";
  54153. import { Vector3 } from "babylonjs/Maths/math";
  54154. import { Mesh } from "babylonjs/Meshes/mesh";
  54155. import { ISceneComponent } from "babylonjs/sceneComponent";
  54156. import { Scene } from "babylonjs/scene";
  54157. import { Node } from "babylonjs/node";
  54158. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  54159. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  54160. module "babylonjs/scene" {
  54161. interface Scene {
  54162. /** @hidden (Backing field) */
  54163. _physicsEngine: Nullable<IPhysicsEngine>;
  54164. /**
  54165. * Gets the current physics engine
  54166. * @returns a IPhysicsEngine or null if none attached
  54167. */
  54168. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  54169. /**
  54170. * Enables physics to the current scene
  54171. * @param gravity defines the scene's gravity for the physics engine
  54172. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  54173. * @return a boolean indicating if the physics engine was initialized
  54174. */
  54175. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  54176. /**
  54177. * Disables and disposes the physics engine associated with the scene
  54178. */
  54179. disablePhysicsEngine(): void;
  54180. /**
  54181. * Gets a boolean indicating if there is an active physics engine
  54182. * @returns a boolean indicating if there is an active physics engine
  54183. */
  54184. isPhysicsEnabled(): boolean;
  54185. /**
  54186. * Deletes a physics compound impostor
  54187. * @param compound defines the compound to delete
  54188. */
  54189. deleteCompoundImpostor(compound: any): void;
  54190. /**
  54191. * An event triggered when physic simulation is about to be run
  54192. */
  54193. onBeforePhysicsObservable: Observable<Scene>;
  54194. /**
  54195. * An event triggered when physic simulation has been done
  54196. */
  54197. onAfterPhysicsObservable: Observable<Scene>;
  54198. }
  54199. }
  54200. module "babylonjs/Meshes/abstractMesh" {
  54201. interface AbstractMesh {
  54202. /** @hidden */
  54203. _physicsImpostor: Nullable<PhysicsImpostor>;
  54204. /**
  54205. * Gets or sets impostor used for physic simulation
  54206. * @see http://doc.babylonjs.com/features/physics_engine
  54207. */
  54208. physicsImpostor: Nullable<PhysicsImpostor>;
  54209. /**
  54210. * Gets the current physics impostor
  54211. * @see http://doc.babylonjs.com/features/physics_engine
  54212. * @returns a physics impostor or null
  54213. */
  54214. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  54215. /** Apply a physic impulse to the mesh
  54216. * @param force defines the force to apply
  54217. * @param contactPoint defines where to apply the force
  54218. * @returns the current mesh
  54219. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  54220. */
  54221. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  54222. /**
  54223. * Creates a physic joint between two meshes
  54224. * @param otherMesh defines the other mesh to use
  54225. * @param pivot1 defines the pivot to use on this mesh
  54226. * @param pivot2 defines the pivot to use on the other mesh
  54227. * @param options defines additional options (can be plugin dependent)
  54228. * @returns the current mesh
  54229. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  54230. */
  54231. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  54232. /** @hidden */
  54233. _disposePhysicsObserver: Nullable<Observer<Node>>;
  54234. }
  54235. }
  54236. /**
  54237. * Defines the physics engine scene component responsible to manage a physics engine
  54238. */
  54239. export class PhysicsEngineSceneComponent implements ISceneComponent {
  54240. /**
  54241. * The component name helpful to identify the component in the list of scene components.
  54242. */
  54243. readonly name: string;
  54244. /**
  54245. * The scene the component belongs to.
  54246. */
  54247. scene: Scene;
  54248. /**
  54249. * Creates a new instance of the component for the given scene
  54250. * @param scene Defines the scene to register the component in
  54251. */
  54252. constructor(scene: Scene);
  54253. /**
  54254. * Registers the component in a given scene
  54255. */
  54256. register(): void;
  54257. /**
  54258. * Rebuilds the elements related to this component in case of
  54259. * context lost for instance.
  54260. */
  54261. rebuild(): void;
  54262. /**
  54263. * Disposes the component and the associated ressources
  54264. */
  54265. dispose(): void;
  54266. }
  54267. }
  54268. declare module "babylonjs/Physics/physicsHelper" {
  54269. import { Nullable } from "babylonjs/types";
  54270. import { Vector3 } from "babylonjs/Maths/math";
  54271. import { Mesh } from "babylonjs/Meshes/mesh";
  54272. import { Scene } from "babylonjs/scene";
  54273. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  54274. /**
  54275. * A helper for physics simulations
  54276. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54277. */
  54278. export class PhysicsHelper {
  54279. private _scene;
  54280. private _physicsEngine;
  54281. /**
  54282. * Initializes the Physics helper
  54283. * @param scene Babylon.js scene
  54284. */
  54285. constructor(scene: Scene);
  54286. /**
  54287. * Applies a radial explosion impulse
  54288. * @param origin the origin of the explosion
  54289. * @param radiusOrEventOptions the radius or the options of radial explosion
  54290. * @param strength the explosion strength
  54291. * @param falloff possible options: Constant & Linear. Defaults to Constant
  54292. * @returns A physics radial explosion event, or null
  54293. */
  54294. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  54295. /**
  54296. * Applies a radial explosion force
  54297. * @param origin the origin of the explosion
  54298. * @param radiusOrEventOptions the radius or the options of radial explosion
  54299. * @param strength the explosion strength
  54300. * @param falloff possible options: Constant & Linear. Defaults to Constant
  54301. * @returns A physics radial explosion event, or null
  54302. */
  54303. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  54304. /**
  54305. * Creates a gravitational field
  54306. * @param origin the origin of the explosion
  54307. * @param radiusOrEventOptions the radius or the options of radial explosion
  54308. * @param strength the explosion strength
  54309. * @param falloff possible options: Constant & Linear. Defaults to Constant
  54310. * @returns A physics gravitational field event, or null
  54311. */
  54312. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  54313. /**
  54314. * Creates a physics updraft event
  54315. * @param origin the origin of the updraft
  54316. * @param radiusOrEventOptions the radius or the options of the updraft
  54317. * @param strength the strength of the updraft
  54318. * @param height the height of the updraft
  54319. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  54320. * @returns A physics updraft event, or null
  54321. */
  54322. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  54323. /**
  54324. * Creates a physics vortex event
  54325. * @param origin the of the vortex
  54326. * @param radiusOrEventOptions the radius or the options of the vortex
  54327. * @param strength the strength of the vortex
  54328. * @param height the height of the vortex
  54329. * @returns a Physics vortex event, or null
  54330. * A physics vortex event or null
  54331. */
  54332. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  54333. }
  54334. /**
  54335. * Represents a physics radial explosion event
  54336. */
  54337. class PhysicsRadialExplosionEvent {
  54338. private _scene;
  54339. private _options;
  54340. private _sphere;
  54341. private _dataFetched;
  54342. /**
  54343. * Initializes a radial explosioin event
  54344. * @param _scene BabylonJS scene
  54345. * @param _options The options for the vortex event
  54346. */
  54347. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  54348. /**
  54349. * Returns the data related to the radial explosion event (sphere).
  54350. * @returns The radial explosion event data
  54351. */
  54352. getData(): PhysicsRadialExplosionEventData;
  54353. /**
  54354. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  54355. * @param impostor A physics imposter
  54356. * @param origin the origin of the explosion
  54357. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  54358. */
  54359. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  54360. /**
  54361. * Triggers affecterd impostors callbacks
  54362. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  54363. */
  54364. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  54365. /**
  54366. * Disposes the sphere.
  54367. * @param force Specifies if the sphere should be disposed by force
  54368. */
  54369. dispose(force?: boolean): void;
  54370. /*** Helpers ***/
  54371. private _prepareSphere;
  54372. private _intersectsWithSphere;
  54373. }
  54374. /**
  54375. * Represents a gravitational field event
  54376. */
  54377. class PhysicsGravitationalFieldEvent {
  54378. private _physicsHelper;
  54379. private _scene;
  54380. private _origin;
  54381. private _options;
  54382. private _tickCallback;
  54383. private _sphere;
  54384. private _dataFetched;
  54385. /**
  54386. * Initializes the physics gravitational field event
  54387. * @param _physicsHelper A physics helper
  54388. * @param _scene BabylonJS scene
  54389. * @param _origin The origin position of the gravitational field event
  54390. * @param _options The options for the vortex event
  54391. */
  54392. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  54393. /**
  54394. * Returns the data related to the gravitational field event (sphere).
  54395. * @returns A gravitational field event
  54396. */
  54397. getData(): PhysicsGravitationalFieldEventData;
  54398. /**
  54399. * Enables the gravitational field.
  54400. */
  54401. enable(): void;
  54402. /**
  54403. * Disables the gravitational field.
  54404. */
  54405. disable(): void;
  54406. /**
  54407. * Disposes the sphere.
  54408. * @param force The force to dispose from the gravitational field event
  54409. */
  54410. dispose(force?: boolean): void;
  54411. private _tick;
  54412. }
  54413. /**
  54414. * Represents a physics updraft event
  54415. */
  54416. class PhysicsUpdraftEvent {
  54417. private _scene;
  54418. private _origin;
  54419. private _options;
  54420. private _physicsEngine;
  54421. private _originTop;
  54422. private _originDirection;
  54423. private _tickCallback;
  54424. private _cylinder;
  54425. private _cylinderPosition;
  54426. private _dataFetched;
  54427. /**
  54428. * Initializes the physics updraft event
  54429. * @param _scene BabylonJS scene
  54430. * @param _origin The origin position of the updraft
  54431. * @param _options The options for the updraft event
  54432. */
  54433. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  54434. /**
  54435. * Returns the data related to the updraft event (cylinder).
  54436. * @returns A physics updraft event
  54437. */
  54438. getData(): PhysicsUpdraftEventData;
  54439. /**
  54440. * Enables the updraft.
  54441. */
  54442. enable(): void;
  54443. /**
  54444. * Disables the updraft.
  54445. */
  54446. disable(): void;
  54447. /**
  54448. * Disposes the cylinder.
  54449. * @param force Specifies if the updraft should be disposed by force
  54450. */
  54451. dispose(force?: boolean): void;
  54452. private getImpostorHitData;
  54453. private _tick;
  54454. /*** Helpers ***/
  54455. private _prepareCylinder;
  54456. private _intersectsWithCylinder;
  54457. }
  54458. /**
  54459. * Represents a physics vortex event
  54460. */
  54461. class PhysicsVortexEvent {
  54462. private _scene;
  54463. private _origin;
  54464. private _options;
  54465. private _physicsEngine;
  54466. private _originTop;
  54467. private _tickCallback;
  54468. private _cylinder;
  54469. private _cylinderPosition;
  54470. private _dataFetched;
  54471. /**
  54472. * Initializes the physics vortex event
  54473. * @param _scene The BabylonJS scene
  54474. * @param _origin The origin position of the vortex
  54475. * @param _options The options for the vortex event
  54476. */
  54477. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  54478. /**
  54479. * Returns the data related to the vortex event (cylinder).
  54480. * @returns The physics vortex event data
  54481. */
  54482. getData(): PhysicsVortexEventData;
  54483. /**
  54484. * Enables the vortex.
  54485. */
  54486. enable(): void;
  54487. /**
  54488. * Disables the cortex.
  54489. */
  54490. disable(): void;
  54491. /**
  54492. * Disposes the sphere.
  54493. * @param force
  54494. */
  54495. dispose(force?: boolean): void;
  54496. private getImpostorHitData;
  54497. private _tick;
  54498. /*** Helpers ***/
  54499. private _prepareCylinder;
  54500. private _intersectsWithCylinder;
  54501. }
  54502. /**
  54503. * Options fot the radial explosion event
  54504. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54505. */
  54506. export class PhysicsRadialExplosionEventOptions {
  54507. /**
  54508. * The radius of the sphere for the radial explosion.
  54509. */
  54510. radius: number;
  54511. /**
  54512. * The strenth of the explosion.
  54513. */
  54514. strength: number;
  54515. /**
  54516. * The strenght of the force in correspondence to the distance of the affected object
  54517. */
  54518. falloff: PhysicsRadialImpulseFalloff;
  54519. /**
  54520. * Sphere options for the radial explosion.
  54521. */
  54522. sphere: {
  54523. segments: number;
  54524. diameter: number;
  54525. };
  54526. /**
  54527. * Sphere options for the radial explosion.
  54528. */
  54529. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  54530. }
  54531. /**
  54532. * Options fot the updraft event
  54533. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54534. */
  54535. export class PhysicsUpdraftEventOptions {
  54536. /**
  54537. * The radius of the cylinder for the vortex
  54538. */
  54539. radius: number;
  54540. /**
  54541. * The strenth of the updraft.
  54542. */
  54543. strength: number;
  54544. /**
  54545. * The height of the cylinder for the updraft.
  54546. */
  54547. height: number;
  54548. /**
  54549. * The mode for the the updraft.
  54550. */
  54551. updraftMode: PhysicsUpdraftMode;
  54552. }
  54553. /**
  54554. * Options fot the vortex event
  54555. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54556. */
  54557. export class PhysicsVortexEventOptions {
  54558. /**
  54559. * The radius of the cylinder for the vortex
  54560. */
  54561. radius: number;
  54562. /**
  54563. * The strenth of the vortex.
  54564. */
  54565. strength: number;
  54566. /**
  54567. * The height of the cylinder for the vortex.
  54568. */
  54569. height: number;
  54570. /**
  54571. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  54572. */
  54573. centripetalForceThreshold: number;
  54574. /**
  54575. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  54576. */
  54577. centripetalForceMultiplier: number;
  54578. /**
  54579. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  54580. */
  54581. centrifugalForceMultiplier: number;
  54582. /**
  54583. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  54584. */
  54585. updraftForceMultiplier: number;
  54586. }
  54587. /**
  54588. * The strenght of the force in correspondence to the distance of the affected object
  54589. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54590. */
  54591. export enum PhysicsRadialImpulseFalloff {
  54592. /** Defines that impulse is constant in strength across it's whole radius */
  54593. Constant = 0,
  54594. /** Defines that impulse gets weaker if it's further from the origin */
  54595. Linear = 1
  54596. }
  54597. /**
  54598. * The strength of the force in correspondence to the distance of the affected object
  54599. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54600. */
  54601. export enum PhysicsUpdraftMode {
  54602. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  54603. Center = 0,
  54604. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  54605. Perpendicular = 1
  54606. }
  54607. /**
  54608. * Interface for a physics hit data
  54609. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54610. */
  54611. export interface PhysicsHitData {
  54612. /**
  54613. * The force applied at the contact point
  54614. */
  54615. force: Vector3;
  54616. /**
  54617. * The contact point
  54618. */
  54619. contactPoint: Vector3;
  54620. /**
  54621. * The distance from the origin to the contact point
  54622. */
  54623. distanceFromOrigin: number;
  54624. }
  54625. /**
  54626. * Interface for radial explosion event data
  54627. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54628. */
  54629. export interface PhysicsRadialExplosionEventData {
  54630. /**
  54631. * A sphere used for the radial explosion event
  54632. */
  54633. sphere: Mesh;
  54634. }
  54635. /**
  54636. * Interface for gravitational field event data
  54637. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54638. */
  54639. export interface PhysicsGravitationalFieldEventData {
  54640. /**
  54641. * A sphere mesh used for the gravitational field event
  54642. */
  54643. sphere: Mesh;
  54644. }
  54645. /**
  54646. * Interface for updraft event data
  54647. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54648. */
  54649. export interface PhysicsUpdraftEventData {
  54650. /**
  54651. * A cylinder used for the updraft event
  54652. */
  54653. cylinder: Mesh;
  54654. }
  54655. /**
  54656. * Interface for vortex event data
  54657. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54658. */
  54659. export interface PhysicsVortexEventData {
  54660. /**
  54661. * A cylinder used for the vortex event
  54662. */
  54663. cylinder: Mesh;
  54664. }
  54665. /**
  54666. * Interface for an affected physics impostor
  54667. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54668. */
  54669. export interface PhysicsAffectedImpostorWithData {
  54670. /**
  54671. * The impostor affected by the effect
  54672. */
  54673. impostor: PhysicsImpostor;
  54674. /**
  54675. * The data about the hit/horce from the explosion
  54676. */
  54677. hitData: PhysicsHitData;
  54678. }
  54679. }
  54680. declare module "babylonjs/Physics/Plugins/index" {
  54681. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  54682. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  54683. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  54684. }
  54685. declare module "babylonjs/Physics/index" {
  54686. export * from "babylonjs/Physics/IPhysicsEngine";
  54687. export * from "babylonjs/Physics/physicsEngine";
  54688. export * from "babylonjs/Physics/physicsEngineComponent";
  54689. export * from "babylonjs/Physics/physicsHelper";
  54690. export * from "babylonjs/Physics/physicsImpostor";
  54691. export * from "babylonjs/Physics/physicsJoint";
  54692. export * from "babylonjs/Physics/Plugins/index";
  54693. }
  54694. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  54695. /** @hidden */
  54696. export var blackAndWhitePixelShader: {
  54697. name: string;
  54698. shader: string;
  54699. };
  54700. }
  54701. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  54702. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54703. import { Camera } from "babylonjs/Cameras/camera";
  54704. import { Engine } from "babylonjs/Engines/engine";
  54705. import "babylonjs/Shaders/blackAndWhite.fragment";
  54706. /**
  54707. * Post process used to render in black and white
  54708. */
  54709. export class BlackAndWhitePostProcess extends PostProcess {
  54710. /**
  54711. * Linear about to convert he result to black and white (default: 1)
  54712. */
  54713. degree: number;
  54714. /**
  54715. * Creates a black and white post process
  54716. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  54717. * @param name The name of the effect.
  54718. * @param options The required width/height ratio to downsize to before computing the render pass.
  54719. * @param camera The camera to apply the render pass to.
  54720. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54721. * @param engine The engine which the post process will be applied. (default: current engine)
  54722. * @param reusable If the post process can be reused on the same frame. (default: false)
  54723. */
  54724. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  54725. }
  54726. }
  54727. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  54728. import { Nullable } from "babylonjs/types";
  54729. import { Camera } from "babylonjs/Cameras/camera";
  54730. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54731. import { Engine } from "babylonjs/Engines/engine";
  54732. /**
  54733. * This represents a set of one or more post processes in Babylon.
  54734. * A post process can be used to apply a shader to a texture after it is rendered.
  54735. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  54736. */
  54737. export class PostProcessRenderEffect {
  54738. private _postProcesses;
  54739. private _getPostProcesses;
  54740. private _singleInstance;
  54741. private _cameras;
  54742. private _indicesForCamera;
  54743. /**
  54744. * Name of the effect
  54745. * @hidden
  54746. */
  54747. _name: string;
  54748. /**
  54749. * Instantiates a post process render effect.
  54750. * A post process can be used to apply a shader to a texture after it is rendered.
  54751. * @param engine The engine the effect is tied to
  54752. * @param name The name of the effect
  54753. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  54754. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  54755. */
  54756. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  54757. /**
  54758. * Checks if all the post processes in the effect are supported.
  54759. */
  54760. readonly isSupported: boolean;
  54761. /**
  54762. * Updates the current state of the effect
  54763. * @hidden
  54764. */
  54765. _update(): void;
  54766. /**
  54767. * Attaches the effect on cameras
  54768. * @param cameras The camera to attach to.
  54769. * @hidden
  54770. */
  54771. _attachCameras(cameras: Camera): void;
  54772. /**
  54773. * Attaches the effect on cameras
  54774. * @param cameras The camera to attach to.
  54775. * @hidden
  54776. */
  54777. _attachCameras(cameras: Camera[]): void;
  54778. /**
  54779. * Detaches the effect on cameras
  54780. * @param cameras The camera to detatch from.
  54781. * @hidden
  54782. */
  54783. _detachCameras(cameras: Camera): void;
  54784. /**
  54785. * Detatches the effect on cameras
  54786. * @param cameras The camera to detatch from.
  54787. * @hidden
  54788. */
  54789. _detachCameras(cameras: Camera[]): void;
  54790. /**
  54791. * Enables the effect on given cameras
  54792. * @param cameras The camera to enable.
  54793. * @hidden
  54794. */
  54795. _enable(cameras: Camera): void;
  54796. /**
  54797. * Enables the effect on given cameras
  54798. * @param cameras The camera to enable.
  54799. * @hidden
  54800. */
  54801. _enable(cameras: Nullable<Camera[]>): void;
  54802. /**
  54803. * Disables the effect on the given cameras
  54804. * @param cameras The camera to disable.
  54805. * @hidden
  54806. */
  54807. _disable(cameras: Camera): void;
  54808. /**
  54809. * Disables the effect on the given cameras
  54810. * @param cameras The camera to disable.
  54811. * @hidden
  54812. */
  54813. _disable(cameras: Nullable<Camera[]>): void;
  54814. /**
  54815. * Gets a list of the post processes contained in the effect.
  54816. * @param camera The camera to get the post processes on.
  54817. * @returns The list of the post processes in the effect.
  54818. */
  54819. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  54820. }
  54821. }
  54822. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  54823. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  54824. /** @hidden */
  54825. export var extractHighlightsPixelShader: {
  54826. name: string;
  54827. shader: string;
  54828. };
  54829. }
  54830. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  54831. import { Nullable } from "babylonjs/types";
  54832. import { Camera } from "babylonjs/Cameras/camera";
  54833. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54834. import { Engine } from "babylonjs/Engines/engine";
  54835. import "babylonjs/Shaders/extractHighlights.fragment";
  54836. /**
  54837. * 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.
  54838. */
  54839. export class ExtractHighlightsPostProcess extends PostProcess {
  54840. /**
  54841. * The luminance threshold, pixels below this value will be set to black.
  54842. */
  54843. threshold: number;
  54844. /** @hidden */
  54845. _exposure: number;
  54846. /**
  54847. * Post process which has the input texture to be used when performing highlight extraction
  54848. * @hidden
  54849. */
  54850. _inputPostProcess: Nullable<PostProcess>;
  54851. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54852. }
  54853. }
  54854. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  54855. /** @hidden */
  54856. export var bloomMergePixelShader: {
  54857. name: string;
  54858. shader: string;
  54859. };
  54860. }
  54861. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  54862. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54863. import { Nullable } from "babylonjs/types";
  54864. import { Engine } from "babylonjs/Engines/engine";
  54865. import { Camera } from "babylonjs/Cameras/camera";
  54866. import "babylonjs/Shaders/bloomMerge.fragment";
  54867. /**
  54868. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  54869. */
  54870. export class BloomMergePostProcess extends PostProcess {
  54871. /** Weight of the bloom to be added to the original input. */
  54872. weight: number;
  54873. /**
  54874. * Creates a new instance of @see BloomMergePostProcess
  54875. * @param name The name of the effect.
  54876. * @param originalFromInput Post process which's input will be used for the merge.
  54877. * @param blurred Blurred highlights post process which's output will be used.
  54878. * @param weight Weight of the bloom to be added to the original input.
  54879. * @param options The required width/height ratio to downsize to before computing the render pass.
  54880. * @param camera The camera to apply the render pass to.
  54881. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54882. * @param engine The engine which the post process will be applied. (default: current engine)
  54883. * @param reusable If the post process can be reused on the same frame. (default: false)
  54884. * @param textureType Type of textures used when performing the post process. (default: 0)
  54885. * @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)
  54886. */
  54887. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  54888. /** Weight of the bloom to be added to the original input. */
  54889. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54890. }
  54891. }
  54892. declare module "babylonjs/PostProcesses/bloomEffect" {
  54893. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  54894. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54895. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  54896. import { Camera } from "babylonjs/Cameras/camera";
  54897. import { Scene } from "babylonjs/scene";
  54898. /**
  54899. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  54900. */
  54901. export class BloomEffect extends PostProcessRenderEffect {
  54902. private bloomScale;
  54903. /**
  54904. * @hidden Internal
  54905. */
  54906. _effects: Array<PostProcess>;
  54907. /**
  54908. * @hidden Internal
  54909. */
  54910. _downscale: ExtractHighlightsPostProcess;
  54911. private _blurX;
  54912. private _blurY;
  54913. private _merge;
  54914. /**
  54915. * The luminance threshold to find bright areas of the image to bloom.
  54916. */
  54917. threshold: number;
  54918. /**
  54919. * The strength of the bloom.
  54920. */
  54921. weight: number;
  54922. /**
  54923. * Specifies the size of the bloom blur kernel, relative to the final output size
  54924. */
  54925. kernel: number;
  54926. /**
  54927. * Creates a new instance of @see BloomEffect
  54928. * @param scene The scene the effect belongs to.
  54929. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  54930. * @param bloomKernel The size of the kernel to be used when applying the blur.
  54931. * @param bloomWeight The the strength of bloom.
  54932. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  54933. * @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)
  54934. */
  54935. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  54936. /**
  54937. * Disposes each of the internal effects for a given camera.
  54938. * @param camera The camera to dispose the effect on.
  54939. */
  54940. disposeEffects(camera: Camera): void;
  54941. /**
  54942. * @hidden Internal
  54943. */
  54944. _updateEffects(): void;
  54945. /**
  54946. * Internal
  54947. * @returns if all the contained post processes are ready.
  54948. * @hidden
  54949. */
  54950. _isReady(): boolean;
  54951. }
  54952. }
  54953. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  54954. /** @hidden */
  54955. export var chromaticAberrationPixelShader: {
  54956. name: string;
  54957. shader: string;
  54958. };
  54959. }
  54960. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  54961. import { Vector2 } from "babylonjs/Maths/math";
  54962. import { Nullable } from "babylonjs/types";
  54963. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54964. import { Camera } from "babylonjs/Cameras/camera";
  54965. import { Engine } from "babylonjs/Engines/engine";
  54966. import "babylonjs/Shaders/chromaticAberration.fragment";
  54967. /**
  54968. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  54969. */
  54970. export class ChromaticAberrationPostProcess extends PostProcess {
  54971. /**
  54972. * The amount of seperation of rgb channels (default: 30)
  54973. */
  54974. aberrationAmount: number;
  54975. /**
  54976. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  54977. */
  54978. radialIntensity: number;
  54979. /**
  54980. * 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))
  54981. */
  54982. direction: Vector2;
  54983. /**
  54984. * 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))
  54985. */
  54986. centerPosition: Vector2;
  54987. /**
  54988. * Creates a new instance ChromaticAberrationPostProcess
  54989. * @param name The name of the effect.
  54990. * @param screenWidth The width of the screen to apply the effect on.
  54991. * @param screenHeight The height of the screen to apply the effect on.
  54992. * @param options The required width/height ratio to downsize to before computing the render pass.
  54993. * @param camera The camera to apply the render pass to.
  54994. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54995. * @param engine The engine which the post process will be applied. (default: current engine)
  54996. * @param reusable If the post process can be reused on the same frame. (default: false)
  54997. * @param textureType Type of textures used when performing the post process. (default: 0)
  54998. * @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)
  54999. */
  55000. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55001. }
  55002. }
  55003. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  55004. /** @hidden */
  55005. export var circleOfConfusionPixelShader: {
  55006. name: string;
  55007. shader: string;
  55008. };
  55009. }
  55010. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  55011. import { Nullable } from "babylonjs/types";
  55012. import { Engine } from "babylonjs/Engines/engine";
  55013. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55014. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55015. import { Camera } from "babylonjs/Cameras/camera";
  55016. import "babylonjs/Shaders/circleOfConfusion.fragment";
  55017. /**
  55018. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  55019. */
  55020. export class CircleOfConfusionPostProcess extends PostProcess {
  55021. /**
  55022. * 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.
  55023. */
  55024. lensSize: number;
  55025. /**
  55026. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  55027. */
  55028. fStop: number;
  55029. /**
  55030. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  55031. */
  55032. focusDistance: number;
  55033. /**
  55034. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  55035. */
  55036. focalLength: number;
  55037. private _depthTexture;
  55038. /**
  55039. * Creates a new instance CircleOfConfusionPostProcess
  55040. * @param name The name of the effect.
  55041. * @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.
  55042. * @param options The required width/height ratio to downsize to before computing the render pass.
  55043. * @param camera The camera to apply the render pass to.
  55044. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55045. * @param engine The engine which the post process will be applied. (default: current engine)
  55046. * @param reusable If the post process can be reused on the same frame. (default: false)
  55047. * @param textureType Type of textures used when performing the post process. (default: 0)
  55048. * @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)
  55049. */
  55050. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55051. /**
  55052. * 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.
  55053. */
  55054. depthTexture: RenderTargetTexture;
  55055. }
  55056. }
  55057. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  55058. /** @hidden */
  55059. export var colorCorrectionPixelShader: {
  55060. name: string;
  55061. shader: string;
  55062. };
  55063. }
  55064. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  55065. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55066. import { Engine } from "babylonjs/Engines/engine";
  55067. import { Camera } from "babylonjs/Cameras/camera";
  55068. import "babylonjs/Shaders/colorCorrection.fragment";
  55069. /**
  55070. *
  55071. * This post-process allows the modification of rendered colors by using
  55072. * a 'look-up table' (LUT). This effect is also called Color Grading.
  55073. *
  55074. * The object needs to be provided an url to a texture containing the color
  55075. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  55076. * Use an image editing software to tweak the LUT to match your needs.
  55077. *
  55078. * For an example of a color LUT, see here:
  55079. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  55080. * For explanations on color grading, see here:
  55081. * @see http://udn.epicgames.com/Three/ColorGrading.html
  55082. *
  55083. */
  55084. export class ColorCorrectionPostProcess extends PostProcess {
  55085. private _colorTableTexture;
  55086. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  55087. }
  55088. }
  55089. declare module "babylonjs/Shaders/convolution.fragment" {
  55090. /** @hidden */
  55091. export var convolutionPixelShader: {
  55092. name: string;
  55093. shader: string;
  55094. };
  55095. }
  55096. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  55097. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55098. import { Nullable } from "babylonjs/types";
  55099. import { Camera } from "babylonjs/Cameras/camera";
  55100. import { Engine } from "babylonjs/Engines/engine";
  55101. import "babylonjs/Shaders/convolution.fragment";
  55102. /**
  55103. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  55104. * input texture to perform effects such as edge detection or sharpening
  55105. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  55106. */
  55107. export class ConvolutionPostProcess extends PostProcess {
  55108. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  55109. kernel: number[];
  55110. /**
  55111. * Creates a new instance ConvolutionPostProcess
  55112. * @param name The name of the effect.
  55113. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  55114. * @param options The required width/height ratio to downsize to before computing the render pass.
  55115. * @param camera The camera to apply the render pass to.
  55116. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55117. * @param engine The engine which the post process will be applied. (default: current engine)
  55118. * @param reusable If the post process can be reused on the same frame. (default: false)
  55119. * @param textureType Type of textures used when performing the post process. (default: 0)
  55120. */
  55121. constructor(name: string,
  55122. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  55123. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  55124. /**
  55125. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55126. */
  55127. static EdgeDetect0Kernel: number[];
  55128. /**
  55129. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55130. */
  55131. static EdgeDetect1Kernel: number[];
  55132. /**
  55133. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55134. */
  55135. static EdgeDetect2Kernel: number[];
  55136. /**
  55137. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55138. */
  55139. static SharpenKernel: number[];
  55140. /**
  55141. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55142. */
  55143. static EmbossKernel: number[];
  55144. /**
  55145. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55146. */
  55147. static GaussianKernel: number[];
  55148. }
  55149. }
  55150. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  55151. import { Nullable } from "babylonjs/types";
  55152. import { Vector2 } from "babylonjs/Maths/math";
  55153. import { Camera } from "babylonjs/Cameras/camera";
  55154. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55155. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  55156. import { Engine } from "babylonjs/Engines/engine";
  55157. import { Scene } from "babylonjs/scene";
  55158. /**
  55159. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  55160. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  55161. * based on samples that have a large difference in distance than the center pixel.
  55162. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  55163. */
  55164. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  55165. direction: Vector2;
  55166. /**
  55167. * Creates a new instance CircleOfConfusionPostProcess
  55168. * @param name The name of the effect.
  55169. * @param scene The scene the effect belongs to.
  55170. * @param direction The direction the blur should be applied.
  55171. * @param kernel The size of the kernel used to blur.
  55172. * @param options The required width/height ratio to downsize to before computing the render pass.
  55173. * @param camera The camera to apply the render pass to.
  55174. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  55175. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  55176. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55177. * @param engine The engine which the post process will be applied. (default: current engine)
  55178. * @param reusable If the post process can be reused on the same frame. (default: false)
  55179. * @param textureType Type of textures used when performing the post process. (default: 0)
  55180. * @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)
  55181. */
  55182. 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);
  55183. }
  55184. }
  55185. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  55186. /** @hidden */
  55187. export var depthOfFieldMergePixelShader: {
  55188. name: string;
  55189. shader: string;
  55190. };
  55191. }
  55192. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  55193. import { Nullable } from "babylonjs/types";
  55194. import { Camera } from "babylonjs/Cameras/camera";
  55195. import { Effect } from "babylonjs/Materials/effect";
  55196. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55197. import { Engine } from "babylonjs/Engines/engine";
  55198. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  55199. /**
  55200. * Options to be set when merging outputs from the default pipeline.
  55201. */
  55202. export class DepthOfFieldMergePostProcessOptions {
  55203. /**
  55204. * The original image to merge on top of
  55205. */
  55206. originalFromInput: PostProcess;
  55207. /**
  55208. * Parameters to perform the merge of the depth of field effect
  55209. */
  55210. depthOfField?: {
  55211. circleOfConfusion: PostProcess;
  55212. blurSteps: Array<PostProcess>;
  55213. };
  55214. /**
  55215. * Parameters to perform the merge of bloom effect
  55216. */
  55217. bloom?: {
  55218. blurred: PostProcess;
  55219. weight: number;
  55220. };
  55221. }
  55222. /**
  55223. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  55224. */
  55225. export class DepthOfFieldMergePostProcess extends PostProcess {
  55226. private blurSteps;
  55227. /**
  55228. * Creates a new instance of DepthOfFieldMergePostProcess
  55229. * @param name The name of the effect.
  55230. * @param originalFromInput Post process which's input will be used for the merge.
  55231. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  55232. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  55233. * @param options The required width/height ratio to downsize to before computing the render pass.
  55234. * @param camera The camera to apply the render pass to.
  55235. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55236. * @param engine The engine which the post process will be applied. (default: current engine)
  55237. * @param reusable If the post process can be reused on the same frame. (default: false)
  55238. * @param textureType Type of textures used when performing the post process. (default: 0)
  55239. * @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)
  55240. */
  55241. 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);
  55242. /**
  55243. * Updates the effect with the current post process compile time values and recompiles the shader.
  55244. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  55245. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  55246. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  55247. * @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
  55248. * @param onCompiled Called when the shader has been compiled.
  55249. * @param onError Called if there is an error when compiling a shader.
  55250. */
  55251. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  55252. }
  55253. }
  55254. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  55255. import { Nullable } from "babylonjs/types";
  55256. import { Camera } from "babylonjs/Cameras/camera";
  55257. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55258. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  55259. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  55260. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  55261. import { Scene } from "babylonjs/scene";
  55262. /**
  55263. * Specifies the level of max blur that should be applied when using the depth of field effect
  55264. */
  55265. export enum DepthOfFieldEffectBlurLevel {
  55266. /**
  55267. * Subtle blur
  55268. */
  55269. Low = 0,
  55270. /**
  55271. * Medium blur
  55272. */
  55273. Medium = 1,
  55274. /**
  55275. * Large blur
  55276. */
  55277. High = 2
  55278. }
  55279. /**
  55280. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  55281. */
  55282. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  55283. private _circleOfConfusion;
  55284. /**
  55285. * @hidden Internal, blurs from high to low
  55286. */
  55287. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  55288. private _depthOfFieldBlurY;
  55289. private _dofMerge;
  55290. /**
  55291. * @hidden Internal post processes in depth of field effect
  55292. */
  55293. _effects: Array<PostProcess>;
  55294. /**
  55295. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  55296. */
  55297. focalLength: number;
  55298. /**
  55299. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  55300. */
  55301. fStop: number;
  55302. /**
  55303. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  55304. */
  55305. focusDistance: number;
  55306. /**
  55307. * 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.
  55308. */
  55309. lensSize: number;
  55310. /**
  55311. * Creates a new instance DepthOfFieldEffect
  55312. * @param scene The scene the effect belongs to.
  55313. * @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.
  55314. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  55315. * @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)
  55316. */
  55317. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  55318. /**
  55319. * Get the current class name of the current effet
  55320. * @returns "DepthOfFieldEffect"
  55321. */
  55322. getClassName(): string;
  55323. /**
  55324. * 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.
  55325. */
  55326. depthTexture: RenderTargetTexture;
  55327. /**
  55328. * Disposes each of the internal effects for a given camera.
  55329. * @param camera The camera to dispose the effect on.
  55330. */
  55331. disposeEffects(camera: Camera): void;
  55332. /**
  55333. * @hidden Internal
  55334. */
  55335. _updateEffects(): void;
  55336. /**
  55337. * Internal
  55338. * @returns if all the contained post processes are ready.
  55339. * @hidden
  55340. */
  55341. _isReady(): boolean;
  55342. }
  55343. }
  55344. declare module "babylonjs/Shaders/displayPass.fragment" {
  55345. /** @hidden */
  55346. export var displayPassPixelShader: {
  55347. name: string;
  55348. shader: string;
  55349. };
  55350. }
  55351. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  55352. import { Nullable } from "babylonjs/types";
  55353. import { Camera } from "babylonjs/Cameras/camera";
  55354. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55355. import { Engine } from "babylonjs/Engines/engine";
  55356. import "babylonjs/Shaders/displayPass.fragment";
  55357. /**
  55358. * DisplayPassPostProcess which produces an output the same as it's input
  55359. */
  55360. export class DisplayPassPostProcess extends PostProcess {
  55361. /**
  55362. * Creates the DisplayPassPostProcess
  55363. * @param name The name of the effect.
  55364. * @param options The required width/height ratio to downsize to before computing the render pass.
  55365. * @param camera The camera to apply the render pass to.
  55366. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55367. * @param engine The engine which the post process will be applied. (default: current engine)
  55368. * @param reusable If the post process can be reused on the same frame. (default: false)
  55369. */
  55370. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  55371. }
  55372. }
  55373. declare module "babylonjs/Shaders/filter.fragment" {
  55374. /** @hidden */
  55375. export var filterPixelShader: {
  55376. name: string;
  55377. shader: string;
  55378. };
  55379. }
  55380. declare module "babylonjs/PostProcesses/filterPostProcess" {
  55381. import { Nullable } from "babylonjs/types";
  55382. import { Matrix } from "babylonjs/Maths/math";
  55383. import { Camera } from "babylonjs/Cameras/camera";
  55384. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55385. import { Engine } from "babylonjs/Engines/engine";
  55386. import "babylonjs/Shaders/filter.fragment";
  55387. /**
  55388. * Applies a kernel filter to the image
  55389. */
  55390. export class FilterPostProcess extends PostProcess {
  55391. /** The matrix to be applied to the image */
  55392. kernelMatrix: Matrix;
  55393. /**
  55394. *
  55395. * @param name The name of the effect.
  55396. * @param kernelMatrix The matrix to be applied to the image
  55397. * @param options The required width/height ratio to downsize to before computing the render pass.
  55398. * @param camera The camera to apply the render pass to.
  55399. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55400. * @param engine The engine which the post process will be applied. (default: current engine)
  55401. * @param reusable If the post process can be reused on the same frame. (default: false)
  55402. */
  55403. constructor(name: string,
  55404. /** The matrix to be applied to the image */
  55405. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  55406. }
  55407. }
  55408. declare module "babylonjs/Shaders/fxaa.fragment" {
  55409. /** @hidden */
  55410. export var fxaaPixelShader: {
  55411. name: string;
  55412. shader: string;
  55413. };
  55414. }
  55415. declare module "babylonjs/Shaders/fxaa.vertex" {
  55416. /** @hidden */
  55417. export var fxaaVertexShader: {
  55418. name: string;
  55419. shader: string;
  55420. };
  55421. }
  55422. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  55423. import { Nullable } from "babylonjs/types";
  55424. import { Camera } from "babylonjs/Cameras/camera";
  55425. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55426. import { Engine } from "babylonjs/Engines/engine";
  55427. import "babylonjs/Shaders/fxaa.fragment";
  55428. import "babylonjs/Shaders/fxaa.vertex";
  55429. /**
  55430. * Fxaa post process
  55431. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  55432. */
  55433. export class FxaaPostProcess extends PostProcess {
  55434. /** @hidden */
  55435. texelWidth: number;
  55436. /** @hidden */
  55437. texelHeight: number;
  55438. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  55439. private _getDefines;
  55440. }
  55441. }
  55442. declare module "babylonjs/Shaders/grain.fragment" {
  55443. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  55444. /** @hidden */
  55445. export var grainPixelShader: {
  55446. name: string;
  55447. shader: string;
  55448. };
  55449. }
  55450. declare module "babylonjs/PostProcesses/grainPostProcess" {
  55451. import { Nullable } from "babylonjs/types";
  55452. import { Camera } from "babylonjs/Cameras/camera";
  55453. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55454. import { Engine } from "babylonjs/Engines/engine";
  55455. import "babylonjs/Shaders/grain.fragment";
  55456. /**
  55457. * The GrainPostProcess adds noise to the image at mid luminance levels
  55458. */
  55459. export class GrainPostProcess extends PostProcess {
  55460. /**
  55461. * The intensity of the grain added (default: 30)
  55462. */
  55463. intensity: number;
  55464. /**
  55465. * If the grain should be randomized on every frame
  55466. */
  55467. animated: boolean;
  55468. /**
  55469. * Creates a new instance of @see GrainPostProcess
  55470. * @param name The name of the effect.
  55471. * @param options The required width/height ratio to downsize to before computing the render pass.
  55472. * @param camera The camera to apply the render pass to.
  55473. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55474. * @param engine The engine which the post process will be applied. (default: current engine)
  55475. * @param reusable If the post process can be reused on the same frame. (default: false)
  55476. * @param textureType Type of textures used when performing the post process. (default: 0)
  55477. * @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)
  55478. */
  55479. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55480. }
  55481. }
  55482. declare module "babylonjs/Shaders/highlights.fragment" {
  55483. /** @hidden */
  55484. export var highlightsPixelShader: {
  55485. name: string;
  55486. shader: string;
  55487. };
  55488. }
  55489. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  55490. import { Nullable } from "babylonjs/types";
  55491. import { Camera } from "babylonjs/Cameras/camera";
  55492. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55493. import { Engine } from "babylonjs/Engines/engine";
  55494. import "babylonjs/Shaders/highlights.fragment";
  55495. /**
  55496. * Extracts highlights from the image
  55497. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  55498. */
  55499. export class HighlightsPostProcess extends PostProcess {
  55500. /**
  55501. * Extracts highlights from the image
  55502. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  55503. * @param name The name of the effect.
  55504. * @param options The required width/height ratio to downsize to before computing the render pass.
  55505. * @param camera The camera to apply the render pass to.
  55506. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55507. * @param engine The engine which the post process will be applied. (default: current engine)
  55508. * @param reusable If the post process can be reused on the same frame. (default: false)
  55509. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  55510. */
  55511. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  55512. }
  55513. }
  55514. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  55515. /** @hidden */
  55516. export var mrtFragmentDeclaration: {
  55517. name: string;
  55518. shader: string;
  55519. };
  55520. }
  55521. declare module "babylonjs/Shaders/geometry.fragment" {
  55522. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  55523. /** @hidden */
  55524. export var geometryPixelShader: {
  55525. name: string;
  55526. shader: string;
  55527. };
  55528. }
  55529. declare module "babylonjs/Shaders/geometry.vertex" {
  55530. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  55531. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  55532. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  55533. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  55534. /** @hidden */
  55535. export var geometryVertexShader: {
  55536. name: string;
  55537. shader: string;
  55538. };
  55539. }
  55540. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  55541. import { Matrix } from "babylonjs/Maths/math";
  55542. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55543. import { Mesh } from "babylonjs/Meshes/mesh";
  55544. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  55545. import { Effect } from "babylonjs/Materials/effect";
  55546. import { Scene } from "babylonjs/scene";
  55547. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55548. import "babylonjs/Shaders/geometry.fragment";
  55549. import "babylonjs/Shaders/geometry.vertex";
  55550. /** @hidden */
  55551. interface ISavedTransformationMatrix {
  55552. world: Matrix;
  55553. viewProjection: Matrix;
  55554. }
  55555. /**
  55556. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  55557. */
  55558. export class GeometryBufferRenderer {
  55559. /**
  55560. * Constant used to retrieve the position texture index in the G-Buffer textures array
  55561. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  55562. */
  55563. static readonly POSITION_TEXTURE_TYPE: number;
  55564. /**
  55565. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  55566. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  55567. */
  55568. static readonly VELOCITY_TEXTURE_TYPE: number;
  55569. /**
  55570. * Dictionary used to store the previous transformation matrices of each rendered mesh
  55571. * in order to compute objects velocities when enableVelocity is set to "true"
  55572. * @hidden
  55573. */
  55574. _previousTransformationMatrices: {
  55575. [index: number]: ISavedTransformationMatrix;
  55576. };
  55577. /**
  55578. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  55579. * in order to compute objects velocities when enableVelocity is set to "true"
  55580. * @hidden
  55581. */
  55582. _previousBonesTransformationMatrices: {
  55583. [index: number]: Float32Array;
  55584. };
  55585. /**
  55586. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  55587. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  55588. */
  55589. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  55590. private _scene;
  55591. private _multiRenderTarget;
  55592. private _ratio;
  55593. private _enablePosition;
  55594. private _enableVelocity;
  55595. private _positionIndex;
  55596. private _velocityIndex;
  55597. protected _effect: Effect;
  55598. protected _cachedDefines: string;
  55599. /**
  55600. * Set the render list (meshes to be rendered) used in the G buffer.
  55601. */
  55602. renderList: Mesh[];
  55603. /**
  55604. * Gets wether or not G buffer are supported by the running hardware.
  55605. * This requires draw buffer supports
  55606. */
  55607. readonly isSupported: boolean;
  55608. /**
  55609. * Returns the index of the given texture type in the G-Buffer textures array
  55610. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  55611. * @returns the index of the given texture type in the G-Buffer textures array
  55612. */
  55613. getTextureIndex(textureType: number): number;
  55614. /**
  55615. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  55616. */
  55617. /**
  55618. * Sets whether or not objects positions are enabled for the G buffer.
  55619. */
  55620. enablePosition: boolean;
  55621. /**
  55622. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  55623. */
  55624. /**
  55625. * Sets wether or not objects velocities are enabled for the G buffer.
  55626. */
  55627. enableVelocity: boolean;
  55628. /**
  55629. * Gets the scene associated with the buffer.
  55630. */
  55631. readonly scene: Scene;
  55632. /**
  55633. * Gets the ratio used by the buffer during its creation.
  55634. * How big is the buffer related to the main canvas.
  55635. */
  55636. readonly ratio: number;
  55637. /** @hidden */
  55638. static _SceneComponentInitialization: (scene: Scene) => void;
  55639. /**
  55640. * Creates a new G Buffer for the scene
  55641. * @param scene The scene the buffer belongs to
  55642. * @param ratio How big is the buffer related to the main canvas.
  55643. */
  55644. constructor(scene: Scene, ratio?: number);
  55645. /**
  55646. * Checks wether everything is ready to render a submesh to the G buffer.
  55647. * @param subMesh the submesh to check readiness for
  55648. * @param useInstances is the mesh drawn using instance or not
  55649. * @returns true if ready otherwise false
  55650. */
  55651. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55652. /**
  55653. * Gets the current underlying G Buffer.
  55654. * @returns the buffer
  55655. */
  55656. getGBuffer(): MultiRenderTarget;
  55657. /**
  55658. * Gets the number of samples used to render the buffer (anti aliasing).
  55659. */
  55660. /**
  55661. * Sets the number of samples used to render the buffer (anti aliasing).
  55662. */
  55663. samples: number;
  55664. /**
  55665. * Disposes the renderer and frees up associated resources.
  55666. */
  55667. dispose(): void;
  55668. protected _createRenderTargets(): void;
  55669. private _copyBonesTransformationMatrices;
  55670. }
  55671. }
  55672. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  55673. import { Nullable } from "babylonjs/types";
  55674. import { Scene } from "babylonjs/scene";
  55675. import { ISceneComponent } from "babylonjs/sceneComponent";
  55676. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  55677. module "babylonjs/scene" {
  55678. interface Scene {
  55679. /** @hidden (Backing field) */
  55680. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  55681. /**
  55682. * Gets or Sets the current geometry buffer associated to the scene.
  55683. */
  55684. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  55685. /**
  55686. * Enables a GeometryBufferRender and associates it with the scene
  55687. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  55688. * @returns the GeometryBufferRenderer
  55689. */
  55690. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  55691. /**
  55692. * Disables the GeometryBufferRender associated with the scene
  55693. */
  55694. disableGeometryBufferRenderer(): void;
  55695. }
  55696. }
  55697. /**
  55698. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  55699. * in several rendering techniques.
  55700. */
  55701. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  55702. /**
  55703. * The component name helpful to identify the component in the list of scene components.
  55704. */
  55705. readonly name: string;
  55706. /**
  55707. * The scene the component belongs to.
  55708. */
  55709. scene: Scene;
  55710. /**
  55711. * Creates a new instance of the component for the given scene
  55712. * @param scene Defines the scene to register the component in
  55713. */
  55714. constructor(scene: Scene);
  55715. /**
  55716. * Registers the component in a given scene
  55717. */
  55718. register(): void;
  55719. /**
  55720. * Rebuilds the elements related to this component in case of
  55721. * context lost for instance.
  55722. */
  55723. rebuild(): void;
  55724. /**
  55725. * Disposes the component and the associated ressources
  55726. */
  55727. dispose(): void;
  55728. private _gatherRenderTargets;
  55729. }
  55730. }
  55731. declare module "babylonjs/Shaders/motionBlur.fragment" {
  55732. /** @hidden */
  55733. export var motionBlurPixelShader: {
  55734. name: string;
  55735. shader: string;
  55736. };
  55737. }
  55738. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  55739. import { Nullable } from "babylonjs/types";
  55740. import { Camera } from "babylonjs/Cameras/camera";
  55741. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55742. import { Scene } from "babylonjs/scene";
  55743. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55744. import "babylonjs/Animations/animatable";
  55745. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  55746. import "babylonjs/Shaders/motionBlur.fragment";
  55747. import { Engine } from "babylonjs/Engines/engine";
  55748. /**
  55749. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  55750. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  55751. * As an example, all you have to do is to create the post-process:
  55752. * var mb = new BABYLON.MotionBlurPostProcess(
  55753. * 'mb', // The name of the effect.
  55754. * scene, // The scene containing the objects to blur according to their velocity.
  55755. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  55756. * camera // The camera to apply the render pass to.
  55757. * );
  55758. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  55759. */
  55760. export class MotionBlurPostProcess extends PostProcess {
  55761. /**
  55762. * Defines how much the image is blurred by the movement. Default value is equal to 1
  55763. */
  55764. motionStrength: number;
  55765. /**
  55766. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  55767. */
  55768. /**
  55769. * Sets the number of iterations to be used for motion blur quality
  55770. */
  55771. motionBlurSamples: number;
  55772. private _motionBlurSamples;
  55773. private _geometryBufferRenderer;
  55774. /**
  55775. * Creates a new instance MotionBlurPostProcess
  55776. * @param name The name of the effect.
  55777. * @param scene The scene containing the objects to blur according to their velocity.
  55778. * @param options The required width/height ratio to downsize to before computing the render pass.
  55779. * @param camera The camera to apply the render pass to.
  55780. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55781. * @param engine The engine which the post process will be applied. (default: current engine)
  55782. * @param reusable If the post process can be reused on the same frame. (default: false)
  55783. * @param textureType Type of textures used when performing the post process. (default: 0)
  55784. * @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)
  55785. */
  55786. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55787. /**
  55788. * Excludes the given skinned mesh from computing bones velocities.
  55789. * Computing bones velocities can have a cost and that cost. The cost can be saved by calling this function and by passing the skinned mesh reference to ignore.
  55790. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  55791. */
  55792. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  55793. /**
  55794. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  55795. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  55796. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  55797. */
  55798. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  55799. /**
  55800. * Disposes the post process.
  55801. * @param camera The camera to dispose the post process on.
  55802. */
  55803. dispose(camera?: Camera): void;
  55804. }
  55805. }
  55806. declare module "babylonjs/Shaders/refraction.fragment" {
  55807. /** @hidden */
  55808. export var refractionPixelShader: {
  55809. name: string;
  55810. shader: string;
  55811. };
  55812. }
  55813. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  55814. import { Color3 } from "babylonjs/Maths/math";
  55815. import { Camera } from "babylonjs/Cameras/camera";
  55816. import { Texture } from "babylonjs/Materials/Textures/texture";
  55817. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55818. import { Engine } from "babylonjs/Engines/engine";
  55819. import "babylonjs/Shaders/refraction.fragment";
  55820. /**
  55821. * Post process which applies a refractin texture
  55822. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  55823. */
  55824. export class RefractionPostProcess extends PostProcess {
  55825. /** the base color of the refraction (used to taint the rendering) */
  55826. color: Color3;
  55827. /** simulated refraction depth */
  55828. depth: number;
  55829. /** the coefficient of the base color (0 to remove base color tainting) */
  55830. colorLevel: number;
  55831. private _refTexture;
  55832. private _ownRefractionTexture;
  55833. /**
  55834. * Gets or sets the refraction texture
  55835. * Please note that you are responsible for disposing the texture if you set it manually
  55836. */
  55837. refractionTexture: Texture;
  55838. /**
  55839. * Initializes the RefractionPostProcess
  55840. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  55841. * @param name The name of the effect.
  55842. * @param refractionTextureUrl Url of the refraction texture to use
  55843. * @param color the base color of the refraction (used to taint the rendering)
  55844. * @param depth simulated refraction depth
  55845. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  55846. * @param camera The camera to apply the render pass to.
  55847. * @param options The required width/height ratio to downsize to before computing the render pass.
  55848. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55849. * @param engine The engine which the post process will be applied. (default: current engine)
  55850. * @param reusable If the post process can be reused on the same frame. (default: false)
  55851. */
  55852. constructor(name: string, refractionTextureUrl: string,
  55853. /** the base color of the refraction (used to taint the rendering) */
  55854. color: Color3,
  55855. /** simulated refraction depth */
  55856. depth: number,
  55857. /** the coefficient of the base color (0 to remove base color tainting) */
  55858. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  55859. /**
  55860. * Disposes of the post process
  55861. * @param camera Camera to dispose post process on
  55862. */
  55863. dispose(camera: Camera): void;
  55864. }
  55865. }
  55866. declare module "babylonjs/Shaders/sharpen.fragment" {
  55867. /** @hidden */
  55868. export var sharpenPixelShader: {
  55869. name: string;
  55870. shader: string;
  55871. };
  55872. }
  55873. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  55874. import { Nullable } from "babylonjs/types";
  55875. import { Camera } from "babylonjs/Cameras/camera";
  55876. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55877. import "babylonjs/Shaders/sharpen.fragment";
  55878. import { Engine } from "babylonjs/Engines/engine";
  55879. /**
  55880. * The SharpenPostProcess applies a sharpen kernel to every pixel
  55881. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  55882. */
  55883. export class SharpenPostProcess extends PostProcess {
  55884. /**
  55885. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  55886. */
  55887. colorAmount: number;
  55888. /**
  55889. * How much sharpness should be applied (default: 0.3)
  55890. */
  55891. edgeAmount: number;
  55892. /**
  55893. * Creates a new instance ConvolutionPostProcess
  55894. * @param name The name of the effect.
  55895. * @param options The required width/height ratio to downsize to before computing the render pass.
  55896. * @param camera The camera to apply the render pass to.
  55897. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55898. * @param engine The engine which the post process will be applied. (default: current engine)
  55899. * @param reusable If the post process can be reused on the same frame. (default: false)
  55900. * @param textureType Type of textures used when performing the post process. (default: 0)
  55901. * @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)
  55902. */
  55903. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55904. }
  55905. }
  55906. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  55907. import { Nullable } from "babylonjs/types";
  55908. import { Camera } from "babylonjs/Cameras/camera";
  55909. import { Engine } from "babylonjs/Engines/engine";
  55910. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  55911. import { IInspectable } from "babylonjs/Misc/iInspectable";
  55912. /**
  55913. * PostProcessRenderPipeline
  55914. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55915. */
  55916. export class PostProcessRenderPipeline {
  55917. private engine;
  55918. private _renderEffects;
  55919. private _renderEffectsForIsolatedPass;
  55920. /**
  55921. * List of inspectable custom properties (used by the Inspector)
  55922. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  55923. */
  55924. inspectableCustomProperties: IInspectable[];
  55925. /**
  55926. * @hidden
  55927. */
  55928. protected _cameras: Camera[];
  55929. /** @hidden */
  55930. _name: string;
  55931. /**
  55932. * Gets pipeline name
  55933. */
  55934. readonly name: string;
  55935. /**
  55936. * Initializes a PostProcessRenderPipeline
  55937. * @param engine engine to add the pipeline to
  55938. * @param name name of the pipeline
  55939. */
  55940. constructor(engine: Engine, name: string);
  55941. /**
  55942. * Gets the class name
  55943. * @returns "PostProcessRenderPipeline"
  55944. */
  55945. getClassName(): string;
  55946. /**
  55947. * If all the render effects in the pipeline are supported
  55948. */
  55949. readonly isSupported: boolean;
  55950. /**
  55951. * Adds an effect to the pipeline
  55952. * @param renderEffect the effect to add
  55953. */
  55954. addEffect(renderEffect: PostProcessRenderEffect): void;
  55955. /** @hidden */
  55956. _rebuild(): void;
  55957. /** @hidden */
  55958. _enableEffect(renderEffectName: string, cameras: Camera): void;
  55959. /** @hidden */
  55960. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  55961. /** @hidden */
  55962. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  55963. /** @hidden */
  55964. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  55965. /** @hidden */
  55966. _attachCameras(cameras: Camera, unique: boolean): void;
  55967. /** @hidden */
  55968. _attachCameras(cameras: Camera[], unique: boolean): void;
  55969. /** @hidden */
  55970. _detachCameras(cameras: Camera): void;
  55971. /** @hidden */
  55972. _detachCameras(cameras: Nullable<Camera[]>): void;
  55973. /** @hidden */
  55974. _update(): void;
  55975. /** @hidden */
  55976. _reset(): void;
  55977. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  55978. /**
  55979. * Disposes of the pipeline
  55980. */
  55981. dispose(): void;
  55982. }
  55983. }
  55984. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  55985. import { Camera } from "babylonjs/Cameras/camera";
  55986. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  55987. /**
  55988. * PostProcessRenderPipelineManager class
  55989. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55990. */
  55991. export class PostProcessRenderPipelineManager {
  55992. private _renderPipelines;
  55993. /**
  55994. * Initializes a PostProcessRenderPipelineManager
  55995. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55996. */
  55997. constructor();
  55998. /**
  55999. * Gets the list of supported render pipelines
  56000. */
  56001. readonly supportedPipelines: PostProcessRenderPipeline[];
  56002. /**
  56003. * Adds a pipeline to the manager
  56004. * @param renderPipeline The pipeline to add
  56005. */
  56006. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  56007. /**
  56008. * Attaches a camera to the pipeline
  56009. * @param renderPipelineName The name of the pipeline to attach to
  56010. * @param cameras the camera to attach
  56011. * @param unique if the camera can be attached multiple times to the pipeline
  56012. */
  56013. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  56014. /**
  56015. * Detaches a camera from the pipeline
  56016. * @param renderPipelineName The name of the pipeline to detach from
  56017. * @param cameras the camera to detach
  56018. */
  56019. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  56020. /**
  56021. * Enables an effect by name on a pipeline
  56022. * @param renderPipelineName the name of the pipeline to enable the effect in
  56023. * @param renderEffectName the name of the effect to enable
  56024. * @param cameras the cameras that the effect should be enabled on
  56025. */
  56026. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  56027. /**
  56028. * Disables an effect by name on a pipeline
  56029. * @param renderPipelineName the name of the pipeline to disable the effect in
  56030. * @param renderEffectName the name of the effect to disable
  56031. * @param cameras the cameras that the effect should be disabled on
  56032. */
  56033. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  56034. /**
  56035. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  56036. */
  56037. update(): void;
  56038. /** @hidden */
  56039. _rebuild(): void;
  56040. /**
  56041. * Disposes of the manager and pipelines
  56042. */
  56043. dispose(): void;
  56044. }
  56045. }
  56046. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  56047. import { ISceneComponent } from "babylonjs/sceneComponent";
  56048. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  56049. import { Scene } from "babylonjs/scene";
  56050. module "babylonjs/scene" {
  56051. interface Scene {
  56052. /** @hidden (Backing field) */
  56053. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  56054. /**
  56055. * Gets the postprocess render pipeline manager
  56056. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  56057. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  56058. */
  56059. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  56060. }
  56061. }
  56062. /**
  56063. * Defines the Render Pipeline scene component responsible to rendering pipelines
  56064. */
  56065. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  56066. /**
  56067. * The component name helpfull to identify the component in the list of scene components.
  56068. */
  56069. readonly name: string;
  56070. /**
  56071. * The scene the component belongs to.
  56072. */
  56073. scene: Scene;
  56074. /**
  56075. * Creates a new instance of the component for the given scene
  56076. * @param scene Defines the scene to register the component in
  56077. */
  56078. constructor(scene: Scene);
  56079. /**
  56080. * Registers the component in a given scene
  56081. */
  56082. register(): void;
  56083. /**
  56084. * Rebuilds the elements related to this component in case of
  56085. * context lost for instance.
  56086. */
  56087. rebuild(): void;
  56088. /**
  56089. * Disposes the component and the associated ressources
  56090. */
  56091. dispose(): void;
  56092. private _gatherRenderTargets;
  56093. }
  56094. }
  56095. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  56096. import { Nullable } from "babylonjs/types";
  56097. import { IAnimatable } from "babylonjs/Misc/tools";
  56098. import { Camera } from "babylonjs/Cameras/camera";
  56099. import { IDisposable } from "babylonjs/scene";
  56100. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  56101. import { Scene } from "babylonjs/scene";
  56102. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  56103. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  56104. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  56105. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  56106. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  56107. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  56108. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  56109. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  56110. import { Animation } from "babylonjs/Animations/animation";
  56111. /**
  56112. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  56113. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  56114. */
  56115. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  56116. private _scene;
  56117. private _camerasToBeAttached;
  56118. /**
  56119. * ID of the sharpen post process,
  56120. */
  56121. private readonly SharpenPostProcessId;
  56122. /**
  56123. * @ignore
  56124. * ID of the image processing post process;
  56125. */
  56126. readonly ImageProcessingPostProcessId: string;
  56127. /**
  56128. * @ignore
  56129. * ID of the Fast Approximate Anti-Aliasing post process;
  56130. */
  56131. readonly FxaaPostProcessId: string;
  56132. /**
  56133. * ID of the chromatic aberration post process,
  56134. */
  56135. private readonly ChromaticAberrationPostProcessId;
  56136. /**
  56137. * ID of the grain post process
  56138. */
  56139. private readonly GrainPostProcessId;
  56140. /**
  56141. * Sharpen post process which will apply a sharpen convolution to enhance edges
  56142. */
  56143. sharpen: SharpenPostProcess;
  56144. private _sharpenEffect;
  56145. private bloom;
  56146. /**
  56147. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  56148. */
  56149. depthOfField: DepthOfFieldEffect;
  56150. /**
  56151. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  56152. */
  56153. fxaa: FxaaPostProcess;
  56154. /**
  56155. * Image post processing pass used to perform operations such as tone mapping or color grading.
  56156. */
  56157. imageProcessing: ImageProcessingPostProcess;
  56158. /**
  56159. * Chromatic aberration post process which will shift rgb colors in the image
  56160. */
  56161. chromaticAberration: ChromaticAberrationPostProcess;
  56162. private _chromaticAberrationEffect;
  56163. /**
  56164. * Grain post process which add noise to the image
  56165. */
  56166. grain: GrainPostProcess;
  56167. private _grainEffect;
  56168. /**
  56169. * Glow post process which adds a glow to emissive areas of the image
  56170. */
  56171. private _glowLayer;
  56172. /**
  56173. * Animations which can be used to tweak settings over a period of time
  56174. */
  56175. animations: Animation[];
  56176. private _imageProcessingConfigurationObserver;
  56177. private _sharpenEnabled;
  56178. private _bloomEnabled;
  56179. private _depthOfFieldEnabled;
  56180. private _depthOfFieldBlurLevel;
  56181. private _fxaaEnabled;
  56182. private _imageProcessingEnabled;
  56183. private _defaultPipelineTextureType;
  56184. private _bloomScale;
  56185. private _chromaticAberrationEnabled;
  56186. private _grainEnabled;
  56187. private _buildAllowed;
  56188. /**
  56189. * Gets active scene
  56190. */
  56191. readonly scene: Scene;
  56192. /**
  56193. * Enable or disable the sharpen process from the pipeline
  56194. */
  56195. sharpenEnabled: boolean;
  56196. private _resizeObserver;
  56197. private _hardwareScaleLevel;
  56198. private _bloomKernel;
  56199. /**
  56200. * Specifies the size of the bloom blur kernel, relative to the final output size
  56201. */
  56202. bloomKernel: number;
  56203. /**
  56204. * Specifies the weight of the bloom in the final rendering
  56205. */
  56206. private _bloomWeight;
  56207. /**
  56208. * Specifies the luma threshold for the area that will be blurred by the bloom
  56209. */
  56210. private _bloomThreshold;
  56211. private _hdr;
  56212. /**
  56213. * The strength of the bloom.
  56214. */
  56215. bloomWeight: number;
  56216. /**
  56217. * The strength of the bloom.
  56218. */
  56219. bloomThreshold: number;
  56220. /**
  56221. * The scale of the bloom, lower value will provide better performance.
  56222. */
  56223. bloomScale: number;
  56224. /**
  56225. * Enable or disable the bloom from the pipeline
  56226. */
  56227. bloomEnabled: boolean;
  56228. private _rebuildBloom;
  56229. /**
  56230. * If the depth of field is enabled.
  56231. */
  56232. depthOfFieldEnabled: boolean;
  56233. /**
  56234. * Blur level of the depth of field effect. (Higher blur will effect performance)
  56235. */
  56236. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  56237. /**
  56238. * If the anti aliasing is enabled.
  56239. */
  56240. fxaaEnabled: boolean;
  56241. private _samples;
  56242. /**
  56243. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  56244. */
  56245. samples: number;
  56246. /**
  56247. * If image processing is enabled.
  56248. */
  56249. imageProcessingEnabled: boolean;
  56250. /**
  56251. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  56252. */
  56253. glowLayerEnabled: boolean;
  56254. /**
  56255. * Gets the glow layer (or null if not defined)
  56256. */
  56257. readonly glowLayer: Nullable<GlowLayer>;
  56258. /**
  56259. * Enable or disable the chromaticAberration process from the pipeline
  56260. */
  56261. chromaticAberrationEnabled: boolean;
  56262. /**
  56263. * Enable or disable the grain process from the pipeline
  56264. */
  56265. grainEnabled: boolean;
  56266. /**
  56267. * @constructor
  56268. * @param name - The rendering pipeline name (default: "")
  56269. * @param hdr - If high dynamic range textures should be used (default: true)
  56270. * @param scene - The scene linked to this pipeline (default: the last created scene)
  56271. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  56272. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  56273. */
  56274. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  56275. /**
  56276. * Get the class name
  56277. * @returns "DefaultRenderingPipeline"
  56278. */
  56279. getClassName(): string;
  56280. /**
  56281. * Force the compilation of the entire pipeline.
  56282. */
  56283. prepare(): void;
  56284. private _hasCleared;
  56285. private _prevPostProcess;
  56286. private _prevPrevPostProcess;
  56287. private _setAutoClearAndTextureSharing;
  56288. private _depthOfFieldSceneObserver;
  56289. private _buildPipeline;
  56290. private _disposePostProcesses;
  56291. /**
  56292. * Adds a camera to the pipeline
  56293. * @param camera the camera to be added
  56294. */
  56295. addCamera(camera: Camera): void;
  56296. /**
  56297. * Removes a camera from the pipeline
  56298. * @param camera the camera to remove
  56299. */
  56300. removeCamera(camera: Camera): void;
  56301. /**
  56302. * Dispose of the pipeline and stop all post processes
  56303. */
  56304. dispose(): void;
  56305. /**
  56306. * Serialize the rendering pipeline (Used when exporting)
  56307. * @returns the serialized object
  56308. */
  56309. serialize(): any;
  56310. /**
  56311. * Parse the serialized pipeline
  56312. * @param source Source pipeline.
  56313. * @param scene The scene to load the pipeline to.
  56314. * @param rootUrl The URL of the serialized pipeline.
  56315. * @returns An instantiated pipeline from the serialized object.
  56316. */
  56317. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  56318. }
  56319. }
  56320. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  56321. /** @hidden */
  56322. export var lensHighlightsPixelShader: {
  56323. name: string;
  56324. shader: string;
  56325. };
  56326. }
  56327. declare module "babylonjs/Shaders/depthOfField.fragment" {
  56328. /** @hidden */
  56329. export var depthOfFieldPixelShader: {
  56330. name: string;
  56331. shader: string;
  56332. };
  56333. }
  56334. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  56335. import { Camera } from "babylonjs/Cameras/camera";
  56336. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  56337. import { Scene } from "babylonjs/scene";
  56338. import "babylonjs/Shaders/chromaticAberration.fragment";
  56339. import "babylonjs/Shaders/lensHighlights.fragment";
  56340. import "babylonjs/Shaders/depthOfField.fragment";
  56341. /**
  56342. * BABYLON.JS Chromatic Aberration GLSL Shader
  56343. * Author: Olivier Guyot
  56344. * Separates very slightly R, G and B colors on the edges of the screen
  56345. * Inspired by Francois Tarlier & Martins Upitis
  56346. */
  56347. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  56348. /**
  56349. * @ignore
  56350. * The chromatic aberration PostProcess id in the pipeline
  56351. */
  56352. LensChromaticAberrationEffect: string;
  56353. /**
  56354. * @ignore
  56355. * The highlights enhancing PostProcess id in the pipeline
  56356. */
  56357. HighlightsEnhancingEffect: string;
  56358. /**
  56359. * @ignore
  56360. * The depth-of-field PostProcess id in the pipeline
  56361. */
  56362. LensDepthOfFieldEffect: string;
  56363. private _scene;
  56364. private _depthTexture;
  56365. private _grainTexture;
  56366. private _chromaticAberrationPostProcess;
  56367. private _highlightsPostProcess;
  56368. private _depthOfFieldPostProcess;
  56369. private _edgeBlur;
  56370. private _grainAmount;
  56371. private _chromaticAberration;
  56372. private _distortion;
  56373. private _highlightsGain;
  56374. private _highlightsThreshold;
  56375. private _dofDistance;
  56376. private _dofAperture;
  56377. private _dofDarken;
  56378. private _dofPentagon;
  56379. private _blurNoise;
  56380. /**
  56381. * @constructor
  56382. *
  56383. * Effect parameters are as follow:
  56384. * {
  56385. * chromatic_aberration: number; // from 0 to x (1 for realism)
  56386. * edge_blur: number; // from 0 to x (1 for realism)
  56387. * distortion: number; // from 0 to x (1 for realism)
  56388. * grain_amount: number; // from 0 to 1
  56389. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  56390. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  56391. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  56392. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  56393. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  56394. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  56395. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  56396. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  56397. * }
  56398. * Note: if an effect parameter is unset, effect is disabled
  56399. *
  56400. * @param name The rendering pipeline name
  56401. * @param parameters - An object containing all parameters (see above)
  56402. * @param scene The scene linked to this pipeline
  56403. * @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)
  56404. * @param cameras The array of cameras that the rendering pipeline will be attached to
  56405. */
  56406. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  56407. /**
  56408. * Get the class name
  56409. * @returns "LensRenderingPipeline"
  56410. */
  56411. getClassName(): string;
  56412. /**
  56413. * Gets associated scene
  56414. */
  56415. readonly scene: Scene;
  56416. /**
  56417. * Gets or sets the edge blur
  56418. */
  56419. edgeBlur: number;
  56420. /**
  56421. * Gets or sets the grain amount
  56422. */
  56423. grainAmount: number;
  56424. /**
  56425. * Gets or sets the chromatic aberration amount
  56426. */
  56427. chromaticAberration: number;
  56428. /**
  56429. * Gets or sets the depth of field aperture
  56430. */
  56431. dofAperture: number;
  56432. /**
  56433. * Gets or sets the edge distortion
  56434. */
  56435. edgeDistortion: number;
  56436. /**
  56437. * Gets or sets the depth of field distortion
  56438. */
  56439. dofDistortion: number;
  56440. /**
  56441. * Gets or sets the darken out of focus amount
  56442. */
  56443. darkenOutOfFocus: number;
  56444. /**
  56445. * Gets or sets a boolean indicating if blur noise is enabled
  56446. */
  56447. blurNoise: boolean;
  56448. /**
  56449. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  56450. */
  56451. pentagonBokeh: boolean;
  56452. /**
  56453. * Gets or sets the highlight grain amount
  56454. */
  56455. highlightsGain: number;
  56456. /**
  56457. * Gets or sets the highlight threshold
  56458. */
  56459. highlightsThreshold: number;
  56460. /**
  56461. * Sets the amount of blur at the edges
  56462. * @param amount blur amount
  56463. */
  56464. setEdgeBlur(amount: number): void;
  56465. /**
  56466. * Sets edge blur to 0
  56467. */
  56468. disableEdgeBlur(): void;
  56469. /**
  56470. * Sets the amout of grain
  56471. * @param amount Amount of grain
  56472. */
  56473. setGrainAmount(amount: number): void;
  56474. /**
  56475. * Set grain amount to 0
  56476. */
  56477. disableGrain(): void;
  56478. /**
  56479. * Sets the chromatic aberration amount
  56480. * @param amount amount of chromatic aberration
  56481. */
  56482. setChromaticAberration(amount: number): void;
  56483. /**
  56484. * Sets chromatic aberration amount to 0
  56485. */
  56486. disableChromaticAberration(): void;
  56487. /**
  56488. * Sets the EdgeDistortion amount
  56489. * @param amount amount of EdgeDistortion
  56490. */
  56491. setEdgeDistortion(amount: number): void;
  56492. /**
  56493. * Sets edge distortion to 0
  56494. */
  56495. disableEdgeDistortion(): void;
  56496. /**
  56497. * Sets the FocusDistance amount
  56498. * @param amount amount of FocusDistance
  56499. */
  56500. setFocusDistance(amount: number): void;
  56501. /**
  56502. * Disables depth of field
  56503. */
  56504. disableDepthOfField(): void;
  56505. /**
  56506. * Sets the Aperture amount
  56507. * @param amount amount of Aperture
  56508. */
  56509. setAperture(amount: number): void;
  56510. /**
  56511. * Sets the DarkenOutOfFocus amount
  56512. * @param amount amount of DarkenOutOfFocus
  56513. */
  56514. setDarkenOutOfFocus(amount: number): void;
  56515. private _pentagonBokehIsEnabled;
  56516. /**
  56517. * Creates a pentagon bokeh effect
  56518. */
  56519. enablePentagonBokeh(): void;
  56520. /**
  56521. * Disables the pentagon bokeh effect
  56522. */
  56523. disablePentagonBokeh(): void;
  56524. /**
  56525. * Enables noise blur
  56526. */
  56527. enableNoiseBlur(): void;
  56528. /**
  56529. * Disables noise blur
  56530. */
  56531. disableNoiseBlur(): void;
  56532. /**
  56533. * Sets the HighlightsGain amount
  56534. * @param amount amount of HighlightsGain
  56535. */
  56536. setHighlightsGain(amount: number): void;
  56537. /**
  56538. * Sets the HighlightsThreshold amount
  56539. * @param amount amount of HighlightsThreshold
  56540. */
  56541. setHighlightsThreshold(amount: number): void;
  56542. /**
  56543. * Disables highlights
  56544. */
  56545. disableHighlights(): void;
  56546. /**
  56547. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  56548. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  56549. */
  56550. dispose(disableDepthRender?: boolean): void;
  56551. private _createChromaticAberrationPostProcess;
  56552. private _createHighlightsPostProcess;
  56553. private _createDepthOfFieldPostProcess;
  56554. private _createGrainTexture;
  56555. }
  56556. }
  56557. declare module "babylonjs/Shaders/ssao2.fragment" {
  56558. /** @hidden */
  56559. export var ssao2PixelShader: {
  56560. name: string;
  56561. shader: string;
  56562. };
  56563. }
  56564. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  56565. /** @hidden */
  56566. export var ssaoCombinePixelShader: {
  56567. name: string;
  56568. shader: string;
  56569. };
  56570. }
  56571. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  56572. import { Camera } from "babylonjs/Cameras/camera";
  56573. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  56574. import { Scene } from "babylonjs/scene";
  56575. import "babylonjs/Shaders/ssao2.fragment";
  56576. import "babylonjs/Shaders/ssaoCombine.fragment";
  56577. /**
  56578. * Render pipeline to produce ssao effect
  56579. */
  56580. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  56581. /**
  56582. * @ignore
  56583. * The PassPostProcess id in the pipeline that contains the original scene color
  56584. */
  56585. SSAOOriginalSceneColorEffect: string;
  56586. /**
  56587. * @ignore
  56588. * The SSAO PostProcess id in the pipeline
  56589. */
  56590. SSAORenderEffect: string;
  56591. /**
  56592. * @ignore
  56593. * The horizontal blur PostProcess id in the pipeline
  56594. */
  56595. SSAOBlurHRenderEffect: string;
  56596. /**
  56597. * @ignore
  56598. * The vertical blur PostProcess id in the pipeline
  56599. */
  56600. SSAOBlurVRenderEffect: string;
  56601. /**
  56602. * @ignore
  56603. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  56604. */
  56605. SSAOCombineRenderEffect: string;
  56606. /**
  56607. * The output strength of the SSAO post-process. Default value is 1.0.
  56608. */
  56609. totalStrength: number;
  56610. /**
  56611. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  56612. */
  56613. maxZ: number;
  56614. /**
  56615. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  56616. */
  56617. minZAspect: number;
  56618. private _samples;
  56619. /**
  56620. * Number of samples used for the SSAO calculations. Default value is 8
  56621. */
  56622. samples: number;
  56623. private _textureSamples;
  56624. /**
  56625. * Number of samples to use for antialiasing
  56626. */
  56627. textureSamples: number;
  56628. /**
  56629. * Ratio object used for SSAO ratio and blur ratio
  56630. */
  56631. private _ratio;
  56632. /**
  56633. * Dynamically generated sphere sampler.
  56634. */
  56635. private _sampleSphere;
  56636. /**
  56637. * Blur filter offsets
  56638. */
  56639. private _samplerOffsets;
  56640. private _expensiveBlur;
  56641. /**
  56642. * If bilateral blur should be used
  56643. */
  56644. expensiveBlur: boolean;
  56645. /**
  56646. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  56647. */
  56648. radius: number;
  56649. /**
  56650. * The base color of the SSAO post-process
  56651. * The final result is "base + ssao" between [0, 1]
  56652. */
  56653. base: number;
  56654. /**
  56655. * Support test.
  56656. */
  56657. static readonly IsSupported: boolean;
  56658. private _scene;
  56659. private _depthTexture;
  56660. private _normalTexture;
  56661. private _randomTexture;
  56662. private _originalColorPostProcess;
  56663. private _ssaoPostProcess;
  56664. private _blurHPostProcess;
  56665. private _blurVPostProcess;
  56666. private _ssaoCombinePostProcess;
  56667. private _firstUpdate;
  56668. /**
  56669. * Gets active scene
  56670. */
  56671. readonly scene: Scene;
  56672. /**
  56673. * @constructor
  56674. * @param name The rendering pipeline name
  56675. * @param scene The scene linked to this pipeline
  56676. * @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 }
  56677. * @param cameras The array of cameras that the rendering pipeline will be attached to
  56678. */
  56679. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  56680. /**
  56681. * Get the class name
  56682. * @returns "SSAO2RenderingPipeline"
  56683. */
  56684. getClassName(): string;
  56685. /**
  56686. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  56687. */
  56688. dispose(disableGeometryBufferRenderer?: boolean): void;
  56689. private _createBlurPostProcess;
  56690. /** @hidden */
  56691. _rebuild(): void;
  56692. private _bits;
  56693. private _radicalInverse_VdC;
  56694. private _hammersley;
  56695. private _hemisphereSample_uniform;
  56696. private _generateHemisphere;
  56697. private _createSSAOPostProcess;
  56698. private _createSSAOCombinePostProcess;
  56699. private _createRandomTexture;
  56700. /**
  56701. * Serialize the rendering pipeline (Used when exporting)
  56702. * @returns the serialized object
  56703. */
  56704. serialize(): any;
  56705. /**
  56706. * Parse the serialized pipeline
  56707. * @param source Source pipeline.
  56708. * @param scene The scene to load the pipeline to.
  56709. * @param rootUrl The URL of the serialized pipeline.
  56710. * @returns An instantiated pipeline from the serialized object.
  56711. */
  56712. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  56713. }
  56714. }
  56715. declare module "babylonjs/Shaders/ssao.fragment" {
  56716. /** @hidden */
  56717. export var ssaoPixelShader: {
  56718. name: string;
  56719. shader: string;
  56720. };
  56721. }
  56722. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  56723. import { Camera } from "babylonjs/Cameras/camera";
  56724. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  56725. import { Scene } from "babylonjs/scene";
  56726. import "babylonjs/Shaders/ssao.fragment";
  56727. import "babylonjs/Shaders/ssaoCombine.fragment";
  56728. /**
  56729. * Render pipeline to produce ssao effect
  56730. */
  56731. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  56732. /**
  56733. * @ignore
  56734. * The PassPostProcess id in the pipeline that contains the original scene color
  56735. */
  56736. SSAOOriginalSceneColorEffect: string;
  56737. /**
  56738. * @ignore
  56739. * The SSAO PostProcess id in the pipeline
  56740. */
  56741. SSAORenderEffect: string;
  56742. /**
  56743. * @ignore
  56744. * The horizontal blur PostProcess id in the pipeline
  56745. */
  56746. SSAOBlurHRenderEffect: string;
  56747. /**
  56748. * @ignore
  56749. * The vertical blur PostProcess id in the pipeline
  56750. */
  56751. SSAOBlurVRenderEffect: string;
  56752. /**
  56753. * @ignore
  56754. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  56755. */
  56756. SSAOCombineRenderEffect: string;
  56757. /**
  56758. * The output strength of the SSAO post-process. Default value is 1.0.
  56759. */
  56760. totalStrength: number;
  56761. /**
  56762. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  56763. */
  56764. radius: number;
  56765. /**
  56766. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  56767. * Must not be equal to fallOff and superior to fallOff.
  56768. * Default value is 0.0075
  56769. */
  56770. area: number;
  56771. /**
  56772. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  56773. * Must not be equal to area and inferior to area.
  56774. * Default value is 0.000001
  56775. */
  56776. fallOff: number;
  56777. /**
  56778. * The base color of the SSAO post-process
  56779. * The final result is "base + ssao" between [0, 1]
  56780. */
  56781. base: number;
  56782. private _scene;
  56783. private _depthTexture;
  56784. private _randomTexture;
  56785. private _originalColorPostProcess;
  56786. private _ssaoPostProcess;
  56787. private _blurHPostProcess;
  56788. private _blurVPostProcess;
  56789. private _ssaoCombinePostProcess;
  56790. private _firstUpdate;
  56791. /**
  56792. * Gets active scene
  56793. */
  56794. readonly scene: Scene;
  56795. /**
  56796. * @constructor
  56797. * @param name - The rendering pipeline name
  56798. * @param scene - The scene linked to this pipeline
  56799. * @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 }
  56800. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  56801. */
  56802. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  56803. /**
  56804. * Get the class name
  56805. * @returns "SSAORenderingPipeline"
  56806. */
  56807. getClassName(): string;
  56808. /**
  56809. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  56810. */
  56811. dispose(disableDepthRender?: boolean): void;
  56812. private _createBlurPostProcess;
  56813. /** @hidden */
  56814. _rebuild(): void;
  56815. private _createSSAOPostProcess;
  56816. private _createSSAOCombinePostProcess;
  56817. private _createRandomTexture;
  56818. }
  56819. }
  56820. declare module "babylonjs/Shaders/standard.fragment" {
  56821. /** @hidden */
  56822. export var standardPixelShader: {
  56823. name: string;
  56824. shader: string;
  56825. };
  56826. }
  56827. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  56828. import { Nullable } from "babylonjs/types";
  56829. import { IAnimatable } from "babylonjs/Misc/tools";
  56830. import { Camera } from "babylonjs/Cameras/camera";
  56831. import { Texture } from "babylonjs/Materials/Textures/texture";
  56832. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  56833. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  56834. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  56835. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  56836. import { IDisposable } from "babylonjs/scene";
  56837. import { SpotLight } from "babylonjs/Lights/spotLight";
  56838. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  56839. import { Scene } from "babylonjs/scene";
  56840. import { Animation } from "babylonjs/Animations/animation";
  56841. import "babylonjs/Shaders/standard.fragment";
  56842. /**
  56843. * Standard rendering pipeline
  56844. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  56845. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  56846. */
  56847. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  56848. /**
  56849. * Public members
  56850. */
  56851. /**
  56852. * Post-process which contains the original scene color before the pipeline applies all the effects
  56853. */
  56854. originalPostProcess: Nullable<PostProcess>;
  56855. /**
  56856. * Post-process used to down scale an image x4
  56857. */
  56858. downSampleX4PostProcess: Nullable<PostProcess>;
  56859. /**
  56860. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  56861. */
  56862. brightPassPostProcess: Nullable<PostProcess>;
  56863. /**
  56864. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  56865. */
  56866. blurHPostProcesses: PostProcess[];
  56867. /**
  56868. * Post-process array storing all the vertical blur post-processes used by the pipeline
  56869. */
  56870. blurVPostProcesses: PostProcess[];
  56871. /**
  56872. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  56873. */
  56874. textureAdderPostProcess: Nullable<PostProcess>;
  56875. /**
  56876. * Post-process used to create volumetric lighting effect
  56877. */
  56878. volumetricLightPostProcess: Nullable<PostProcess>;
  56879. /**
  56880. * Post-process used to smooth the previous volumetric light post-process on the X axis
  56881. */
  56882. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  56883. /**
  56884. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  56885. */
  56886. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  56887. /**
  56888. * Post-process used to merge the volumetric light effect and the real scene color
  56889. */
  56890. volumetricLightMergePostProces: Nullable<PostProcess>;
  56891. /**
  56892. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  56893. */
  56894. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  56895. /**
  56896. * Base post-process used to calculate the average luminance of the final image for HDR
  56897. */
  56898. luminancePostProcess: Nullable<PostProcess>;
  56899. /**
  56900. * Post-processes used to create down sample post-processes in order to get
  56901. * the average luminance of the final image for HDR
  56902. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  56903. */
  56904. luminanceDownSamplePostProcesses: PostProcess[];
  56905. /**
  56906. * Post-process used to create a HDR effect (light adaptation)
  56907. */
  56908. hdrPostProcess: Nullable<PostProcess>;
  56909. /**
  56910. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  56911. */
  56912. textureAdderFinalPostProcess: Nullable<PostProcess>;
  56913. /**
  56914. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  56915. */
  56916. lensFlareFinalPostProcess: Nullable<PostProcess>;
  56917. /**
  56918. * Post-process used to merge the final HDR post-process and the real scene color
  56919. */
  56920. hdrFinalPostProcess: Nullable<PostProcess>;
  56921. /**
  56922. * Post-process used to create a lens flare effect
  56923. */
  56924. lensFlarePostProcess: Nullable<PostProcess>;
  56925. /**
  56926. * Post-process that merges the result of the lens flare post-process and the real scene color
  56927. */
  56928. lensFlareComposePostProcess: Nullable<PostProcess>;
  56929. /**
  56930. * Post-process used to create a motion blur effect
  56931. */
  56932. motionBlurPostProcess: Nullable<PostProcess>;
  56933. /**
  56934. * Post-process used to create a depth of field effect
  56935. */
  56936. depthOfFieldPostProcess: Nullable<PostProcess>;
  56937. /**
  56938. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  56939. */
  56940. fxaaPostProcess: Nullable<FxaaPostProcess>;
  56941. /**
  56942. * Represents the brightness threshold in order to configure the illuminated surfaces
  56943. */
  56944. brightThreshold: number;
  56945. /**
  56946. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  56947. */
  56948. blurWidth: number;
  56949. /**
  56950. * Sets if the blur for highlighted surfaces must be only horizontal
  56951. */
  56952. horizontalBlur: boolean;
  56953. /**
  56954. * Gets the overall exposure used by the pipeline
  56955. */
  56956. /**
  56957. * Sets the overall exposure used by the pipeline
  56958. */
  56959. exposure: number;
  56960. /**
  56961. * Texture used typically to simulate "dirty" on camera lens
  56962. */
  56963. lensTexture: Nullable<Texture>;
  56964. /**
  56965. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  56966. */
  56967. volumetricLightCoefficient: number;
  56968. /**
  56969. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  56970. */
  56971. volumetricLightPower: number;
  56972. /**
  56973. * Used the set the blur intensity to smooth the volumetric lights
  56974. */
  56975. volumetricLightBlurScale: number;
  56976. /**
  56977. * Light (spot or directional) used to generate the volumetric lights rays
  56978. * The source light must have a shadow generate so the pipeline can get its
  56979. * depth map
  56980. */
  56981. sourceLight: Nullable<SpotLight | DirectionalLight>;
  56982. /**
  56983. * For eye adaptation, represents the minimum luminance the eye can see
  56984. */
  56985. hdrMinimumLuminance: number;
  56986. /**
  56987. * For eye adaptation, represents the decrease luminance speed
  56988. */
  56989. hdrDecreaseRate: number;
  56990. /**
  56991. * For eye adaptation, represents the increase luminance speed
  56992. */
  56993. hdrIncreaseRate: number;
  56994. /**
  56995. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  56996. */
  56997. /**
  56998. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  56999. */
  57000. hdrAutoExposure: boolean;
  57001. /**
  57002. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  57003. */
  57004. lensColorTexture: Nullable<Texture>;
  57005. /**
  57006. * The overall strengh for the lens flare effect
  57007. */
  57008. lensFlareStrength: number;
  57009. /**
  57010. * Dispersion coefficient for lens flare ghosts
  57011. */
  57012. lensFlareGhostDispersal: number;
  57013. /**
  57014. * Main lens flare halo width
  57015. */
  57016. lensFlareHaloWidth: number;
  57017. /**
  57018. * Based on the lens distortion effect, defines how much the lens flare result
  57019. * is distorted
  57020. */
  57021. lensFlareDistortionStrength: number;
  57022. /**
  57023. * Lens star texture must be used to simulate rays on the flares and is available
  57024. * in the documentation
  57025. */
  57026. lensStarTexture: Nullable<Texture>;
  57027. /**
  57028. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  57029. * flare effect by taking account of the dirt texture
  57030. */
  57031. lensFlareDirtTexture: Nullable<Texture>;
  57032. /**
  57033. * Represents the focal length for the depth of field effect
  57034. */
  57035. depthOfFieldDistance: number;
  57036. /**
  57037. * Represents the blur intensity for the blurred part of the depth of field effect
  57038. */
  57039. depthOfFieldBlurWidth: number;
  57040. /**
  57041. * For motion blur, defines how much the image is blurred by the movement
  57042. */
  57043. motionStrength: number;
  57044. /**
  57045. * List of animations for the pipeline (IAnimatable implementation)
  57046. */
  57047. animations: Animation[];
  57048. /**
  57049. * Private members
  57050. */
  57051. private _scene;
  57052. private _currentDepthOfFieldSource;
  57053. private _basePostProcess;
  57054. private _fixedExposure;
  57055. private _currentExposure;
  57056. private _hdrAutoExposure;
  57057. private _hdrCurrentLuminance;
  57058. private _floatTextureType;
  57059. private _ratio;
  57060. private _bloomEnabled;
  57061. private _depthOfFieldEnabled;
  57062. private _vlsEnabled;
  57063. private _lensFlareEnabled;
  57064. private _hdrEnabled;
  57065. private _motionBlurEnabled;
  57066. private _fxaaEnabled;
  57067. private _motionBlurSamples;
  57068. private _volumetricLightStepsCount;
  57069. private _samples;
  57070. /**
  57071. * @ignore
  57072. * Specifies if the bloom pipeline is enabled
  57073. */
  57074. BloomEnabled: boolean;
  57075. /**
  57076. * @ignore
  57077. * Specifies if the depth of field pipeline is enabed
  57078. */
  57079. DepthOfFieldEnabled: boolean;
  57080. /**
  57081. * @ignore
  57082. * Specifies if the lens flare pipeline is enabed
  57083. */
  57084. LensFlareEnabled: boolean;
  57085. /**
  57086. * @ignore
  57087. * Specifies if the HDR pipeline is enabled
  57088. */
  57089. HDREnabled: boolean;
  57090. /**
  57091. * @ignore
  57092. * Specifies if the volumetric lights scattering effect is enabled
  57093. */
  57094. VLSEnabled: boolean;
  57095. /**
  57096. * @ignore
  57097. * Specifies if the motion blur effect is enabled
  57098. */
  57099. MotionBlurEnabled: boolean;
  57100. /**
  57101. * Specifies if anti-aliasing is enabled
  57102. */
  57103. fxaaEnabled: boolean;
  57104. /**
  57105. * Specifies the number of steps used to calculate the volumetric lights
  57106. * Typically in interval [50, 200]
  57107. */
  57108. volumetricLightStepsCount: number;
  57109. /**
  57110. * Specifies the number of samples used for the motion blur effect
  57111. * Typically in interval [16, 64]
  57112. */
  57113. motionBlurSamples: number;
  57114. /**
  57115. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  57116. */
  57117. samples: number;
  57118. /**
  57119. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  57120. * @constructor
  57121. * @param name The rendering pipeline name
  57122. * @param scene The scene linked to this pipeline
  57123. * @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)
  57124. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  57125. * @param cameras The array of cameras that the rendering pipeline will be attached to
  57126. */
  57127. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  57128. private _buildPipeline;
  57129. private _createDownSampleX4PostProcess;
  57130. private _createBrightPassPostProcess;
  57131. private _createBlurPostProcesses;
  57132. private _createTextureAdderPostProcess;
  57133. private _createVolumetricLightPostProcess;
  57134. private _createLuminancePostProcesses;
  57135. private _createHdrPostProcess;
  57136. private _createLensFlarePostProcess;
  57137. private _createDepthOfFieldPostProcess;
  57138. private _createMotionBlurPostProcess;
  57139. private _getDepthTexture;
  57140. private _disposePostProcesses;
  57141. /**
  57142. * Dispose of the pipeline and stop all post processes
  57143. */
  57144. dispose(): void;
  57145. /**
  57146. * Serialize the rendering pipeline (Used when exporting)
  57147. * @returns the serialized object
  57148. */
  57149. serialize(): any;
  57150. /**
  57151. * Parse the serialized pipeline
  57152. * @param source Source pipeline.
  57153. * @param scene The scene to load the pipeline to.
  57154. * @param rootUrl The URL of the serialized pipeline.
  57155. * @returns An instantiated pipeline from the serialized object.
  57156. */
  57157. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  57158. /**
  57159. * Luminance steps
  57160. */
  57161. static LuminanceSteps: number;
  57162. }
  57163. }
  57164. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  57165. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  57166. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  57167. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  57168. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  57169. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  57170. }
  57171. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  57172. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  57173. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  57174. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  57175. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  57176. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  57177. }
  57178. declare module "babylonjs/Shaders/tonemap.fragment" {
  57179. /** @hidden */
  57180. export var tonemapPixelShader: {
  57181. name: string;
  57182. shader: string;
  57183. };
  57184. }
  57185. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  57186. import { Camera } from "babylonjs/Cameras/camera";
  57187. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  57188. import "babylonjs/Shaders/tonemap.fragment";
  57189. import { Engine } from "babylonjs/Engines/engine";
  57190. /** Defines operator used for tonemapping */
  57191. export enum TonemappingOperator {
  57192. /** Hable */
  57193. Hable = 0,
  57194. /** Reinhard */
  57195. Reinhard = 1,
  57196. /** HejiDawson */
  57197. HejiDawson = 2,
  57198. /** Photographic */
  57199. Photographic = 3
  57200. }
  57201. /**
  57202. * Defines a post process to apply tone mapping
  57203. */
  57204. export class TonemapPostProcess extends PostProcess {
  57205. private _operator;
  57206. /** Defines the required exposure adjustement */
  57207. exposureAdjustment: number;
  57208. /**
  57209. * Creates a new TonemapPostProcess
  57210. * @param name defines the name of the postprocess
  57211. * @param _operator defines the operator to use
  57212. * @param exposureAdjustment defines the required exposure adjustement
  57213. * @param camera defines the camera to use (can be null)
  57214. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  57215. * @param engine defines the hosting engine (can be ignore if camera is set)
  57216. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  57217. */
  57218. constructor(name: string, _operator: TonemappingOperator,
  57219. /** Defines the required exposure adjustement */
  57220. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  57221. }
  57222. }
  57223. declare module "babylonjs/Shaders/depth.vertex" {
  57224. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  57225. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  57226. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  57227. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  57228. /** @hidden */
  57229. export var depthVertexShader: {
  57230. name: string;
  57231. shader: string;
  57232. };
  57233. }
  57234. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  57235. /** @hidden */
  57236. export var volumetricLightScatteringPixelShader: {
  57237. name: string;
  57238. shader: string;
  57239. };
  57240. }
  57241. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  57242. /** @hidden */
  57243. export var volumetricLightScatteringPassPixelShader: {
  57244. name: string;
  57245. shader: string;
  57246. };
  57247. }
  57248. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  57249. import { Vector3 } from "babylonjs/Maths/math";
  57250. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57251. import { Mesh } from "babylonjs/Meshes/mesh";
  57252. import { Camera } from "babylonjs/Cameras/camera";
  57253. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57254. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  57255. import { Scene } from "babylonjs/scene";
  57256. import "babylonjs/Meshes/Builders/planeBuilder";
  57257. import "babylonjs/Shaders/depth.vertex";
  57258. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  57259. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  57260. import { Engine } from "babylonjs/Engines/engine";
  57261. /**
  57262. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  57263. */
  57264. export class VolumetricLightScatteringPostProcess extends PostProcess {
  57265. private _volumetricLightScatteringPass;
  57266. private _volumetricLightScatteringRTT;
  57267. private _viewPort;
  57268. private _screenCoordinates;
  57269. private _cachedDefines;
  57270. /**
  57271. * If not undefined, the mesh position is computed from the attached node position
  57272. */
  57273. attachedNode: {
  57274. position: Vector3;
  57275. };
  57276. /**
  57277. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  57278. */
  57279. customMeshPosition: Vector3;
  57280. /**
  57281. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  57282. */
  57283. useCustomMeshPosition: boolean;
  57284. /**
  57285. * If the post-process should inverse the light scattering direction
  57286. */
  57287. invert: boolean;
  57288. /**
  57289. * The internal mesh used by the post-process
  57290. */
  57291. mesh: Mesh;
  57292. /**
  57293. * @hidden
  57294. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  57295. */
  57296. useDiffuseColor: boolean;
  57297. /**
  57298. * Array containing the excluded meshes not rendered in the internal pass
  57299. */
  57300. excludedMeshes: AbstractMesh[];
  57301. /**
  57302. * Controls the overall intensity of the post-process
  57303. */
  57304. exposure: number;
  57305. /**
  57306. * Dissipates each sample's contribution in range [0, 1]
  57307. */
  57308. decay: number;
  57309. /**
  57310. * Controls the overall intensity of each sample
  57311. */
  57312. weight: number;
  57313. /**
  57314. * Controls the density of each sample
  57315. */
  57316. density: number;
  57317. /**
  57318. * @constructor
  57319. * @param name The post-process name
  57320. * @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)
  57321. * @param camera The camera that the post-process will be attached to
  57322. * @param mesh The mesh used to create the light scattering
  57323. * @param samples The post-process quality, default 100
  57324. * @param samplingModeThe post-process filtering mode
  57325. * @param engine The babylon engine
  57326. * @param reusable If the post-process is reusable
  57327. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  57328. */
  57329. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  57330. /**
  57331. * Returns the string "VolumetricLightScatteringPostProcess"
  57332. * @returns "VolumetricLightScatteringPostProcess"
  57333. */
  57334. getClassName(): string;
  57335. private _isReady;
  57336. /**
  57337. * Sets the new light position for light scattering effect
  57338. * @param position The new custom light position
  57339. */
  57340. setCustomMeshPosition(position: Vector3): void;
  57341. /**
  57342. * Returns the light position for light scattering effect
  57343. * @return Vector3 The custom light position
  57344. */
  57345. getCustomMeshPosition(): Vector3;
  57346. /**
  57347. * Disposes the internal assets and detaches the post-process from the camera
  57348. */
  57349. dispose(camera: Camera): void;
  57350. /**
  57351. * Returns the render target texture used by the post-process
  57352. * @return the render target texture used by the post-process
  57353. */
  57354. getPass(): RenderTargetTexture;
  57355. private _meshExcluded;
  57356. private _createPass;
  57357. private _updateMeshScreenCoordinates;
  57358. /**
  57359. * Creates a default mesh for the Volumeric Light Scattering post-process
  57360. * @param name The mesh name
  57361. * @param scene The scene where to create the mesh
  57362. * @return the default mesh
  57363. */
  57364. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  57365. }
  57366. }
  57367. declare module "babylonjs/PostProcesses/index" {
  57368. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  57369. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  57370. export * from "babylonjs/PostProcesses/bloomEffect";
  57371. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  57372. export * from "babylonjs/PostProcesses/blurPostProcess";
  57373. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  57374. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  57375. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  57376. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  57377. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  57378. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  57379. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  57380. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  57381. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  57382. export * from "babylonjs/PostProcesses/filterPostProcess";
  57383. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  57384. export * from "babylonjs/PostProcesses/grainPostProcess";
  57385. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  57386. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  57387. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  57388. export * from "babylonjs/PostProcesses/passPostProcess";
  57389. export * from "babylonjs/PostProcesses/postProcess";
  57390. export * from "babylonjs/PostProcesses/postProcessManager";
  57391. export * from "babylonjs/PostProcesses/refractionPostProcess";
  57392. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  57393. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  57394. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  57395. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  57396. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  57397. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  57398. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  57399. }
  57400. declare module "babylonjs/Probes/index" {
  57401. export * from "babylonjs/Probes/reflectionProbe";
  57402. }
  57403. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  57404. import { Scene } from "babylonjs/scene";
  57405. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57406. import { Color3 } from "babylonjs/Maths/math";
  57407. import { SmartArray } from "babylonjs/Misc/smartArray";
  57408. import { ISceneComponent } from "babylonjs/sceneComponent";
  57409. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  57410. import "babylonjs/Meshes/Builders/boxBuilder";
  57411. import "babylonjs/Shaders/color.fragment";
  57412. import "babylonjs/Shaders/color.vertex";
  57413. module "babylonjs/scene" {
  57414. interface Scene {
  57415. /** @hidden (Backing field) */
  57416. _boundingBoxRenderer: BoundingBoxRenderer;
  57417. /** @hidden (Backing field) */
  57418. _forceShowBoundingBoxes: boolean;
  57419. /**
  57420. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  57421. */
  57422. forceShowBoundingBoxes: boolean;
  57423. /**
  57424. * Gets the bounding box renderer associated with the scene
  57425. * @returns a BoundingBoxRenderer
  57426. */
  57427. getBoundingBoxRenderer(): BoundingBoxRenderer;
  57428. }
  57429. }
  57430. module "babylonjs/Meshes/abstractMesh" {
  57431. interface AbstractMesh {
  57432. /** @hidden (Backing field) */
  57433. _showBoundingBox: boolean;
  57434. /**
  57435. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  57436. */
  57437. showBoundingBox: boolean;
  57438. }
  57439. }
  57440. /**
  57441. * Component responsible of rendering the bounding box of the meshes in a scene.
  57442. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  57443. */
  57444. export class BoundingBoxRenderer implements ISceneComponent {
  57445. /**
  57446. * The component name helpfull to identify the component in the list of scene components.
  57447. */
  57448. readonly name: string;
  57449. /**
  57450. * The scene the component belongs to.
  57451. */
  57452. scene: Scene;
  57453. /**
  57454. * Color of the bounding box lines placed in front of an object
  57455. */
  57456. frontColor: Color3;
  57457. /**
  57458. * Color of the bounding box lines placed behind an object
  57459. */
  57460. backColor: Color3;
  57461. /**
  57462. * Defines if the renderer should show the back lines or not
  57463. */
  57464. showBackLines: boolean;
  57465. /**
  57466. * @hidden
  57467. */
  57468. renderList: SmartArray<BoundingBox>;
  57469. private _colorShader;
  57470. private _vertexBuffers;
  57471. private _indexBuffer;
  57472. /**
  57473. * Instantiates a new bounding box renderer in a scene.
  57474. * @param scene the scene the renderer renders in
  57475. */
  57476. constructor(scene: Scene);
  57477. /**
  57478. * Registers the component in a given scene
  57479. */
  57480. register(): void;
  57481. private _evaluateSubMesh;
  57482. private _activeMesh;
  57483. private _prepareRessources;
  57484. private _createIndexBuffer;
  57485. /**
  57486. * Rebuilds the elements related to this component in case of
  57487. * context lost for instance.
  57488. */
  57489. rebuild(): void;
  57490. /**
  57491. * @hidden
  57492. */
  57493. reset(): void;
  57494. /**
  57495. * Render the bounding boxes of a specific rendering group
  57496. * @param renderingGroupId defines the rendering group to render
  57497. */
  57498. render(renderingGroupId: number): void;
  57499. /**
  57500. * In case of occlusion queries, we can render the occlusion bounding box through this method
  57501. * @param mesh Define the mesh to render the occlusion bounding box for
  57502. */
  57503. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  57504. /**
  57505. * Dispose and release the resources attached to this renderer.
  57506. */
  57507. dispose(): void;
  57508. }
  57509. }
  57510. declare module "babylonjs/Shaders/depth.fragment" {
  57511. /** @hidden */
  57512. export var depthPixelShader: {
  57513. name: string;
  57514. shader: string;
  57515. };
  57516. }
  57517. declare module "babylonjs/Rendering/depthRenderer" {
  57518. import { Nullable } from "babylonjs/types";
  57519. import { SubMesh } from "babylonjs/Meshes/subMesh";
  57520. import { Scene } from "babylonjs/scene";
  57521. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57522. import { Camera } from "babylonjs/Cameras/camera";
  57523. import "babylonjs/Shaders/depth.fragment";
  57524. import "babylonjs/Shaders/depth.vertex";
  57525. /**
  57526. * This represents a depth renderer in Babylon.
  57527. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  57528. */
  57529. export class DepthRenderer {
  57530. private _scene;
  57531. private _depthMap;
  57532. private _effect;
  57533. private _cachedDefines;
  57534. private _camera;
  57535. /**
  57536. * Specifiess that the depth renderer will only be used within
  57537. * the camera it is created for.
  57538. * This can help forcing its rendering during the camera processing.
  57539. */
  57540. useOnlyInActiveCamera: boolean;
  57541. /** @hidden */
  57542. static _SceneComponentInitialization: (scene: Scene) => void;
  57543. /**
  57544. * Instantiates a depth renderer
  57545. * @param scene The scene the renderer belongs to
  57546. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  57547. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  57548. */
  57549. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  57550. /**
  57551. * Creates the depth rendering effect and checks if the effect is ready.
  57552. * @param subMesh The submesh to be used to render the depth map of
  57553. * @param useInstances If multiple world instances should be used
  57554. * @returns if the depth renderer is ready to render the depth map
  57555. */
  57556. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57557. /**
  57558. * Gets the texture which the depth map will be written to.
  57559. * @returns The depth map texture
  57560. */
  57561. getDepthMap(): RenderTargetTexture;
  57562. /**
  57563. * Disposes of the depth renderer.
  57564. */
  57565. dispose(): void;
  57566. }
  57567. }
  57568. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  57569. import { Nullable } from "babylonjs/types";
  57570. import { Scene } from "babylonjs/scene";
  57571. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  57572. import { Camera } from "babylonjs/Cameras/camera";
  57573. import { ISceneComponent } from "babylonjs/sceneComponent";
  57574. module "babylonjs/scene" {
  57575. interface Scene {
  57576. /** @hidden (Backing field) */
  57577. _depthRenderer: {
  57578. [id: string]: DepthRenderer;
  57579. };
  57580. /**
  57581. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  57582. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  57583. * @returns the created depth renderer
  57584. */
  57585. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  57586. /**
  57587. * Disables a depth renderer for a given camera
  57588. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  57589. */
  57590. disableDepthRenderer(camera?: Nullable<Camera>): void;
  57591. }
  57592. }
  57593. /**
  57594. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  57595. * in several rendering techniques.
  57596. */
  57597. export class DepthRendererSceneComponent implements ISceneComponent {
  57598. /**
  57599. * The component name helpfull to identify the component in the list of scene components.
  57600. */
  57601. readonly name: string;
  57602. /**
  57603. * The scene the component belongs to.
  57604. */
  57605. scene: Scene;
  57606. /**
  57607. * Creates a new instance of the component for the given scene
  57608. * @param scene Defines the scene to register the component in
  57609. */
  57610. constructor(scene: Scene);
  57611. /**
  57612. * Registers the component in a given scene
  57613. */
  57614. register(): void;
  57615. /**
  57616. * Rebuilds the elements related to this component in case of
  57617. * context lost for instance.
  57618. */
  57619. rebuild(): void;
  57620. /**
  57621. * Disposes the component and the associated ressources
  57622. */
  57623. dispose(): void;
  57624. private _gatherRenderTargets;
  57625. private _gatherActiveCameraRenderTargets;
  57626. }
  57627. }
  57628. declare module "babylonjs/Shaders/outline.fragment" {
  57629. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  57630. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  57631. /** @hidden */
  57632. export var outlinePixelShader: {
  57633. name: string;
  57634. shader: string;
  57635. };
  57636. }
  57637. declare module "babylonjs/Shaders/outline.vertex" {
  57638. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  57639. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  57640. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  57641. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  57642. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  57643. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  57644. /** @hidden */
  57645. export var outlineVertexShader: {
  57646. name: string;
  57647. shader: string;
  57648. };
  57649. }
  57650. declare module "babylonjs/Rendering/outlineRenderer" {
  57651. import { SubMesh } from "babylonjs/Meshes/subMesh";
  57652. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  57653. import { Scene } from "babylonjs/scene";
  57654. import { ISceneComponent } from "babylonjs/sceneComponent";
  57655. import "babylonjs/Shaders/outline.fragment";
  57656. import "babylonjs/Shaders/outline.vertex";
  57657. module "babylonjs/scene" {
  57658. interface Scene {
  57659. /** @hidden */
  57660. _outlineRenderer: OutlineRenderer;
  57661. /**
  57662. * Gets the outline renderer associated with the scene
  57663. * @returns a OutlineRenderer
  57664. */
  57665. getOutlineRenderer(): OutlineRenderer;
  57666. }
  57667. }
  57668. module "babylonjs/Meshes/abstractMesh" {
  57669. interface AbstractMesh {
  57670. /** @hidden (Backing field) */
  57671. _renderOutline: boolean;
  57672. /**
  57673. * Gets or sets a boolean indicating if the outline must be rendered as well
  57674. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  57675. */
  57676. renderOutline: boolean;
  57677. /** @hidden (Backing field) */
  57678. _renderOverlay: boolean;
  57679. /**
  57680. * Gets or sets a boolean indicating if the overlay must be rendered as well
  57681. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  57682. */
  57683. renderOverlay: boolean;
  57684. }
  57685. }
  57686. /**
  57687. * This class is responsible to draw bothe outline/overlay of meshes.
  57688. * It should not be used directly but through the available method on mesh.
  57689. */
  57690. export class OutlineRenderer implements ISceneComponent {
  57691. /**
  57692. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  57693. */
  57694. private static _StencilReference;
  57695. /**
  57696. * The name of the component. Each component must have a unique name.
  57697. */
  57698. name: string;
  57699. /**
  57700. * The scene the component belongs to.
  57701. */
  57702. scene: Scene;
  57703. /**
  57704. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  57705. */
  57706. zOffset: number;
  57707. private _engine;
  57708. private _effect;
  57709. private _cachedDefines;
  57710. private _savedDepthWrite;
  57711. /**
  57712. * Instantiates a new outline renderer. (There could be only one per scene).
  57713. * @param scene Defines the scene it belongs to
  57714. */
  57715. constructor(scene: Scene);
  57716. /**
  57717. * Register the component to one instance of a scene.
  57718. */
  57719. register(): void;
  57720. /**
  57721. * Rebuilds the elements related to this component in case of
  57722. * context lost for instance.
  57723. */
  57724. rebuild(): void;
  57725. /**
  57726. * Disposes the component and the associated ressources.
  57727. */
  57728. dispose(): void;
  57729. /**
  57730. * Renders the outline in the canvas.
  57731. * @param subMesh Defines the sumesh to render
  57732. * @param batch Defines the batch of meshes in case of instances
  57733. * @param useOverlay Defines if the rendering is for the overlay or the outline
  57734. */
  57735. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  57736. /**
  57737. * Returns whether or not the outline renderer is ready for a given submesh.
  57738. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  57739. * @param subMesh Defines the submesh to check readyness for
  57740. * @param useInstances Defines wheter wee are trying to render instances or not
  57741. * @returns true if ready otherwise false
  57742. */
  57743. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57744. private _beforeRenderingMesh;
  57745. private _afterRenderingMesh;
  57746. }
  57747. }
  57748. declare module "babylonjs/Rendering/index" {
  57749. export * from "babylonjs/Rendering/boundingBoxRenderer";
  57750. export * from "babylonjs/Rendering/depthRenderer";
  57751. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  57752. export * from "babylonjs/Rendering/edgesRenderer";
  57753. export * from "babylonjs/Rendering/geometryBufferRenderer";
  57754. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  57755. export * from "babylonjs/Rendering/outlineRenderer";
  57756. export * from "babylonjs/Rendering/renderingGroup";
  57757. export * from "babylonjs/Rendering/renderingManager";
  57758. export * from "babylonjs/Rendering/utilityLayerRenderer";
  57759. }
  57760. declare module "babylonjs/Sprites/index" {
  57761. export * from "babylonjs/Sprites/sprite";
  57762. export * from "babylonjs/Sprites/spriteManager";
  57763. export * from "babylonjs/Sprites/spriteSceneComponent";
  57764. }
  57765. declare module "babylonjs/Misc/assetsManager" {
  57766. import { Scene } from "babylonjs/scene";
  57767. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57768. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  57769. import { Skeleton } from "babylonjs/Bones/skeleton";
  57770. import { Observable } from "babylonjs/Misc/observable";
  57771. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57772. import { Texture } from "babylonjs/Materials/Textures/texture";
  57773. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  57774. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  57775. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  57776. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  57777. /**
  57778. * Defines the list of states available for a task inside a AssetsManager
  57779. */
  57780. export enum AssetTaskState {
  57781. /**
  57782. * Initialization
  57783. */
  57784. INIT = 0,
  57785. /**
  57786. * Running
  57787. */
  57788. RUNNING = 1,
  57789. /**
  57790. * Done
  57791. */
  57792. DONE = 2,
  57793. /**
  57794. * Error
  57795. */
  57796. ERROR = 3
  57797. }
  57798. /**
  57799. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  57800. */
  57801. export abstract class AbstractAssetTask {
  57802. /**
  57803. * Task name
  57804. */ name: string;
  57805. /**
  57806. * Callback called when the task is successful
  57807. */
  57808. onSuccess: (task: any) => void;
  57809. /**
  57810. * Callback called when the task is not successful
  57811. */
  57812. onError: (task: any, message?: string, exception?: any) => void;
  57813. /**
  57814. * Creates a new AssetsManager
  57815. * @param name defines the name of the task
  57816. */
  57817. constructor(
  57818. /**
  57819. * Task name
  57820. */ name: string);
  57821. private _isCompleted;
  57822. private _taskState;
  57823. private _errorObject;
  57824. /**
  57825. * Get if the task is completed
  57826. */
  57827. readonly isCompleted: boolean;
  57828. /**
  57829. * Gets the current state of the task
  57830. */
  57831. readonly taskState: AssetTaskState;
  57832. /**
  57833. * Gets the current error object (if task is in error)
  57834. */
  57835. readonly errorObject: {
  57836. message?: string;
  57837. exception?: any;
  57838. };
  57839. /**
  57840. * Internal only
  57841. * @hidden
  57842. */
  57843. _setErrorObject(message?: string, exception?: any): void;
  57844. /**
  57845. * Execute the current task
  57846. * @param scene defines the scene where you want your assets to be loaded
  57847. * @param onSuccess is a callback called when the task is successfully executed
  57848. * @param onError is a callback called if an error occurs
  57849. */
  57850. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57851. /**
  57852. * Execute the current task
  57853. * @param scene defines the scene where you want your assets to be loaded
  57854. * @param onSuccess is a callback called when the task is successfully executed
  57855. * @param onError is a callback called if an error occurs
  57856. */
  57857. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57858. /**
  57859. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  57860. * This can be used with failed tasks that have the reason for failure fixed.
  57861. */
  57862. reset(): void;
  57863. private onErrorCallback;
  57864. private onDoneCallback;
  57865. }
  57866. /**
  57867. * Define the interface used by progress events raised during assets loading
  57868. */
  57869. export interface IAssetsProgressEvent {
  57870. /**
  57871. * Defines the number of remaining tasks to process
  57872. */
  57873. remainingCount: number;
  57874. /**
  57875. * Defines the total number of tasks
  57876. */
  57877. totalCount: number;
  57878. /**
  57879. * Defines the task that was just processed
  57880. */
  57881. task: AbstractAssetTask;
  57882. }
  57883. /**
  57884. * Class used to share progress information about assets loading
  57885. */
  57886. export class AssetsProgressEvent implements IAssetsProgressEvent {
  57887. /**
  57888. * Defines the number of remaining tasks to process
  57889. */
  57890. remainingCount: number;
  57891. /**
  57892. * Defines the total number of tasks
  57893. */
  57894. totalCount: number;
  57895. /**
  57896. * Defines the task that was just processed
  57897. */
  57898. task: AbstractAssetTask;
  57899. /**
  57900. * Creates a AssetsProgressEvent
  57901. * @param remainingCount defines the number of remaining tasks to process
  57902. * @param totalCount defines the total number of tasks
  57903. * @param task defines the task that was just processed
  57904. */
  57905. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  57906. }
  57907. /**
  57908. * Define a task used by AssetsManager to load meshes
  57909. */
  57910. export class MeshAssetTask extends AbstractAssetTask {
  57911. /**
  57912. * Defines the name of the task
  57913. */
  57914. name: string;
  57915. /**
  57916. * Defines the list of mesh's names you want to load
  57917. */
  57918. meshesNames: any;
  57919. /**
  57920. * Defines the root url to use as a base to load your meshes and associated resources
  57921. */
  57922. rootUrl: string;
  57923. /**
  57924. * Defines the filename of the scene to load from
  57925. */
  57926. sceneFilename: string;
  57927. /**
  57928. * Gets the list of loaded meshes
  57929. */
  57930. loadedMeshes: Array<AbstractMesh>;
  57931. /**
  57932. * Gets the list of loaded particle systems
  57933. */
  57934. loadedParticleSystems: Array<IParticleSystem>;
  57935. /**
  57936. * Gets the list of loaded skeletons
  57937. */
  57938. loadedSkeletons: Array<Skeleton>;
  57939. /**
  57940. * Gets the list of loaded animation groups
  57941. */
  57942. loadedAnimationGroups: Array<AnimationGroup>;
  57943. /**
  57944. * Callback called when the task is successful
  57945. */
  57946. onSuccess: (task: MeshAssetTask) => void;
  57947. /**
  57948. * Callback called when the task is successful
  57949. */
  57950. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  57951. /**
  57952. * Creates a new MeshAssetTask
  57953. * @param name defines the name of the task
  57954. * @param meshesNames defines the list of mesh's names you want to load
  57955. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  57956. * @param sceneFilename defines the filename of the scene to load from
  57957. */
  57958. constructor(
  57959. /**
  57960. * Defines the name of the task
  57961. */
  57962. name: string,
  57963. /**
  57964. * Defines the list of mesh's names you want to load
  57965. */
  57966. meshesNames: any,
  57967. /**
  57968. * Defines the root url to use as a base to load your meshes and associated resources
  57969. */
  57970. rootUrl: string,
  57971. /**
  57972. * Defines the filename of the scene to load from
  57973. */
  57974. sceneFilename: string);
  57975. /**
  57976. * Execute the current task
  57977. * @param scene defines the scene where you want your assets to be loaded
  57978. * @param onSuccess is a callback called when the task is successfully executed
  57979. * @param onError is a callback called if an error occurs
  57980. */
  57981. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57982. }
  57983. /**
  57984. * Define a task used by AssetsManager to load text content
  57985. */
  57986. export class TextFileAssetTask extends AbstractAssetTask {
  57987. /**
  57988. * Defines the name of the task
  57989. */
  57990. name: string;
  57991. /**
  57992. * Defines the location of the file to load
  57993. */
  57994. url: string;
  57995. /**
  57996. * Gets the loaded text string
  57997. */
  57998. text: string;
  57999. /**
  58000. * Callback called when the task is successful
  58001. */
  58002. onSuccess: (task: TextFileAssetTask) => void;
  58003. /**
  58004. * Callback called when the task is successful
  58005. */
  58006. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  58007. /**
  58008. * Creates a new TextFileAssetTask object
  58009. * @param name defines the name of the task
  58010. * @param url defines the location of the file to load
  58011. */
  58012. constructor(
  58013. /**
  58014. * Defines the name of the task
  58015. */
  58016. name: string,
  58017. /**
  58018. * Defines the location of the file to load
  58019. */
  58020. url: string);
  58021. /**
  58022. * Execute the current task
  58023. * @param scene defines the scene where you want your assets to be loaded
  58024. * @param onSuccess is a callback called when the task is successfully executed
  58025. * @param onError is a callback called if an error occurs
  58026. */
  58027. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58028. }
  58029. /**
  58030. * Define a task used by AssetsManager to load binary data
  58031. */
  58032. export class BinaryFileAssetTask extends AbstractAssetTask {
  58033. /**
  58034. * Defines the name of the task
  58035. */
  58036. name: string;
  58037. /**
  58038. * Defines the location of the file to load
  58039. */
  58040. url: string;
  58041. /**
  58042. * Gets the lodaded data (as an array buffer)
  58043. */
  58044. data: ArrayBuffer;
  58045. /**
  58046. * Callback called when the task is successful
  58047. */
  58048. onSuccess: (task: BinaryFileAssetTask) => void;
  58049. /**
  58050. * Callback called when the task is successful
  58051. */
  58052. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  58053. /**
  58054. * Creates a new BinaryFileAssetTask object
  58055. * @param name defines the name of the new task
  58056. * @param url defines the location of the file to load
  58057. */
  58058. constructor(
  58059. /**
  58060. * Defines the name of the task
  58061. */
  58062. name: string,
  58063. /**
  58064. * Defines the location of the file to load
  58065. */
  58066. url: string);
  58067. /**
  58068. * Execute the current task
  58069. * @param scene defines the scene where you want your assets to be loaded
  58070. * @param onSuccess is a callback called when the task is successfully executed
  58071. * @param onError is a callback called if an error occurs
  58072. */
  58073. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58074. }
  58075. /**
  58076. * Define a task used by AssetsManager to load images
  58077. */
  58078. export class ImageAssetTask extends AbstractAssetTask {
  58079. /**
  58080. * Defines the name of the task
  58081. */
  58082. name: string;
  58083. /**
  58084. * Defines the location of the image to load
  58085. */
  58086. url: string;
  58087. /**
  58088. * Gets the loaded images
  58089. */
  58090. image: HTMLImageElement;
  58091. /**
  58092. * Callback called when the task is successful
  58093. */
  58094. onSuccess: (task: ImageAssetTask) => void;
  58095. /**
  58096. * Callback called when the task is successful
  58097. */
  58098. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  58099. /**
  58100. * Creates a new ImageAssetTask
  58101. * @param name defines the name of the task
  58102. * @param url defines the location of the image to load
  58103. */
  58104. constructor(
  58105. /**
  58106. * Defines the name of the task
  58107. */
  58108. name: string,
  58109. /**
  58110. * Defines the location of the image to load
  58111. */
  58112. url: string);
  58113. /**
  58114. * Execute the current task
  58115. * @param scene defines the scene where you want your assets to be loaded
  58116. * @param onSuccess is a callback called when the task is successfully executed
  58117. * @param onError is a callback called if an error occurs
  58118. */
  58119. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58120. }
  58121. /**
  58122. * Defines the interface used by texture loading tasks
  58123. */
  58124. export interface ITextureAssetTask<TEX extends BaseTexture> {
  58125. /**
  58126. * Gets the loaded texture
  58127. */
  58128. texture: TEX;
  58129. }
  58130. /**
  58131. * Define a task used by AssetsManager to load 2D textures
  58132. */
  58133. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  58134. /**
  58135. * Defines the name of the task
  58136. */
  58137. name: string;
  58138. /**
  58139. * Defines the location of the file to load
  58140. */
  58141. url: string;
  58142. /**
  58143. * Defines if mipmap should not be generated (default is false)
  58144. */
  58145. noMipmap?: boolean | undefined;
  58146. /**
  58147. * Defines if texture must be inverted on Y axis (default is false)
  58148. */
  58149. invertY?: boolean | undefined;
  58150. /**
  58151. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  58152. */
  58153. samplingMode: number;
  58154. /**
  58155. * Gets the loaded texture
  58156. */
  58157. texture: Texture;
  58158. /**
  58159. * Callback called when the task is successful
  58160. */
  58161. onSuccess: (task: TextureAssetTask) => void;
  58162. /**
  58163. * Callback called when the task is successful
  58164. */
  58165. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  58166. /**
  58167. * Creates a new TextureAssetTask object
  58168. * @param name defines the name of the task
  58169. * @param url defines the location of the file to load
  58170. * @param noMipmap defines if mipmap should not be generated (default is false)
  58171. * @param invertY defines if texture must be inverted on Y axis (default is false)
  58172. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  58173. */
  58174. constructor(
  58175. /**
  58176. * Defines the name of the task
  58177. */
  58178. name: string,
  58179. /**
  58180. * Defines the location of the file to load
  58181. */
  58182. url: string,
  58183. /**
  58184. * Defines if mipmap should not be generated (default is false)
  58185. */
  58186. noMipmap?: boolean | undefined,
  58187. /**
  58188. * Defines if texture must be inverted on Y axis (default is false)
  58189. */
  58190. invertY?: boolean | undefined,
  58191. /**
  58192. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  58193. */
  58194. samplingMode?: number);
  58195. /**
  58196. * Execute the current task
  58197. * @param scene defines the scene where you want your assets to be loaded
  58198. * @param onSuccess is a callback called when the task is successfully executed
  58199. * @param onError is a callback called if an error occurs
  58200. */
  58201. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58202. }
  58203. /**
  58204. * Define a task used by AssetsManager to load cube textures
  58205. */
  58206. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  58207. /**
  58208. * Defines the name of the task
  58209. */
  58210. name: string;
  58211. /**
  58212. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  58213. */
  58214. url: string;
  58215. /**
  58216. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  58217. */
  58218. extensions?: string[] | undefined;
  58219. /**
  58220. * Defines if mipmaps should not be generated (default is false)
  58221. */
  58222. noMipmap?: boolean | undefined;
  58223. /**
  58224. * Defines the explicit list of files (undefined by default)
  58225. */
  58226. files?: string[] | undefined;
  58227. /**
  58228. * Gets the loaded texture
  58229. */
  58230. texture: CubeTexture;
  58231. /**
  58232. * Callback called when the task is successful
  58233. */
  58234. onSuccess: (task: CubeTextureAssetTask) => void;
  58235. /**
  58236. * Callback called when the task is successful
  58237. */
  58238. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  58239. /**
  58240. * Creates a new CubeTextureAssetTask
  58241. * @param name defines the name of the task
  58242. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  58243. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  58244. * @param noMipmap defines if mipmaps should not be generated (default is false)
  58245. * @param files defines the explicit list of files (undefined by default)
  58246. */
  58247. constructor(
  58248. /**
  58249. * Defines the name of the task
  58250. */
  58251. name: string,
  58252. /**
  58253. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  58254. */
  58255. url: string,
  58256. /**
  58257. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  58258. */
  58259. extensions?: string[] | undefined,
  58260. /**
  58261. * Defines if mipmaps should not be generated (default is false)
  58262. */
  58263. noMipmap?: boolean | undefined,
  58264. /**
  58265. * Defines the explicit list of files (undefined by default)
  58266. */
  58267. files?: string[] | undefined);
  58268. /**
  58269. * Execute the current task
  58270. * @param scene defines the scene where you want your assets to be loaded
  58271. * @param onSuccess is a callback called when the task is successfully executed
  58272. * @param onError is a callback called if an error occurs
  58273. */
  58274. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58275. }
  58276. /**
  58277. * Define a task used by AssetsManager to load HDR cube textures
  58278. */
  58279. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  58280. /**
  58281. * Defines the name of the task
  58282. */
  58283. name: string;
  58284. /**
  58285. * Defines the location of the file to load
  58286. */
  58287. url: string;
  58288. /**
  58289. * Defines the desired size (the more it increases the longer the generation will be)
  58290. */
  58291. size: number;
  58292. /**
  58293. * Defines if mipmaps should not be generated (default is false)
  58294. */
  58295. noMipmap: boolean;
  58296. /**
  58297. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  58298. */
  58299. generateHarmonics: boolean;
  58300. /**
  58301. * 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)
  58302. */
  58303. gammaSpace: boolean;
  58304. /**
  58305. * Internal Use Only
  58306. */
  58307. reserved: boolean;
  58308. /**
  58309. * Gets the loaded texture
  58310. */
  58311. texture: HDRCubeTexture;
  58312. /**
  58313. * Callback called when the task is successful
  58314. */
  58315. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  58316. /**
  58317. * Callback called when the task is successful
  58318. */
  58319. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  58320. /**
  58321. * Creates a new HDRCubeTextureAssetTask object
  58322. * @param name defines the name of the task
  58323. * @param url defines the location of the file to load
  58324. * @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.
  58325. * @param noMipmap defines if mipmaps should not be generated (default is false)
  58326. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  58327. * @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)
  58328. * @param reserved Internal use only
  58329. */
  58330. constructor(
  58331. /**
  58332. * Defines the name of the task
  58333. */
  58334. name: string,
  58335. /**
  58336. * Defines the location of the file to load
  58337. */
  58338. url: string,
  58339. /**
  58340. * Defines the desired size (the more it increases the longer the generation will be)
  58341. */
  58342. size: number,
  58343. /**
  58344. * Defines if mipmaps should not be generated (default is false)
  58345. */
  58346. noMipmap?: boolean,
  58347. /**
  58348. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  58349. */
  58350. generateHarmonics?: boolean,
  58351. /**
  58352. * 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)
  58353. */
  58354. gammaSpace?: boolean,
  58355. /**
  58356. * Internal Use Only
  58357. */
  58358. reserved?: boolean);
  58359. /**
  58360. * Execute the current task
  58361. * @param scene defines the scene where you want your assets to be loaded
  58362. * @param onSuccess is a callback called when the task is successfully executed
  58363. * @param onError is a callback called if an error occurs
  58364. */
  58365. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58366. }
  58367. /**
  58368. * Define a task used by AssetsManager to load Equirectangular cube textures
  58369. */
  58370. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  58371. /**
  58372. * Defines the name of the task
  58373. */
  58374. name: string;
  58375. /**
  58376. * Defines the location of the file to load
  58377. */
  58378. url: string;
  58379. /**
  58380. * Defines the desired size (the more it increases the longer the generation will be)
  58381. */
  58382. size: number;
  58383. /**
  58384. * Defines if mipmaps should not be generated (default is false)
  58385. */
  58386. noMipmap: boolean;
  58387. /**
  58388. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  58389. * but the standard material would require them in Gamma space) (default is true)
  58390. */
  58391. gammaSpace: boolean;
  58392. /**
  58393. * Gets the loaded texture
  58394. */
  58395. texture: EquiRectangularCubeTexture;
  58396. /**
  58397. * Callback called when the task is successful
  58398. */
  58399. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  58400. /**
  58401. * Callback called when the task is successful
  58402. */
  58403. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  58404. /**
  58405. * Creates a new EquiRectangularCubeTextureAssetTask object
  58406. * @param name defines the name of the task
  58407. * @param url defines the location of the file to load
  58408. * @param size defines the desired size (the more it increases the longer the generation will be)
  58409. * If the size is omitted this implies you are using a preprocessed cubemap.
  58410. * @param noMipmap defines if mipmaps should not be generated (default is false)
  58411. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  58412. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  58413. * (default is true)
  58414. */
  58415. constructor(
  58416. /**
  58417. * Defines the name of the task
  58418. */
  58419. name: string,
  58420. /**
  58421. * Defines the location of the file to load
  58422. */
  58423. url: string,
  58424. /**
  58425. * Defines the desired size (the more it increases the longer the generation will be)
  58426. */
  58427. size: number,
  58428. /**
  58429. * Defines if mipmaps should not be generated (default is false)
  58430. */
  58431. noMipmap?: boolean,
  58432. /**
  58433. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  58434. * but the standard material would require them in Gamma space) (default is true)
  58435. */
  58436. gammaSpace?: boolean);
  58437. /**
  58438. * Execute the current task
  58439. * @param scene defines the scene where you want your assets to be loaded
  58440. * @param onSuccess is a callback called when the task is successfully executed
  58441. * @param onError is a callback called if an error occurs
  58442. */
  58443. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58444. }
  58445. /**
  58446. * This class can be used to easily import assets into a scene
  58447. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  58448. */
  58449. export class AssetsManager {
  58450. private _scene;
  58451. private _isLoading;
  58452. protected _tasks: AbstractAssetTask[];
  58453. protected _waitingTasksCount: number;
  58454. protected _totalTasksCount: number;
  58455. /**
  58456. * Callback called when all tasks are processed
  58457. */
  58458. onFinish: (tasks: AbstractAssetTask[]) => void;
  58459. /**
  58460. * Callback called when a task is successful
  58461. */
  58462. onTaskSuccess: (task: AbstractAssetTask) => void;
  58463. /**
  58464. * Callback called when a task had an error
  58465. */
  58466. onTaskError: (task: AbstractAssetTask) => void;
  58467. /**
  58468. * Callback called when a task is done (whatever the result is)
  58469. */
  58470. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  58471. /**
  58472. * Observable called when all tasks are processed
  58473. */
  58474. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  58475. /**
  58476. * Observable called when a task had an error
  58477. */
  58478. onTaskErrorObservable: Observable<AbstractAssetTask>;
  58479. /**
  58480. * Observable called when all tasks were executed
  58481. */
  58482. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  58483. /**
  58484. * Observable called when a task is done (whatever the result is)
  58485. */
  58486. onProgressObservable: Observable<IAssetsProgressEvent>;
  58487. /**
  58488. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  58489. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  58490. */
  58491. useDefaultLoadingScreen: boolean;
  58492. /**
  58493. * Creates a new AssetsManager
  58494. * @param scene defines the scene to work on
  58495. */
  58496. constructor(scene: Scene);
  58497. /**
  58498. * Add a MeshAssetTask to the list of active tasks
  58499. * @param taskName defines the name of the new task
  58500. * @param meshesNames defines the name of meshes to load
  58501. * @param rootUrl defines the root url to use to locate files
  58502. * @param sceneFilename defines the filename of the scene file
  58503. * @returns a new MeshAssetTask object
  58504. */
  58505. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  58506. /**
  58507. * Add a TextFileAssetTask to the list of active tasks
  58508. * @param taskName defines the name of the new task
  58509. * @param url defines the url of the file to load
  58510. * @returns a new TextFileAssetTask object
  58511. */
  58512. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  58513. /**
  58514. * Add a BinaryFileAssetTask to the list of active tasks
  58515. * @param taskName defines the name of the new task
  58516. * @param url defines the url of the file to load
  58517. * @returns a new BinaryFileAssetTask object
  58518. */
  58519. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  58520. /**
  58521. * Add a ImageAssetTask to the list of active tasks
  58522. * @param taskName defines the name of the new task
  58523. * @param url defines the url of the file to load
  58524. * @returns a new ImageAssetTask object
  58525. */
  58526. addImageTask(taskName: string, url: string): ImageAssetTask;
  58527. /**
  58528. * Add a TextureAssetTask to the list of active tasks
  58529. * @param taskName defines the name of the new task
  58530. * @param url defines the url of the file to load
  58531. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  58532. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  58533. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  58534. * @returns a new TextureAssetTask object
  58535. */
  58536. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  58537. /**
  58538. * Add a CubeTextureAssetTask to the list of active tasks
  58539. * @param taskName defines the name of the new task
  58540. * @param url defines the url of the file to load
  58541. * @param extensions defines the extension to use to load the cube map (can be null)
  58542. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  58543. * @param files defines the list of files to load (can be null)
  58544. * @returns a new CubeTextureAssetTask object
  58545. */
  58546. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  58547. /**
  58548. *
  58549. * Add a HDRCubeTextureAssetTask to the list of active tasks
  58550. * @param taskName defines the name of the new task
  58551. * @param url defines the url of the file to load
  58552. * @param size defines the size you want for the cubemap (can be null)
  58553. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  58554. * @param generateHarmonics defines if you want to automatically generate (true by default)
  58555. * @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)
  58556. * @param reserved Internal use only
  58557. * @returns a new HDRCubeTextureAssetTask object
  58558. */
  58559. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  58560. /**
  58561. *
  58562. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  58563. * @param taskName defines the name of the new task
  58564. * @param url defines the url of the file to load
  58565. * @param size defines the size you want for the cubemap (can be null)
  58566. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  58567. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  58568. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  58569. * @returns a new EquiRectangularCubeTextureAssetTask object
  58570. */
  58571. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  58572. /**
  58573. * Remove a task from the assets manager.
  58574. * @param task the task to remove
  58575. */
  58576. removeTask(task: AbstractAssetTask): void;
  58577. private _decreaseWaitingTasksCount;
  58578. private _runTask;
  58579. /**
  58580. * Reset the AssetsManager and remove all tasks
  58581. * @return the current instance of the AssetsManager
  58582. */
  58583. reset(): AssetsManager;
  58584. /**
  58585. * Start the loading process
  58586. * @return the current instance of the AssetsManager
  58587. */
  58588. load(): AssetsManager;
  58589. /**
  58590. * Start the loading process as an async operation
  58591. * @return a promise returning the list of failed tasks
  58592. */
  58593. loadAsync(): Promise<void>;
  58594. }
  58595. }
  58596. declare module "babylonjs/Misc/deferred" {
  58597. /**
  58598. * Wrapper class for promise with external resolve and reject.
  58599. */
  58600. export class Deferred<T> {
  58601. /**
  58602. * The promise associated with this deferred object.
  58603. */
  58604. readonly promise: Promise<T>;
  58605. private _resolve;
  58606. private _reject;
  58607. /**
  58608. * The resolve method of the promise associated with this deferred object.
  58609. */
  58610. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  58611. /**
  58612. * The reject method of the promise associated with this deferred object.
  58613. */
  58614. readonly reject: (reason?: any) => void;
  58615. /**
  58616. * Constructor for this deferred object.
  58617. */
  58618. constructor();
  58619. }
  58620. }
  58621. declare module "babylonjs/Misc/meshExploder" {
  58622. import { Mesh } from "babylonjs/Meshes/mesh";
  58623. /**
  58624. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  58625. */
  58626. export class MeshExploder {
  58627. private _centerMesh;
  58628. private _meshes;
  58629. private _meshesOrigins;
  58630. private _toCenterVectors;
  58631. private _scaledDirection;
  58632. private _newPosition;
  58633. private _centerPosition;
  58634. /**
  58635. * Explodes meshes from a center mesh.
  58636. * @param meshes The meshes to explode.
  58637. * @param centerMesh The mesh to be center of explosion.
  58638. */
  58639. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  58640. private _setCenterMesh;
  58641. /**
  58642. * Get class name
  58643. * @returns "MeshExploder"
  58644. */
  58645. getClassName(): string;
  58646. /**
  58647. * "Exploded meshes"
  58648. * @returns Array of meshes with the centerMesh at index 0.
  58649. */
  58650. getMeshes(): Array<Mesh>;
  58651. /**
  58652. * Explodes meshes giving a specific direction
  58653. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  58654. */
  58655. explode(direction?: number): void;
  58656. }
  58657. }
  58658. declare module "babylonjs/Misc/filesInput" {
  58659. import { Engine } from "babylonjs/Engines/engine";
  58660. import { Scene } from "babylonjs/scene";
  58661. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  58662. /**
  58663. * Class used to help managing file picking and drag'n'drop
  58664. */
  58665. export class FilesInput {
  58666. /**
  58667. * List of files ready to be loaded
  58668. */
  58669. static readonly FilesToLoad: {
  58670. [key: string]: File;
  58671. };
  58672. /**
  58673. * Callback called when a file is processed
  58674. */
  58675. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  58676. private _engine;
  58677. private _currentScene;
  58678. private _sceneLoadedCallback;
  58679. private _progressCallback;
  58680. private _additionalRenderLoopLogicCallback;
  58681. private _textureLoadingCallback;
  58682. private _startingProcessingFilesCallback;
  58683. private _onReloadCallback;
  58684. private _errorCallback;
  58685. private _elementToMonitor;
  58686. private _sceneFileToLoad;
  58687. private _filesToLoad;
  58688. /**
  58689. * Creates a new FilesInput
  58690. * @param engine defines the rendering engine
  58691. * @param scene defines the hosting scene
  58692. * @param sceneLoadedCallback callback called when scene is loaded
  58693. * @param progressCallback callback called to track progress
  58694. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  58695. * @param textureLoadingCallback callback called when a texture is loading
  58696. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  58697. * @param onReloadCallback callback called when a reload is requested
  58698. * @param errorCallback callback call if an error occurs
  58699. */
  58700. 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);
  58701. private _dragEnterHandler;
  58702. private _dragOverHandler;
  58703. private _dropHandler;
  58704. /**
  58705. * Calls this function to listen to drag'n'drop events on a specific DOM element
  58706. * @param elementToMonitor defines the DOM element to track
  58707. */
  58708. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  58709. /**
  58710. * Release all associated resources
  58711. */
  58712. dispose(): void;
  58713. private renderFunction;
  58714. private drag;
  58715. private drop;
  58716. private _traverseFolder;
  58717. private _processFiles;
  58718. /**
  58719. * Load files from a drop event
  58720. * @param event defines the drop event to use as source
  58721. */
  58722. loadFiles(event: any): void;
  58723. private _processReload;
  58724. /**
  58725. * Reload the current scene from the loaded files
  58726. */
  58727. reload(): void;
  58728. }
  58729. }
  58730. declare module "babylonjs/Misc/HighDynamicRange/index" {
  58731. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  58732. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  58733. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  58734. }
  58735. declare module "babylonjs/Misc/sceneOptimizer" {
  58736. import { Scene, IDisposable } from "babylonjs/scene";
  58737. import { Observable } from "babylonjs/Misc/observable";
  58738. /**
  58739. * Defines the root class used to create scene optimization to use with SceneOptimizer
  58740. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58741. */
  58742. export class SceneOptimization {
  58743. /**
  58744. * Defines the priority of this optimization (0 by default which means first in the list)
  58745. */
  58746. priority: number;
  58747. /**
  58748. * Gets a string describing the action executed by the current optimization
  58749. * @returns description string
  58750. */
  58751. getDescription(): string;
  58752. /**
  58753. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58754. * @param scene defines the current scene where to apply this optimization
  58755. * @param optimizer defines the current optimizer
  58756. * @returns true if everything that can be done was applied
  58757. */
  58758. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58759. /**
  58760. * Creates the SceneOptimization object
  58761. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  58762. * @param desc defines the description associated with the optimization
  58763. */
  58764. constructor(
  58765. /**
  58766. * Defines the priority of this optimization (0 by default which means first in the list)
  58767. */
  58768. priority?: number);
  58769. }
  58770. /**
  58771. * Defines an optimization used to reduce the size of render target textures
  58772. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58773. */
  58774. export class TextureOptimization extends SceneOptimization {
  58775. /**
  58776. * Defines the priority of this optimization (0 by default which means first in the list)
  58777. */
  58778. priority: number;
  58779. /**
  58780. * 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
  58781. */
  58782. maximumSize: number;
  58783. /**
  58784. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  58785. */
  58786. step: number;
  58787. /**
  58788. * Gets a string describing the action executed by the current optimization
  58789. * @returns description string
  58790. */
  58791. getDescription(): string;
  58792. /**
  58793. * Creates the TextureOptimization object
  58794. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  58795. * @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
  58796. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  58797. */
  58798. constructor(
  58799. /**
  58800. * Defines the priority of this optimization (0 by default which means first in the list)
  58801. */
  58802. priority?: number,
  58803. /**
  58804. * 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
  58805. */
  58806. maximumSize?: number,
  58807. /**
  58808. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  58809. */
  58810. step?: number);
  58811. /**
  58812. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58813. * @param scene defines the current scene where to apply this optimization
  58814. * @param optimizer defines the current optimizer
  58815. * @returns true if everything that can be done was applied
  58816. */
  58817. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58818. }
  58819. /**
  58820. * Defines an optimization used to increase or decrease the rendering resolution
  58821. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58822. */
  58823. export class HardwareScalingOptimization extends SceneOptimization {
  58824. /**
  58825. * Defines the priority of this optimization (0 by default which means first in the list)
  58826. */
  58827. priority: number;
  58828. /**
  58829. * Defines the maximum scale to use (2 by default)
  58830. */
  58831. maximumScale: number;
  58832. /**
  58833. * Defines the step to use between two passes (0.5 by default)
  58834. */
  58835. step: number;
  58836. private _currentScale;
  58837. private _directionOffset;
  58838. /**
  58839. * Gets a string describing the action executed by the current optimization
  58840. * @return description string
  58841. */
  58842. getDescription(): string;
  58843. /**
  58844. * Creates the HardwareScalingOptimization object
  58845. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  58846. * @param maximumScale defines the maximum scale to use (2 by default)
  58847. * @param step defines the step to use between two passes (0.5 by default)
  58848. */
  58849. constructor(
  58850. /**
  58851. * Defines the priority of this optimization (0 by default which means first in the list)
  58852. */
  58853. priority?: number,
  58854. /**
  58855. * Defines the maximum scale to use (2 by default)
  58856. */
  58857. maximumScale?: number,
  58858. /**
  58859. * Defines the step to use between two passes (0.5 by default)
  58860. */
  58861. step?: number);
  58862. /**
  58863. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58864. * @param scene defines the current scene where to apply this optimization
  58865. * @param optimizer defines the current optimizer
  58866. * @returns true if everything that can be done was applied
  58867. */
  58868. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58869. }
  58870. /**
  58871. * Defines an optimization used to remove shadows
  58872. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58873. */
  58874. export class ShadowsOptimization extends SceneOptimization {
  58875. /**
  58876. * Gets a string describing the action executed by the current optimization
  58877. * @return description string
  58878. */
  58879. getDescription(): string;
  58880. /**
  58881. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58882. * @param scene defines the current scene where to apply this optimization
  58883. * @param optimizer defines the current optimizer
  58884. * @returns true if everything that can be done was applied
  58885. */
  58886. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58887. }
  58888. /**
  58889. * Defines an optimization used to turn post-processes off
  58890. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58891. */
  58892. export class PostProcessesOptimization extends SceneOptimization {
  58893. /**
  58894. * Gets a string describing the action executed by the current optimization
  58895. * @return description string
  58896. */
  58897. getDescription(): string;
  58898. /**
  58899. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58900. * @param scene defines the current scene where to apply this optimization
  58901. * @param optimizer defines the current optimizer
  58902. * @returns true if everything that can be done was applied
  58903. */
  58904. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58905. }
  58906. /**
  58907. * Defines an optimization used to turn lens flares off
  58908. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58909. */
  58910. export class LensFlaresOptimization extends SceneOptimization {
  58911. /**
  58912. * Gets a string describing the action executed by the current optimization
  58913. * @return description string
  58914. */
  58915. getDescription(): string;
  58916. /**
  58917. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58918. * @param scene defines the current scene where to apply this optimization
  58919. * @param optimizer defines the current optimizer
  58920. * @returns true if everything that can be done was applied
  58921. */
  58922. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58923. }
  58924. /**
  58925. * Defines an optimization based on user defined callback.
  58926. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58927. */
  58928. export class CustomOptimization extends SceneOptimization {
  58929. /**
  58930. * Callback called to apply the custom optimization.
  58931. */
  58932. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  58933. /**
  58934. * Callback called to get custom description
  58935. */
  58936. onGetDescription: () => string;
  58937. /**
  58938. * Gets a string describing the action executed by the current optimization
  58939. * @returns description string
  58940. */
  58941. getDescription(): string;
  58942. /**
  58943. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58944. * @param scene defines the current scene where to apply this optimization
  58945. * @param optimizer defines the current optimizer
  58946. * @returns true if everything that can be done was applied
  58947. */
  58948. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58949. }
  58950. /**
  58951. * Defines an optimization used to turn particles off
  58952. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58953. */
  58954. export class ParticlesOptimization extends SceneOptimization {
  58955. /**
  58956. * Gets a string describing the action executed by the current optimization
  58957. * @return description string
  58958. */
  58959. getDescription(): string;
  58960. /**
  58961. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58962. * @param scene defines the current scene where to apply this optimization
  58963. * @param optimizer defines the current optimizer
  58964. * @returns true if everything that can be done was applied
  58965. */
  58966. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58967. }
  58968. /**
  58969. * Defines an optimization used to turn render targets off
  58970. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58971. */
  58972. export class RenderTargetsOptimization extends SceneOptimization {
  58973. /**
  58974. * Gets a string describing the action executed by the current optimization
  58975. * @return description string
  58976. */
  58977. getDescription(): string;
  58978. /**
  58979. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58980. * @param scene defines the current scene where to apply this optimization
  58981. * @param optimizer defines the current optimizer
  58982. * @returns true if everything that can be done was applied
  58983. */
  58984. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58985. }
  58986. /**
  58987. * Defines an optimization used to merge meshes with compatible materials
  58988. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58989. */
  58990. export class MergeMeshesOptimization extends SceneOptimization {
  58991. private static _UpdateSelectionTree;
  58992. /**
  58993. * Gets or sets a boolean which defines if optimization octree has to be updated
  58994. */
  58995. /**
  58996. * Gets or sets a boolean which defines if optimization octree has to be updated
  58997. */
  58998. static UpdateSelectionTree: boolean;
  58999. /**
  59000. * Gets a string describing the action executed by the current optimization
  59001. * @return description string
  59002. */
  59003. getDescription(): string;
  59004. private _canBeMerged;
  59005. /**
  59006. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  59007. * @param scene defines the current scene where to apply this optimization
  59008. * @param optimizer defines the current optimizer
  59009. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  59010. * @returns true if everything that can be done was applied
  59011. */
  59012. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  59013. }
  59014. /**
  59015. * Defines a list of options used by SceneOptimizer
  59016. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  59017. */
  59018. export class SceneOptimizerOptions {
  59019. /**
  59020. * Defines the target frame rate to reach (60 by default)
  59021. */
  59022. targetFrameRate: number;
  59023. /**
  59024. * Defines the interval between two checkes (2000ms by default)
  59025. */
  59026. trackerDuration: number;
  59027. /**
  59028. * Gets the list of optimizations to apply
  59029. */
  59030. optimizations: SceneOptimization[];
  59031. /**
  59032. * Creates a new list of options used by SceneOptimizer
  59033. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  59034. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  59035. */
  59036. constructor(
  59037. /**
  59038. * Defines the target frame rate to reach (60 by default)
  59039. */
  59040. targetFrameRate?: number,
  59041. /**
  59042. * Defines the interval between two checkes (2000ms by default)
  59043. */
  59044. trackerDuration?: number);
  59045. /**
  59046. * Add a new optimization
  59047. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  59048. * @returns the current SceneOptimizerOptions
  59049. */
  59050. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  59051. /**
  59052. * Add a new custom optimization
  59053. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  59054. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  59055. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  59056. * @returns the current SceneOptimizerOptions
  59057. */
  59058. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  59059. /**
  59060. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  59061. * @param targetFrameRate defines the target frame rate (60 by default)
  59062. * @returns a SceneOptimizerOptions object
  59063. */
  59064. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  59065. /**
  59066. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  59067. * @param targetFrameRate defines the target frame rate (60 by default)
  59068. * @returns a SceneOptimizerOptions object
  59069. */
  59070. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  59071. /**
  59072. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  59073. * @param targetFrameRate defines the target frame rate (60 by default)
  59074. * @returns a SceneOptimizerOptions object
  59075. */
  59076. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  59077. }
  59078. /**
  59079. * Class used to run optimizations in order to reach a target frame rate
  59080. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  59081. */
  59082. export class SceneOptimizer implements IDisposable {
  59083. private _isRunning;
  59084. private _options;
  59085. private _scene;
  59086. private _currentPriorityLevel;
  59087. private _targetFrameRate;
  59088. private _trackerDuration;
  59089. private _currentFrameRate;
  59090. private _sceneDisposeObserver;
  59091. private _improvementMode;
  59092. /**
  59093. * Defines an observable called when the optimizer reaches the target frame rate
  59094. */
  59095. onSuccessObservable: Observable<SceneOptimizer>;
  59096. /**
  59097. * Defines an observable called when the optimizer enables an optimization
  59098. */
  59099. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  59100. /**
  59101. * Defines an observable called when the optimizer is not able to reach the target frame rate
  59102. */
  59103. onFailureObservable: Observable<SceneOptimizer>;
  59104. /**
  59105. * Gets a boolean indicating if the optimizer is in improvement mode
  59106. */
  59107. readonly isInImprovementMode: boolean;
  59108. /**
  59109. * Gets the current priority level (0 at start)
  59110. */
  59111. readonly currentPriorityLevel: number;
  59112. /**
  59113. * Gets the current frame rate checked by the SceneOptimizer
  59114. */
  59115. readonly currentFrameRate: number;
  59116. /**
  59117. * Gets or sets the current target frame rate (60 by default)
  59118. */
  59119. /**
  59120. * Gets or sets the current target frame rate (60 by default)
  59121. */
  59122. targetFrameRate: number;
  59123. /**
  59124. * Gets or sets the current interval between two checks (every 2000ms by default)
  59125. */
  59126. /**
  59127. * Gets or sets the current interval between two checks (every 2000ms by default)
  59128. */
  59129. trackerDuration: number;
  59130. /**
  59131. * Gets the list of active optimizations
  59132. */
  59133. readonly optimizations: SceneOptimization[];
  59134. /**
  59135. * Creates a new SceneOptimizer
  59136. * @param scene defines the scene to work on
  59137. * @param options defines the options to use with the SceneOptimizer
  59138. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  59139. * @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)
  59140. */
  59141. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  59142. /**
  59143. * Stops the current optimizer
  59144. */
  59145. stop(): void;
  59146. /**
  59147. * Reset the optimizer to initial step (current priority level = 0)
  59148. */
  59149. reset(): void;
  59150. /**
  59151. * Start the optimizer. By default it will try to reach a specific framerate
  59152. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  59153. */
  59154. start(): void;
  59155. private _checkCurrentState;
  59156. /**
  59157. * Release all resources
  59158. */
  59159. dispose(): void;
  59160. /**
  59161. * Helper function to create a SceneOptimizer with one single line of code
  59162. * @param scene defines the scene to work on
  59163. * @param options defines the options to use with the SceneOptimizer
  59164. * @param onSuccess defines a callback to call on success
  59165. * @param onFailure defines a callback to call on failure
  59166. * @returns the new SceneOptimizer object
  59167. */
  59168. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  59169. }
  59170. }
  59171. declare module "babylonjs/Misc/sceneSerializer" {
  59172. import { Scene } from "babylonjs/scene";
  59173. /**
  59174. * Class used to serialize a scene into a string
  59175. */
  59176. export class SceneSerializer {
  59177. /**
  59178. * Clear cache used by a previous serialization
  59179. */
  59180. static ClearCache(): void;
  59181. /**
  59182. * Serialize a scene into a JSON compatible object
  59183. * @param scene defines the scene to serialize
  59184. * @returns a JSON compatible object
  59185. */
  59186. static Serialize(scene: Scene): any;
  59187. /**
  59188. * Serialize a mesh into a JSON compatible object
  59189. * @param toSerialize defines the mesh to serialize
  59190. * @param withParents defines if parents must be serialized as well
  59191. * @param withChildren defines if children must be serialized as well
  59192. * @returns a JSON compatible object
  59193. */
  59194. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  59195. }
  59196. }
  59197. declare module "babylonjs/Misc/textureTools" {
  59198. import { Texture } from "babylonjs/Materials/Textures/texture";
  59199. /**
  59200. * Class used to host texture specific utilities
  59201. */
  59202. export class TextureTools {
  59203. /**
  59204. * Uses the GPU to create a copy texture rescaled at a given size
  59205. * @param texture Texture to copy from
  59206. * @param width defines the desired width
  59207. * @param height defines the desired height
  59208. * @param useBilinearMode defines if bilinear mode has to be used
  59209. * @return the generated texture
  59210. */
  59211. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  59212. }
  59213. }
  59214. declare module "babylonjs/Misc/videoRecorder" {
  59215. import { Nullable } from "babylonjs/types";
  59216. import { Engine } from "babylonjs/Engines/engine";
  59217. /**
  59218. * This represents the different options avilable for the video capture.
  59219. */
  59220. export interface VideoRecorderOptions {
  59221. /** Defines the mime type of the video */
  59222. mimeType: string;
  59223. /** Defines the video the video should be recorded at */
  59224. fps: number;
  59225. /** Defines the chunk size for the recording data */
  59226. recordChunckSize: number;
  59227. /** The audio tracks to attach to the record */
  59228. audioTracks?: MediaStreamTrack[];
  59229. }
  59230. /**
  59231. * This can helps recording videos from BabylonJS.
  59232. * This is based on the available WebRTC functionalities of the browser.
  59233. *
  59234. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  59235. */
  59236. export class VideoRecorder {
  59237. private static readonly _defaultOptions;
  59238. /**
  59239. * Returns wehther or not the VideoRecorder is available in your browser.
  59240. * @param engine Defines the Babylon Engine to check the support for
  59241. * @returns true if supported otherwise false
  59242. */
  59243. static IsSupported(engine: Engine): boolean;
  59244. private readonly _options;
  59245. private _canvas;
  59246. private _mediaRecorder;
  59247. private _recordedChunks;
  59248. private _fileName;
  59249. private _resolve;
  59250. private _reject;
  59251. /**
  59252. * True wether a recording is already in progress.
  59253. */
  59254. readonly isRecording: boolean;
  59255. /**
  59256. * Create a new VideoCapture object which can help converting what you see in Babylon to
  59257. * a video file.
  59258. * @param engine Defines the BabylonJS Engine you wish to record
  59259. * @param options Defines options that can be used to customized the capture
  59260. */
  59261. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  59262. /**
  59263. * Stops the current recording before the default capture timeout passed in the startRecording
  59264. * functions.
  59265. */
  59266. stopRecording(): void;
  59267. /**
  59268. * Starts recording the canvas for a max duration specified in parameters.
  59269. * @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.
  59270. * @param maxDuration Defines the maximum recording time in seconds.
  59271. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  59272. * @return a promise callback at the end of the recording with the video data in Blob.
  59273. */
  59274. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  59275. /**
  59276. * Releases internal resources used during the recording.
  59277. */
  59278. dispose(): void;
  59279. private _handleDataAvailable;
  59280. private _handleError;
  59281. private _handleStop;
  59282. }
  59283. }
  59284. declare module "babylonjs/Misc/screenshotTools" {
  59285. import { Camera } from "babylonjs/Cameras/camera";
  59286. import { Engine } from "babylonjs/Engines/engine";
  59287. /**
  59288. * Class containing a set of static utilities functions for screenshots
  59289. */
  59290. export class ScreenshotTools {
  59291. /**
  59292. * Captures a screenshot of the current rendering
  59293. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  59294. * @param engine defines the rendering engine
  59295. * @param camera defines the source camera
  59296. * @param size This parameter can be set to a single number or to an object with the
  59297. * following (optional) properties: precision, width, height. If a single number is passed,
  59298. * it will be used for both width and height. If an object is passed, the screenshot size
  59299. * will be derived from the parameters. The precision property is a multiplier allowing
  59300. * rendering at a higher or lower resolution
  59301. * @param successCallback defines the callback receives a single parameter which contains the
  59302. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  59303. * src parameter of an <img> to display it
  59304. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  59305. * Check your browser for supported MIME types
  59306. */
  59307. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  59308. /**
  59309. * Generates an image screenshot from the specified camera.
  59310. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  59311. * @param engine The engine to use for rendering
  59312. * @param camera The camera to use for rendering
  59313. * @param size This parameter can be set to a single number or to an object with the
  59314. * following (optional) properties: precision, width, height. If a single number is passed,
  59315. * it will be used for both width and height. If an object is passed, the screenshot size
  59316. * will be derived from the parameters. The precision property is a multiplier allowing
  59317. * rendering at a higher or lower resolution
  59318. * @param successCallback The callback receives a single parameter which contains the
  59319. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  59320. * src parameter of an <img> to display it
  59321. * @param mimeType The MIME type of the screenshot image (default: image/png).
  59322. * Check your browser for supported MIME types
  59323. * @param samples Texture samples (default: 1)
  59324. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  59325. * @param fileName A name for for the downloaded file.
  59326. */
  59327. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  59328. }
  59329. }
  59330. declare module "babylonjs/Misc/index" {
  59331. export * from "babylonjs/Misc/andOrNotEvaluator";
  59332. export * from "babylonjs/Misc/assetsManager";
  59333. export * from "babylonjs/Misc/dds";
  59334. export * from "babylonjs/Misc/decorators";
  59335. export * from "babylonjs/Misc/deferred";
  59336. export * from "babylonjs/Misc/environmentTextureTools";
  59337. export * from "babylonjs/Misc/meshExploder";
  59338. export * from "babylonjs/Misc/filesInput";
  59339. export * from "babylonjs/Misc/HighDynamicRange/index";
  59340. export * from "babylonjs/Misc/khronosTextureContainer";
  59341. export * from "babylonjs/Misc/observable";
  59342. export * from "babylonjs/Misc/performanceMonitor";
  59343. export * from "babylonjs/Misc/promise";
  59344. export * from "babylonjs/Misc/sceneOptimizer";
  59345. export * from "babylonjs/Misc/sceneSerializer";
  59346. export * from "babylonjs/Misc/smartArray";
  59347. export * from "babylonjs/Misc/stringDictionary";
  59348. export * from "babylonjs/Misc/tags";
  59349. export * from "babylonjs/Misc/textureTools";
  59350. export * from "babylonjs/Misc/tga";
  59351. export * from "babylonjs/Misc/tools";
  59352. export * from "babylonjs/Misc/videoRecorder";
  59353. export * from "babylonjs/Misc/virtualJoystick";
  59354. export * from "babylonjs/Misc/workerPool";
  59355. export * from "babylonjs/Misc/logger";
  59356. export * from "babylonjs/Misc/typeStore";
  59357. export * from "babylonjs/Misc/filesInputStore";
  59358. export * from "babylonjs/Misc/deepCopier";
  59359. export * from "babylonjs/Misc/pivotTools";
  59360. export * from "babylonjs/Misc/precisionDate";
  59361. export * from "babylonjs/Misc/screenshotTools";
  59362. export * from "babylonjs/Misc/typeStore";
  59363. export * from "babylonjs/Misc/webRequest";
  59364. export * from "babylonjs/Misc/iInspectable";
  59365. }
  59366. declare module "babylonjs/index" {
  59367. export * from "babylonjs/abstractScene";
  59368. export * from "babylonjs/Actions/index";
  59369. export * from "babylonjs/Animations/index";
  59370. export * from "babylonjs/assetContainer";
  59371. export * from "babylonjs/Audio/index";
  59372. export * from "babylonjs/Behaviors/index";
  59373. export * from "babylonjs/Bones/index";
  59374. export * from "babylonjs/Cameras/index";
  59375. export * from "babylonjs/Collisions/index";
  59376. export * from "babylonjs/Culling/index";
  59377. export * from "babylonjs/Debug/index";
  59378. export * from "babylonjs/Engines/index";
  59379. export * from "babylonjs/Events/index";
  59380. export * from "babylonjs/Gamepads/index";
  59381. export * from "babylonjs/Gizmos/index";
  59382. export * from "babylonjs/Helpers/index";
  59383. export * from "babylonjs/Instrumentation/index";
  59384. export * from "babylonjs/Layers/index";
  59385. export * from "babylonjs/LensFlares/index";
  59386. export * from "babylonjs/Lights/index";
  59387. export * from "babylonjs/Loading/index";
  59388. export * from "babylonjs/Materials/index";
  59389. export * from "babylonjs/Maths/index";
  59390. export * from "babylonjs/Meshes/index";
  59391. export * from "babylonjs/Morph/index";
  59392. export * from "babylonjs/node";
  59393. export * from "babylonjs/Offline/index";
  59394. export * from "babylonjs/Particles/index";
  59395. export * from "babylonjs/Physics/index";
  59396. export * from "babylonjs/PostProcesses/index";
  59397. export * from "babylonjs/Probes/index";
  59398. export * from "babylonjs/Rendering/index";
  59399. export * from "babylonjs/scene";
  59400. export * from "babylonjs/sceneComponent";
  59401. export * from "babylonjs/Sprites/index";
  59402. export * from "babylonjs/States/index";
  59403. export * from "babylonjs/Misc/index";
  59404. export * from "babylonjs/types";
  59405. }
  59406. declare module "babylonjs/Animations/pathCursor" {
  59407. import { Path2, Vector3 } from "babylonjs/Maths/math";
  59408. /**
  59409. * A cursor which tracks a point on a path
  59410. */
  59411. export class PathCursor {
  59412. private path;
  59413. /**
  59414. * Stores path cursor callbacks for when an onchange event is triggered
  59415. */
  59416. private _onchange;
  59417. /**
  59418. * The value of the path cursor
  59419. */
  59420. value: number;
  59421. /**
  59422. * The animation array of the path cursor
  59423. */
  59424. animations: Animation[];
  59425. /**
  59426. * Initializes the path cursor
  59427. * @param path The path to track
  59428. */
  59429. constructor(path: Path2);
  59430. /**
  59431. * Gets the cursor point on the path
  59432. * @returns A point on the path cursor at the cursor location
  59433. */
  59434. getPoint(): Vector3;
  59435. /**
  59436. * Moves the cursor ahead by the step amount
  59437. * @param step The amount to move the cursor forward
  59438. * @returns This path cursor
  59439. */
  59440. moveAhead(step?: number): PathCursor;
  59441. /**
  59442. * Moves the cursor behind by the step amount
  59443. * @param step The amount to move the cursor back
  59444. * @returns This path cursor
  59445. */
  59446. moveBack(step?: number): PathCursor;
  59447. /**
  59448. * Moves the cursor by the step amount
  59449. * If the step amount is greater than one, an exception is thrown
  59450. * @param step The amount to move the cursor
  59451. * @returns This path cursor
  59452. */
  59453. move(step: number): PathCursor;
  59454. /**
  59455. * Ensures that the value is limited between zero and one
  59456. * @returns This path cursor
  59457. */
  59458. private ensureLimits;
  59459. /**
  59460. * Runs onchange callbacks on change (used by the animation engine)
  59461. * @returns This path cursor
  59462. */
  59463. private raiseOnChange;
  59464. /**
  59465. * Executes a function on change
  59466. * @param f A path cursor onchange callback
  59467. * @returns This path cursor
  59468. */
  59469. onchange(f: (cursor: PathCursor) => void): PathCursor;
  59470. }
  59471. }
  59472. declare module "babylonjs/Legacy/legacy" {
  59473. import * as Babylon from "babylonjs/index";
  59474. export * from "babylonjs/index";
  59475. }
  59476. declare module "babylonjs/Shaders/blur.fragment" {
  59477. /** @hidden */
  59478. export var blurPixelShader: {
  59479. name: string;
  59480. shader: string;
  59481. };
  59482. }
  59483. declare module "babylonjs/Shaders/ShadersInclude/bones300Declaration" {
  59484. /** @hidden */
  59485. export var bones300Declaration: {
  59486. name: string;
  59487. shader: string;
  59488. };
  59489. }
  59490. declare module "babylonjs/Shaders/ShadersInclude/instances300Declaration" {
  59491. /** @hidden */
  59492. export var instances300Declaration: {
  59493. name: string;
  59494. shader: string;
  59495. };
  59496. }
  59497. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  59498. /** @hidden */
  59499. export var pointCloudVertexDeclaration: {
  59500. name: string;
  59501. shader: string;
  59502. };
  59503. }
  59504. // Mixins
  59505. interface Window {
  59506. mozIndexedDB: IDBFactory;
  59507. webkitIndexedDB: IDBFactory;
  59508. msIndexedDB: IDBFactory;
  59509. webkitURL: typeof URL;
  59510. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  59511. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  59512. WebGLRenderingContext: WebGLRenderingContext;
  59513. MSGesture: MSGesture;
  59514. CANNON: any;
  59515. AudioContext: AudioContext;
  59516. webkitAudioContext: AudioContext;
  59517. PointerEvent: any;
  59518. Math: Math;
  59519. Uint8Array: Uint8ArrayConstructor;
  59520. Float32Array: Float32ArrayConstructor;
  59521. mozURL: typeof URL;
  59522. msURL: typeof URL;
  59523. VRFrameData: any; // WebVR, from specs 1.1
  59524. DracoDecoderModule: any;
  59525. setImmediate(handler: (...args: any[]) => void): number;
  59526. }
  59527. interface HTMLCanvasElement {
  59528. requestPointerLock(): void;
  59529. msRequestPointerLock?(): void;
  59530. mozRequestPointerLock?(): void;
  59531. webkitRequestPointerLock?(): void;
  59532. /** Track wether a record is in progress */
  59533. isRecording: boolean;
  59534. /** Capture Stream method defined by some browsers */
  59535. captureStream(fps?: number): MediaStream;
  59536. }
  59537. interface CanvasRenderingContext2D {
  59538. msImageSmoothingEnabled: boolean;
  59539. }
  59540. interface MouseEvent {
  59541. mozMovementX: number;
  59542. mozMovementY: number;
  59543. webkitMovementX: number;
  59544. webkitMovementY: number;
  59545. msMovementX: number;
  59546. msMovementY: number;
  59547. }
  59548. interface Navigator {
  59549. mozGetVRDevices: (any: any) => any;
  59550. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  59551. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  59552. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  59553. webkitGetGamepads(): Gamepad[];
  59554. msGetGamepads(): Gamepad[];
  59555. webkitGamepads(): Gamepad[];
  59556. }
  59557. interface HTMLVideoElement {
  59558. mozSrcObject: any;
  59559. }
  59560. interface Math {
  59561. fround(x: number): number;
  59562. imul(a: number, b: number): number;
  59563. }
  59564. interface WebGLRenderingContext {
  59565. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  59566. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  59567. vertexAttribDivisor(index: number, divisor: number): void;
  59568. createVertexArray(): any;
  59569. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  59570. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  59571. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  59572. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  59573. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  59574. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  59575. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  59576. // Queries
  59577. createQuery(): WebGLQuery;
  59578. deleteQuery(query: WebGLQuery): void;
  59579. beginQuery(target: number, query: WebGLQuery): void;
  59580. endQuery(target: number): void;
  59581. getQueryParameter(query: WebGLQuery, pname: number): any;
  59582. getQuery(target: number, pname: number): any;
  59583. MAX_SAMPLES: number;
  59584. RGBA8: number;
  59585. READ_FRAMEBUFFER: number;
  59586. DRAW_FRAMEBUFFER: number;
  59587. UNIFORM_BUFFER: number;
  59588. HALF_FLOAT_OES: number;
  59589. RGBA16F: number;
  59590. RGBA32F: number;
  59591. R32F: number;
  59592. RG32F: number;
  59593. RGB32F: number;
  59594. R16F: number;
  59595. RG16F: number;
  59596. RGB16F: number;
  59597. RED: number;
  59598. RG: number;
  59599. R8: number;
  59600. RG8: number;
  59601. UNSIGNED_INT_24_8: number;
  59602. DEPTH24_STENCIL8: number;
  59603. /* Multiple Render Targets */
  59604. drawBuffers(buffers: number[]): void;
  59605. readBuffer(src: number): void;
  59606. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  59607. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  59608. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  59609. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  59610. // Occlusion Query
  59611. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  59612. ANY_SAMPLES_PASSED: number;
  59613. QUERY_RESULT_AVAILABLE: number;
  59614. QUERY_RESULT: number;
  59615. }
  59616. interface WebGLProgram {
  59617. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  59618. }
  59619. interface EXT_disjoint_timer_query {
  59620. QUERY_COUNTER_BITS_EXT: number;
  59621. TIME_ELAPSED_EXT: number;
  59622. TIMESTAMP_EXT: number;
  59623. GPU_DISJOINT_EXT: number;
  59624. QUERY_RESULT_EXT: number;
  59625. QUERY_RESULT_AVAILABLE_EXT: number;
  59626. queryCounterEXT(query: WebGLQuery, target: number): void;
  59627. createQueryEXT(): WebGLQuery;
  59628. beginQueryEXT(target: number, query: WebGLQuery): void;
  59629. endQueryEXT(target: number): void;
  59630. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  59631. deleteQueryEXT(query: WebGLQuery): void;
  59632. }
  59633. interface WebGLUniformLocation {
  59634. _currentState: any;
  59635. }
  59636. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  59637. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  59638. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  59639. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  59640. interface WebGLRenderingContext {
  59641. readonly RASTERIZER_DISCARD: number;
  59642. readonly DEPTH_COMPONENT24: number;
  59643. readonly TEXTURE_3D: number;
  59644. readonly TEXTURE_2D_ARRAY: number;
  59645. readonly TEXTURE_COMPARE_FUNC: number;
  59646. readonly TEXTURE_COMPARE_MODE: number;
  59647. readonly COMPARE_REF_TO_TEXTURE: number;
  59648. readonly TEXTURE_WRAP_R: number;
  59649. readonly HALF_FLOAT: number;
  59650. readonly RGB8: number;
  59651. readonly RED_INTEGER: number;
  59652. readonly RG_INTEGER: number;
  59653. readonly RGB_INTEGER: number;
  59654. readonly RGBA_INTEGER: number;
  59655. readonly R8_SNORM: number;
  59656. readonly RG8_SNORM: number;
  59657. readonly RGB8_SNORM: number;
  59658. readonly RGBA8_SNORM: number;
  59659. readonly R8I: number;
  59660. readonly RG8I: number;
  59661. readonly RGB8I: number;
  59662. readonly RGBA8I: number;
  59663. readonly R8UI: number;
  59664. readonly RG8UI: number;
  59665. readonly RGB8UI: number;
  59666. readonly RGBA8UI: number;
  59667. readonly R16I: number;
  59668. readonly RG16I: number;
  59669. readonly RGB16I: number;
  59670. readonly RGBA16I: number;
  59671. readonly R16UI: number;
  59672. readonly RG16UI: number;
  59673. readonly RGB16UI: number;
  59674. readonly RGBA16UI: number;
  59675. readonly R32I: number;
  59676. readonly RG32I: number;
  59677. readonly RGB32I: number;
  59678. readonly RGBA32I: number;
  59679. readonly R32UI: number;
  59680. readonly RG32UI: number;
  59681. readonly RGB32UI: number;
  59682. readonly RGBA32UI: number;
  59683. readonly RGB10_A2UI: number;
  59684. readonly R11F_G11F_B10F: number;
  59685. readonly RGB9_E5: number;
  59686. readonly RGB10_A2: number;
  59687. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  59688. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  59689. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  59690. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  59691. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  59692. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  59693. 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;
  59694. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  59695. readonly TRANSFORM_FEEDBACK: number;
  59696. readonly INTERLEAVED_ATTRIBS: number;
  59697. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  59698. createTransformFeedback(): WebGLTransformFeedback;
  59699. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  59700. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  59701. beginTransformFeedback(primitiveMode: number): void;
  59702. endTransformFeedback(): void;
  59703. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  59704. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  59705. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  59706. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  59707. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  59708. }
  59709. interface ImageBitmap {
  59710. readonly width: number;
  59711. readonly height: number;
  59712. close(): void;
  59713. }
  59714. interface WebGLQuery extends WebGLObject {
  59715. }
  59716. declare var WebGLQuery: {
  59717. prototype: WebGLQuery;
  59718. new(): WebGLQuery;
  59719. };
  59720. interface WebGLSampler extends WebGLObject {
  59721. }
  59722. declare var WebGLSampler: {
  59723. prototype: WebGLSampler;
  59724. new(): WebGLSampler;
  59725. };
  59726. interface WebGLSync extends WebGLObject {
  59727. }
  59728. declare var WebGLSync: {
  59729. prototype: WebGLSync;
  59730. new(): WebGLSync;
  59731. };
  59732. interface WebGLTransformFeedback extends WebGLObject {
  59733. }
  59734. declare var WebGLTransformFeedback: {
  59735. prototype: WebGLTransformFeedback;
  59736. new(): WebGLTransformFeedback;
  59737. };
  59738. interface WebGLVertexArrayObject extends WebGLObject {
  59739. }
  59740. declare var WebGLVertexArrayObject: {
  59741. prototype: WebGLVertexArrayObject;
  59742. new(): WebGLVertexArrayObject;
  59743. };
  59744. // Type definitions for WebVR API
  59745. // Project: https://w3c.github.io/webvr/
  59746. // Definitions by: six a <https://github.com/lostfictions>
  59747. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  59748. interface VRDisplay extends EventTarget {
  59749. /**
  59750. * Dictionary of capabilities describing the VRDisplay.
  59751. */
  59752. readonly capabilities: VRDisplayCapabilities;
  59753. /**
  59754. * z-depth defining the far plane of the eye view frustum
  59755. * enables mapping of values in the render target depth
  59756. * attachment to scene coordinates. Initially set to 10000.0.
  59757. */
  59758. depthFar: number;
  59759. /**
  59760. * z-depth defining the near plane of the eye view frustum
  59761. * enables mapping of values in the render target depth
  59762. * attachment to scene coordinates. Initially set to 0.01.
  59763. */
  59764. depthNear: number;
  59765. /**
  59766. * An identifier for this distinct VRDisplay. Used as an
  59767. * association point in the Gamepad API.
  59768. */
  59769. readonly displayId: number;
  59770. /**
  59771. * A display name, a user-readable name identifying it.
  59772. */
  59773. readonly displayName: string;
  59774. readonly isConnected: boolean;
  59775. readonly isPresenting: boolean;
  59776. /**
  59777. * If this VRDisplay supports room-scale experiences, the optional
  59778. * stage attribute contains details on the room-scale parameters.
  59779. */
  59780. readonly stageParameters: VRStageParameters | null;
  59781. /**
  59782. * Passing the value returned by `requestAnimationFrame` to
  59783. * `cancelAnimationFrame` will unregister the callback.
  59784. * @param handle Define the hanle of the request to cancel
  59785. */
  59786. cancelAnimationFrame(handle: number): void;
  59787. /**
  59788. * Stops presenting to the VRDisplay.
  59789. * @returns a promise to know when it stopped
  59790. */
  59791. exitPresent(): Promise<void>;
  59792. /**
  59793. * Return the current VREyeParameters for the given eye.
  59794. * @param whichEye Define the eye we want the parameter for
  59795. * @returns the eye parameters
  59796. */
  59797. getEyeParameters(whichEye: string): VREyeParameters;
  59798. /**
  59799. * Populates the passed VRFrameData with the information required to render
  59800. * the current frame.
  59801. * @param frameData Define the data structure to populate
  59802. * @returns true if ok otherwise false
  59803. */
  59804. getFrameData(frameData: VRFrameData): boolean;
  59805. /**
  59806. * Get the layers currently being presented.
  59807. * @returns the list of VR layers
  59808. */
  59809. getLayers(): VRLayer[];
  59810. /**
  59811. * Return a VRPose containing the future predicted pose of the VRDisplay
  59812. * when the current frame will be presented. The value returned will not
  59813. * change until JavaScript has returned control to the browser.
  59814. *
  59815. * The VRPose will contain the position, orientation, velocity,
  59816. * and acceleration of each of these properties.
  59817. * @returns the pose object
  59818. */
  59819. getPose(): VRPose;
  59820. /**
  59821. * Return the current instantaneous pose of the VRDisplay, with no
  59822. * prediction applied.
  59823. * @returns the current instantaneous pose
  59824. */
  59825. getImmediatePose(): VRPose;
  59826. /**
  59827. * The callback passed to `requestAnimationFrame` will be called
  59828. * any time a new frame should be rendered. When the VRDisplay is
  59829. * presenting the callback will be called at the native refresh
  59830. * rate of the HMD. When not presenting this function acts
  59831. * identically to how window.requestAnimationFrame acts. Content should
  59832. * make no assumptions of frame rate or vsync behavior as the HMD runs
  59833. * asynchronously from other displays and at differing refresh rates.
  59834. * @param callback Define the eaction to run next frame
  59835. * @returns the request handle it
  59836. */
  59837. requestAnimationFrame(callback: FrameRequestCallback): number;
  59838. /**
  59839. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  59840. * Repeat calls while already presenting will update the VRLayers being displayed.
  59841. * @param layers Define the list of layer to present
  59842. * @returns a promise to know when the request has been fulfilled
  59843. */
  59844. requestPresent(layers: VRLayer[]): Promise<void>;
  59845. /**
  59846. * Reset the pose for this display, treating its current position and
  59847. * orientation as the "origin/zero" values. VRPose.position,
  59848. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  59849. * updated when calling resetPose(). This should be called in only
  59850. * sitting-space experiences.
  59851. */
  59852. resetPose(): void;
  59853. /**
  59854. * The VRLayer provided to the VRDisplay will be captured and presented
  59855. * in the HMD. Calling this function has the same effect on the source
  59856. * canvas as any other operation that uses its source image, and canvases
  59857. * created without preserveDrawingBuffer set to true will be cleared.
  59858. * @param pose Define the pose to submit
  59859. */
  59860. submitFrame(pose?: VRPose): void;
  59861. }
  59862. declare var VRDisplay: {
  59863. prototype: VRDisplay;
  59864. new(): VRDisplay;
  59865. };
  59866. interface VRLayer {
  59867. leftBounds?: number[] | Float32Array | null;
  59868. rightBounds?: number[] | Float32Array | null;
  59869. source?: HTMLCanvasElement | null;
  59870. }
  59871. interface VRDisplayCapabilities {
  59872. readonly canPresent: boolean;
  59873. readonly hasExternalDisplay: boolean;
  59874. readonly hasOrientation: boolean;
  59875. readonly hasPosition: boolean;
  59876. readonly maxLayers: number;
  59877. }
  59878. interface VREyeParameters {
  59879. /** @deprecated */
  59880. readonly fieldOfView: VRFieldOfView;
  59881. readonly offset: Float32Array;
  59882. readonly renderHeight: number;
  59883. readonly renderWidth: number;
  59884. }
  59885. interface VRFieldOfView {
  59886. readonly downDegrees: number;
  59887. readonly leftDegrees: number;
  59888. readonly rightDegrees: number;
  59889. readonly upDegrees: number;
  59890. }
  59891. interface VRFrameData {
  59892. readonly leftProjectionMatrix: Float32Array;
  59893. readonly leftViewMatrix: Float32Array;
  59894. readonly pose: VRPose;
  59895. readonly rightProjectionMatrix: Float32Array;
  59896. readonly rightViewMatrix: Float32Array;
  59897. readonly timestamp: number;
  59898. }
  59899. interface VRPose {
  59900. readonly angularAcceleration: Float32Array | null;
  59901. readonly angularVelocity: Float32Array | null;
  59902. readonly linearAcceleration: Float32Array | null;
  59903. readonly linearVelocity: Float32Array | null;
  59904. readonly orientation: Float32Array | null;
  59905. readonly position: Float32Array | null;
  59906. readonly timestamp: number;
  59907. }
  59908. interface VRStageParameters {
  59909. sittingToStandingTransform?: Float32Array;
  59910. sizeX?: number;
  59911. sizeY?: number;
  59912. }
  59913. interface Navigator {
  59914. getVRDisplays(): Promise<VRDisplay[]>;
  59915. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  59916. }
  59917. interface Window {
  59918. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  59919. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  59920. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  59921. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  59922. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  59923. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  59924. }
  59925. interface Gamepad {
  59926. readonly displayId: number;
  59927. }
  59928. interface XRDevice {
  59929. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  59930. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  59931. }
  59932. interface XRSession {
  59933. getInputSources(): Array<any>;
  59934. baseLayer: XRWebGLLayer;
  59935. requestFrameOfReference(type: string): Promise<void>;
  59936. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  59937. end(): Promise<void>;
  59938. requestAnimationFrame: Function;
  59939. addEventListener: Function;
  59940. }
  59941. interface XRSessionCreationOptions {
  59942. outputContext?: WebGLRenderingContext | null;
  59943. immersive?: boolean;
  59944. environmentIntegration?: boolean;
  59945. }
  59946. interface XRLayer {
  59947. getViewport: Function;
  59948. framebufferWidth: number;
  59949. framebufferHeight: number;
  59950. }
  59951. interface XRView {
  59952. projectionMatrix: Float32Array;
  59953. }
  59954. interface XRFrame {
  59955. getDevicePose: Function;
  59956. getInputPose: Function;
  59957. views: Array<XRView>;
  59958. baseLayer: XRLayer;
  59959. }
  59960. interface XRFrameOfReference {
  59961. }
  59962. interface XRWebGLLayer extends XRLayer {
  59963. framebuffer: WebGLFramebuffer;
  59964. }
  59965. declare var XRWebGLLayer: {
  59966. prototype: XRWebGLLayer;
  59967. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  59968. };
  59969. declare module "babylonjs" {
  59970. export * from "babylonjs/Legacy/legacy";
  59971. }
  59972. declare module BABYLON {
  59973. /** Alias type for value that can be null */
  59974. export type Nullable<T> = T | null;
  59975. /**
  59976. * Alias type for number that are floats
  59977. * @ignorenaming
  59978. */
  59979. export type float = number;
  59980. /**
  59981. * Alias type for number that are doubles.
  59982. * @ignorenaming
  59983. */
  59984. export type double = number;
  59985. /**
  59986. * Alias type for number that are integer
  59987. * @ignorenaming
  59988. */
  59989. export type int = number;
  59990. /** Alias type for number array or Float32Array */
  59991. export type FloatArray = number[] | Float32Array;
  59992. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  59993. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  59994. /**
  59995. * Alias for types that can be used by a Buffer or VertexBuffer.
  59996. */
  59997. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  59998. /**
  59999. * Alias type for primitive types
  60000. * @ignorenaming
  60001. */
  60002. type Primitive = undefined | null | boolean | string | number | Function;
  60003. /**
  60004. * Type modifier to make all the properties of an object Readonly
  60005. */
  60006. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  60007. /**
  60008. * Type modifier to make all the properties of an object Readonly recursively
  60009. */
  60010. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  60011. /** @hidden */
  60012. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  60013. }
  60014. /** @hidden */
  60015. /** @hidden */
  60016. type DeepImmutableObject<T> = {
  60017. readonly [K in keyof T]: DeepImmutable<T[K]>;
  60018. };
  60019. }
  60020. declare module BABYLON {
  60021. /**
  60022. * Class containing a set of static utilities functions for arrays.
  60023. */
  60024. export class ArrayTools {
  60025. /**
  60026. * Returns an array of the given size filled with element built from the given constructor and the paramters
  60027. * @param size the number of element to construct and put in the array
  60028. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  60029. * @returns a new array filled with new objects
  60030. */
  60031. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  60032. }
  60033. }
  60034. declare module BABYLON {
  60035. /**
  60036. * Scalar computation library
  60037. */
  60038. export class Scalar {
  60039. /**
  60040. * Two pi constants convenient for computation.
  60041. */
  60042. static TwoPi: number;
  60043. /**
  60044. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  60045. * @param a number
  60046. * @param b number
  60047. * @param epsilon (default = 1.401298E-45)
  60048. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  60049. */
  60050. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  60051. /**
  60052. * Returns a string : the upper case translation of the number i to hexadecimal.
  60053. * @param i number
  60054. * @returns the upper case translation of the number i to hexadecimal.
  60055. */
  60056. static ToHex(i: number): string;
  60057. /**
  60058. * Returns -1 if value is negative and +1 is value is positive.
  60059. * @param value the value
  60060. * @returns the value itself if it's equal to zero.
  60061. */
  60062. static Sign(value: number): number;
  60063. /**
  60064. * Returns the value itself if it's between min and max.
  60065. * Returns min if the value is lower than min.
  60066. * Returns max if the value is greater than max.
  60067. * @param value the value to clmap
  60068. * @param min the min value to clamp to (default: 0)
  60069. * @param max the max value to clamp to (default: 1)
  60070. * @returns the clamped value
  60071. */
  60072. static Clamp(value: number, min?: number, max?: number): number;
  60073. /**
  60074. * the log2 of value.
  60075. * @param value the value to compute log2 of
  60076. * @returns the log2 of value.
  60077. */
  60078. static Log2(value: number): number;
  60079. /**
  60080. * Loops the value, so that it is never larger than length and never smaller than 0.
  60081. *
  60082. * This is similar to the modulo operator but it works with floating point numbers.
  60083. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  60084. * With t = 5 and length = 2.5, the result would be 0.0.
  60085. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  60086. * @param value the value
  60087. * @param length the length
  60088. * @returns the looped value
  60089. */
  60090. static Repeat(value: number, length: number): number;
  60091. /**
  60092. * Normalize the value between 0.0 and 1.0 using min and max values
  60093. * @param value value to normalize
  60094. * @param min max to normalize between
  60095. * @param max min to normalize between
  60096. * @returns the normalized value
  60097. */
  60098. static Normalize(value: number, min: number, max: number): number;
  60099. /**
  60100. * Denormalize the value from 0.0 and 1.0 using min and max values
  60101. * @param normalized value to denormalize
  60102. * @param min max to denormalize between
  60103. * @param max min to denormalize between
  60104. * @returns the denormalized value
  60105. */
  60106. static Denormalize(normalized: number, min: number, max: number): number;
  60107. /**
  60108. * Calculates the shortest difference between two given angles given in degrees.
  60109. * @param current current angle in degrees
  60110. * @param target target angle in degrees
  60111. * @returns the delta
  60112. */
  60113. static DeltaAngle(current: number, target: number): number;
  60114. /**
  60115. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  60116. * @param tx value
  60117. * @param length length
  60118. * @returns The returned value will move back and forth between 0 and length
  60119. */
  60120. static PingPong(tx: number, length: number): number;
  60121. /**
  60122. * Interpolates between min and max with smoothing at the limits.
  60123. *
  60124. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  60125. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  60126. * @param from from
  60127. * @param to to
  60128. * @param tx value
  60129. * @returns the smooth stepped value
  60130. */
  60131. static SmoothStep(from: number, to: number, tx: number): number;
  60132. /**
  60133. * Moves a value current towards target.
  60134. *
  60135. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  60136. * Negative values of maxDelta pushes the value away from target.
  60137. * @param current current value
  60138. * @param target target value
  60139. * @param maxDelta max distance to move
  60140. * @returns resulting value
  60141. */
  60142. static MoveTowards(current: number, target: number, maxDelta: number): number;
  60143. /**
  60144. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  60145. *
  60146. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  60147. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  60148. * @param current current value
  60149. * @param target target value
  60150. * @param maxDelta max distance to move
  60151. * @returns resulting angle
  60152. */
  60153. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  60154. /**
  60155. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  60156. * @param start start value
  60157. * @param end target value
  60158. * @param amount amount to lerp between
  60159. * @returns the lerped value
  60160. */
  60161. static Lerp(start: number, end: number, amount: number): number;
  60162. /**
  60163. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  60164. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  60165. * @param start start value
  60166. * @param end target value
  60167. * @param amount amount to lerp between
  60168. * @returns the lerped value
  60169. */
  60170. static LerpAngle(start: number, end: number, amount: number): number;
  60171. /**
  60172. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  60173. * @param a start value
  60174. * @param b target value
  60175. * @param value value between a and b
  60176. * @returns the inverseLerp value
  60177. */
  60178. static InverseLerp(a: number, b: number, value: number): number;
  60179. /**
  60180. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  60181. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  60182. * @param value1 spline value
  60183. * @param tangent1 spline value
  60184. * @param value2 spline value
  60185. * @param tangent2 spline value
  60186. * @param amount input value
  60187. * @returns hermite result
  60188. */
  60189. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  60190. /**
  60191. * Returns a random float number between and min and max values
  60192. * @param min min value of random
  60193. * @param max max value of random
  60194. * @returns random value
  60195. */
  60196. static RandomRange(min: number, max: number): number;
  60197. /**
  60198. * This function returns percentage of a number in a given range.
  60199. *
  60200. * RangeToPercent(40,20,60) will return 0.5 (50%)
  60201. * RangeToPercent(34,0,100) will return 0.34 (34%)
  60202. * @param number to convert to percentage
  60203. * @param min min range
  60204. * @param max max range
  60205. * @returns the percentage
  60206. */
  60207. static RangeToPercent(number: number, min: number, max: number): number;
  60208. /**
  60209. * This function returns number that corresponds to the percentage in a given range.
  60210. *
  60211. * PercentToRange(0.34,0,100) will return 34.
  60212. * @param percent to convert to number
  60213. * @param min min range
  60214. * @param max max range
  60215. * @returns the number
  60216. */
  60217. static PercentToRange(percent: number, min: number, max: number): number;
  60218. /**
  60219. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  60220. * @param angle The angle to normalize in radian.
  60221. * @return The converted angle.
  60222. */
  60223. static NormalizeRadians(angle: number): number;
  60224. }
  60225. }
  60226. declare module BABYLON {
  60227. /**
  60228. * Constant used to convert a value to gamma space
  60229. * @ignorenaming
  60230. */
  60231. export const ToGammaSpace: number;
  60232. /**
  60233. * Constant used to convert a value to linear space
  60234. * @ignorenaming
  60235. */
  60236. export const ToLinearSpace = 2.2;
  60237. /**
  60238. * Constant used to define the minimal number value in Babylon.js
  60239. * @ignorenaming
  60240. */
  60241. let Epsilon: number;
  60242. /**
  60243. * Class used to hold a RBG color
  60244. */
  60245. export class Color3 {
  60246. /**
  60247. * Defines the red component (between 0 and 1, default is 0)
  60248. */
  60249. r: number;
  60250. /**
  60251. * Defines the green component (between 0 and 1, default is 0)
  60252. */
  60253. g: number;
  60254. /**
  60255. * Defines the blue component (between 0 and 1, default is 0)
  60256. */
  60257. b: number;
  60258. /**
  60259. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  60260. * @param r defines the red component (between 0 and 1, default is 0)
  60261. * @param g defines the green component (between 0 and 1, default is 0)
  60262. * @param b defines the blue component (between 0 and 1, default is 0)
  60263. */
  60264. constructor(
  60265. /**
  60266. * Defines the red component (between 0 and 1, default is 0)
  60267. */
  60268. r?: number,
  60269. /**
  60270. * Defines the green component (between 0 and 1, default is 0)
  60271. */
  60272. g?: number,
  60273. /**
  60274. * Defines the blue component (between 0 and 1, default is 0)
  60275. */
  60276. b?: number);
  60277. /**
  60278. * Creates a string with the Color3 current values
  60279. * @returns the string representation of the Color3 object
  60280. */
  60281. toString(): string;
  60282. /**
  60283. * Returns the string "Color3"
  60284. * @returns "Color3"
  60285. */
  60286. getClassName(): string;
  60287. /**
  60288. * Compute the Color3 hash code
  60289. * @returns an unique number that can be used to hash Color3 objects
  60290. */
  60291. getHashCode(): number;
  60292. /**
  60293. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  60294. * @param array defines the array where to store the r,g,b components
  60295. * @param index defines an optional index in the target array to define where to start storing values
  60296. * @returns the current Color3 object
  60297. */
  60298. toArray(array: FloatArray, index?: number): Color3;
  60299. /**
  60300. * Returns a new Color4 object from the current Color3 and the given alpha
  60301. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  60302. * @returns a new Color4 object
  60303. */
  60304. toColor4(alpha?: number): Color4;
  60305. /**
  60306. * Returns a new array populated with 3 numeric elements : red, green and blue values
  60307. * @returns the new array
  60308. */
  60309. asArray(): number[];
  60310. /**
  60311. * Returns the luminance value
  60312. * @returns a float value
  60313. */
  60314. toLuminance(): number;
  60315. /**
  60316. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  60317. * @param otherColor defines the second operand
  60318. * @returns the new Color3 object
  60319. */
  60320. multiply(otherColor: DeepImmutable<Color3>): Color3;
  60321. /**
  60322. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  60323. * @param otherColor defines the second operand
  60324. * @param result defines the Color3 object where to store the result
  60325. * @returns the current Color3
  60326. */
  60327. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  60328. /**
  60329. * Determines equality between Color3 objects
  60330. * @param otherColor defines the second operand
  60331. * @returns true if the rgb values are equal to the given ones
  60332. */
  60333. equals(otherColor: DeepImmutable<Color3>): boolean;
  60334. /**
  60335. * Determines equality between the current Color3 object and a set of r,b,g values
  60336. * @param r defines the red component to check
  60337. * @param g defines the green component to check
  60338. * @param b defines the blue component to check
  60339. * @returns true if the rgb values are equal to the given ones
  60340. */
  60341. equalsFloats(r: number, g: number, b: number): boolean;
  60342. /**
  60343. * Multiplies in place each rgb value by scale
  60344. * @param scale defines the scaling factor
  60345. * @returns the updated Color3
  60346. */
  60347. scale(scale: number): Color3;
  60348. /**
  60349. * Multiplies the rgb values by scale and stores the result into "result"
  60350. * @param scale defines the scaling factor
  60351. * @param result defines the Color3 object where to store the result
  60352. * @returns the unmodified current Color3
  60353. */
  60354. scaleToRef(scale: number, result: Color3): Color3;
  60355. /**
  60356. * Scale the current Color3 values by a factor and add the result to a given Color3
  60357. * @param scale defines the scale factor
  60358. * @param result defines color to store the result into
  60359. * @returns the unmodified current Color3
  60360. */
  60361. scaleAndAddToRef(scale: number, result: Color3): Color3;
  60362. /**
  60363. * Clamps the rgb values by the min and max values and stores the result into "result"
  60364. * @param min defines minimum clamping value (default is 0)
  60365. * @param max defines maximum clamping value (default is 1)
  60366. * @param result defines color to store the result into
  60367. * @returns the original Color3
  60368. */
  60369. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  60370. /**
  60371. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  60372. * @param otherColor defines the second operand
  60373. * @returns the new Color3
  60374. */
  60375. add(otherColor: DeepImmutable<Color3>): Color3;
  60376. /**
  60377. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  60378. * @param otherColor defines the second operand
  60379. * @param result defines Color3 object to store the result into
  60380. * @returns the unmodified current Color3
  60381. */
  60382. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  60383. /**
  60384. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  60385. * @param otherColor defines the second operand
  60386. * @returns the new Color3
  60387. */
  60388. subtract(otherColor: DeepImmutable<Color3>): Color3;
  60389. /**
  60390. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  60391. * @param otherColor defines the second operand
  60392. * @param result defines Color3 object to store the result into
  60393. * @returns the unmodified current Color3
  60394. */
  60395. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  60396. /**
  60397. * Copy the current object
  60398. * @returns a new Color3 copied the current one
  60399. */
  60400. clone(): Color3;
  60401. /**
  60402. * Copies the rgb values from the source in the current Color3
  60403. * @param source defines the source Color3 object
  60404. * @returns the updated Color3 object
  60405. */
  60406. copyFrom(source: DeepImmutable<Color3>): Color3;
  60407. /**
  60408. * Updates the Color3 rgb values from the given floats
  60409. * @param r defines the red component to read from
  60410. * @param g defines the green component to read from
  60411. * @param b defines the blue component to read from
  60412. * @returns the current Color3 object
  60413. */
  60414. copyFromFloats(r: number, g: number, b: number): Color3;
  60415. /**
  60416. * Updates the Color3 rgb values from the given floats
  60417. * @param r defines the red component to read from
  60418. * @param g defines the green component to read from
  60419. * @param b defines the blue component to read from
  60420. * @returns the current Color3 object
  60421. */
  60422. set(r: number, g: number, b: number): Color3;
  60423. /**
  60424. * Compute the Color3 hexadecimal code as a string
  60425. * @returns a string containing the hexadecimal representation of the Color3 object
  60426. */
  60427. toHexString(): string;
  60428. /**
  60429. * Computes a new Color3 converted from the current one to linear space
  60430. * @returns a new Color3 object
  60431. */
  60432. toLinearSpace(): Color3;
  60433. /**
  60434. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  60435. * @param convertedColor defines the Color3 object where to store the linear space version
  60436. * @returns the unmodified Color3
  60437. */
  60438. toLinearSpaceToRef(convertedColor: Color3): Color3;
  60439. /**
  60440. * Computes a new Color3 converted from the current one to gamma space
  60441. * @returns a new Color3 object
  60442. */
  60443. toGammaSpace(): Color3;
  60444. /**
  60445. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  60446. * @param convertedColor defines the Color3 object where to store the gamma space version
  60447. * @returns the unmodified Color3
  60448. */
  60449. toGammaSpaceToRef(convertedColor: Color3): Color3;
  60450. private static _BlackReadOnly;
  60451. /**
  60452. * Creates a new Color3 from the string containing valid hexadecimal values
  60453. * @param hex defines a string containing valid hexadecimal values
  60454. * @returns a new Color3 object
  60455. */
  60456. static FromHexString(hex: string): Color3;
  60457. /**
  60458. * Creates a new Color3 from the starting index of the given array
  60459. * @param array defines the source array
  60460. * @param offset defines an offset in the source array
  60461. * @returns a new Color3 object
  60462. */
  60463. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  60464. /**
  60465. * Creates a new Color3 from integer values (< 256)
  60466. * @param r defines the red component to read from (value between 0 and 255)
  60467. * @param g defines the green component to read from (value between 0 and 255)
  60468. * @param b defines the blue component to read from (value between 0 and 255)
  60469. * @returns a new Color3 object
  60470. */
  60471. static FromInts(r: number, g: number, b: number): Color3;
  60472. /**
  60473. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  60474. * @param start defines the start Color3 value
  60475. * @param end defines the end Color3 value
  60476. * @param amount defines the gradient value between start and end
  60477. * @returns a new Color3 object
  60478. */
  60479. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  60480. /**
  60481. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  60482. * @param left defines the start value
  60483. * @param right defines the end value
  60484. * @param amount defines the gradient factor
  60485. * @param result defines the Color3 object where to store the result
  60486. */
  60487. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  60488. /**
  60489. * Returns a Color3 value containing a red color
  60490. * @returns a new Color3 object
  60491. */
  60492. static Red(): Color3;
  60493. /**
  60494. * Returns a Color3 value containing a green color
  60495. * @returns a new Color3 object
  60496. */
  60497. static Green(): Color3;
  60498. /**
  60499. * Returns a Color3 value containing a blue color
  60500. * @returns a new Color3 object
  60501. */
  60502. static Blue(): Color3;
  60503. /**
  60504. * Returns a Color3 value containing a black color
  60505. * @returns a new Color3 object
  60506. */
  60507. static Black(): Color3;
  60508. /**
  60509. * Gets a Color3 value containing a black color that must not be updated
  60510. */
  60511. static readonly BlackReadOnly: DeepImmutable<Color3>;
  60512. /**
  60513. * Returns a Color3 value containing a white color
  60514. * @returns a new Color3 object
  60515. */
  60516. static White(): Color3;
  60517. /**
  60518. * Returns a Color3 value containing a purple color
  60519. * @returns a new Color3 object
  60520. */
  60521. static Purple(): Color3;
  60522. /**
  60523. * Returns a Color3 value containing a magenta color
  60524. * @returns a new Color3 object
  60525. */
  60526. static Magenta(): Color3;
  60527. /**
  60528. * Returns a Color3 value containing a yellow color
  60529. * @returns a new Color3 object
  60530. */
  60531. static Yellow(): Color3;
  60532. /**
  60533. * Returns a Color3 value containing a gray color
  60534. * @returns a new Color3 object
  60535. */
  60536. static Gray(): Color3;
  60537. /**
  60538. * Returns a Color3 value containing a teal color
  60539. * @returns a new Color3 object
  60540. */
  60541. static Teal(): Color3;
  60542. /**
  60543. * Returns a Color3 value containing a random color
  60544. * @returns a new Color3 object
  60545. */
  60546. static Random(): Color3;
  60547. }
  60548. /**
  60549. * Class used to hold a RBGA color
  60550. */
  60551. export class Color4 {
  60552. /**
  60553. * Defines the red component (between 0 and 1, default is 0)
  60554. */
  60555. r: number;
  60556. /**
  60557. * Defines the green component (between 0 and 1, default is 0)
  60558. */
  60559. g: number;
  60560. /**
  60561. * Defines the blue component (between 0 and 1, default is 0)
  60562. */
  60563. b: number;
  60564. /**
  60565. * Defines the alpha component (between 0 and 1, default is 1)
  60566. */
  60567. a: number;
  60568. /**
  60569. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  60570. * @param r defines the red component (between 0 and 1, default is 0)
  60571. * @param g defines the green component (between 0 and 1, default is 0)
  60572. * @param b defines the blue component (between 0 and 1, default is 0)
  60573. * @param a defines the alpha component (between 0 and 1, default is 1)
  60574. */
  60575. constructor(
  60576. /**
  60577. * Defines the red component (between 0 and 1, default is 0)
  60578. */
  60579. r?: number,
  60580. /**
  60581. * Defines the green component (between 0 and 1, default is 0)
  60582. */
  60583. g?: number,
  60584. /**
  60585. * Defines the blue component (between 0 and 1, default is 0)
  60586. */
  60587. b?: number,
  60588. /**
  60589. * Defines the alpha component (between 0 and 1, default is 1)
  60590. */
  60591. a?: number);
  60592. /**
  60593. * Adds in place the given Color4 values to the current Color4 object
  60594. * @param right defines the second operand
  60595. * @returns the current updated Color4 object
  60596. */
  60597. addInPlace(right: DeepImmutable<Color4>): Color4;
  60598. /**
  60599. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  60600. * @returns the new array
  60601. */
  60602. asArray(): number[];
  60603. /**
  60604. * Stores from the starting index in the given array the Color4 successive values
  60605. * @param array defines the array where to store the r,g,b components
  60606. * @param index defines an optional index in the target array to define where to start storing values
  60607. * @returns the current Color4 object
  60608. */
  60609. toArray(array: number[], index?: number): Color4;
  60610. /**
  60611. * Determines equality between Color4 objects
  60612. * @param otherColor defines the second operand
  60613. * @returns true if the rgba values are equal to the given ones
  60614. */
  60615. equals(otherColor: DeepImmutable<Color4>): boolean;
  60616. /**
  60617. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  60618. * @param right defines the second operand
  60619. * @returns a new Color4 object
  60620. */
  60621. add(right: DeepImmutable<Color4>): Color4;
  60622. /**
  60623. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  60624. * @param right defines the second operand
  60625. * @returns a new Color4 object
  60626. */
  60627. subtract(right: DeepImmutable<Color4>): Color4;
  60628. /**
  60629. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  60630. * @param right defines the second operand
  60631. * @param result defines the Color4 object where to store the result
  60632. * @returns the current Color4 object
  60633. */
  60634. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  60635. /**
  60636. * Creates a new Color4 with the current Color4 values multiplied by scale
  60637. * @param scale defines the scaling factor to apply
  60638. * @returns a new Color4 object
  60639. */
  60640. scale(scale: number): Color4;
  60641. /**
  60642. * Multiplies the current Color4 values by scale and stores the result in "result"
  60643. * @param scale defines the scaling factor to apply
  60644. * @param result defines the Color4 object where to store the result
  60645. * @returns the current unmodified Color4
  60646. */
  60647. scaleToRef(scale: number, result: Color4): Color4;
  60648. /**
  60649. * Scale the current Color4 values by a factor and add the result to a given Color4
  60650. * @param scale defines the scale factor
  60651. * @param result defines the Color4 object where to store the result
  60652. * @returns the unmodified current Color4
  60653. */
  60654. scaleAndAddToRef(scale: number, result: Color4): Color4;
  60655. /**
  60656. * Clamps the rgb values by the min and max values and stores the result into "result"
  60657. * @param min defines minimum clamping value (default is 0)
  60658. * @param max defines maximum clamping value (default is 1)
  60659. * @param result defines color to store the result into.
  60660. * @returns the cuurent Color4
  60661. */
  60662. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  60663. /**
  60664. * Multipy an Color4 value by another and return a new Color4 object
  60665. * @param color defines the Color4 value to multiply by
  60666. * @returns a new Color4 object
  60667. */
  60668. multiply(color: Color4): Color4;
  60669. /**
  60670. * Multipy a Color4 value by another and push the result in a reference value
  60671. * @param color defines the Color4 value to multiply by
  60672. * @param result defines the Color4 to fill the result in
  60673. * @returns the result Color4
  60674. */
  60675. multiplyToRef(color: Color4, result: Color4): Color4;
  60676. /**
  60677. * Creates a string with the Color4 current values
  60678. * @returns the string representation of the Color4 object
  60679. */
  60680. toString(): string;
  60681. /**
  60682. * Returns the string "Color4"
  60683. * @returns "Color4"
  60684. */
  60685. getClassName(): string;
  60686. /**
  60687. * Compute the Color4 hash code
  60688. * @returns an unique number that can be used to hash Color4 objects
  60689. */
  60690. getHashCode(): number;
  60691. /**
  60692. * Creates a new Color4 copied from the current one
  60693. * @returns a new Color4 object
  60694. */
  60695. clone(): Color4;
  60696. /**
  60697. * Copies the given Color4 values into the current one
  60698. * @param source defines the source Color4 object
  60699. * @returns the current updated Color4 object
  60700. */
  60701. copyFrom(source: Color4): Color4;
  60702. /**
  60703. * Copies the given float values into the current one
  60704. * @param r defines the red component to read from
  60705. * @param g defines the green component to read from
  60706. * @param b defines the blue component to read from
  60707. * @param a defines the alpha component to read from
  60708. * @returns the current updated Color4 object
  60709. */
  60710. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  60711. /**
  60712. * Copies the given float values into the current one
  60713. * @param r defines the red component to read from
  60714. * @param g defines the green component to read from
  60715. * @param b defines the blue component to read from
  60716. * @param a defines the alpha component to read from
  60717. * @returns the current updated Color4 object
  60718. */
  60719. set(r: number, g: number, b: number, a: number): Color4;
  60720. /**
  60721. * Compute the Color4 hexadecimal code as a string
  60722. * @returns a string containing the hexadecimal representation of the Color4 object
  60723. */
  60724. toHexString(): string;
  60725. /**
  60726. * Computes a new Color4 converted from the current one to linear space
  60727. * @returns a new Color4 object
  60728. */
  60729. toLinearSpace(): Color4;
  60730. /**
  60731. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  60732. * @param convertedColor defines the Color4 object where to store the linear space version
  60733. * @returns the unmodified Color4
  60734. */
  60735. toLinearSpaceToRef(convertedColor: Color4): Color4;
  60736. /**
  60737. * Computes a new Color4 converted from the current one to gamma space
  60738. * @returns a new Color4 object
  60739. */
  60740. toGammaSpace(): Color4;
  60741. /**
  60742. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  60743. * @param convertedColor defines the Color4 object where to store the gamma space version
  60744. * @returns the unmodified Color4
  60745. */
  60746. toGammaSpaceToRef(convertedColor: Color4): Color4;
  60747. /**
  60748. * Creates a new Color4 from the string containing valid hexadecimal values
  60749. * @param hex defines a string containing valid hexadecimal values
  60750. * @returns a new Color4 object
  60751. */
  60752. static FromHexString(hex: string): Color4;
  60753. /**
  60754. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  60755. * @param left defines the start value
  60756. * @param right defines the end value
  60757. * @param amount defines the gradient factor
  60758. * @returns a new Color4 object
  60759. */
  60760. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  60761. /**
  60762. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  60763. * @param left defines the start value
  60764. * @param right defines the end value
  60765. * @param amount defines the gradient factor
  60766. * @param result defines the Color4 object where to store data
  60767. */
  60768. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  60769. /**
  60770. * Creates a new Color4 from a Color3 and an alpha value
  60771. * @param color3 defines the source Color3 to read from
  60772. * @param alpha defines the alpha component (1.0 by default)
  60773. * @returns a new Color4 object
  60774. */
  60775. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  60776. /**
  60777. * Creates a new Color4 from the starting index element of the given array
  60778. * @param array defines the source array to read from
  60779. * @param offset defines the offset in the source array
  60780. * @returns a new Color4 object
  60781. */
  60782. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  60783. /**
  60784. * Creates a new Color3 from integer values (< 256)
  60785. * @param r defines the red component to read from (value between 0 and 255)
  60786. * @param g defines the green component to read from (value between 0 and 255)
  60787. * @param b defines the blue component to read from (value between 0 and 255)
  60788. * @param a defines the alpha component to read from (value between 0 and 255)
  60789. * @returns a new Color3 object
  60790. */
  60791. static FromInts(r: number, g: number, b: number, a: number): Color4;
  60792. /**
  60793. * Check the content of a given array and convert it to an array containing RGBA data
  60794. * If the original array was already containing count * 4 values then it is returned directly
  60795. * @param colors defines the array to check
  60796. * @param count defines the number of RGBA data to expect
  60797. * @returns an array containing count * 4 values (RGBA)
  60798. */
  60799. static CheckColors4(colors: number[], count: number): number[];
  60800. }
  60801. /**
  60802. * Class representing a vector containing 2 coordinates
  60803. */
  60804. export class Vector2 {
  60805. /** defines the first coordinate */
  60806. x: number;
  60807. /** defines the second coordinate */
  60808. y: number;
  60809. /**
  60810. * Creates a new Vector2 from the given x and y coordinates
  60811. * @param x defines the first coordinate
  60812. * @param y defines the second coordinate
  60813. */
  60814. constructor(
  60815. /** defines the first coordinate */
  60816. x?: number,
  60817. /** defines the second coordinate */
  60818. y?: number);
  60819. /**
  60820. * Gets a string with the Vector2 coordinates
  60821. * @returns a string with the Vector2 coordinates
  60822. */
  60823. toString(): string;
  60824. /**
  60825. * Gets class name
  60826. * @returns the string "Vector2"
  60827. */
  60828. getClassName(): string;
  60829. /**
  60830. * Gets current vector hash code
  60831. * @returns the Vector2 hash code as a number
  60832. */
  60833. getHashCode(): number;
  60834. /**
  60835. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  60836. * @param array defines the source array
  60837. * @param index defines the offset in source array
  60838. * @returns the current Vector2
  60839. */
  60840. toArray(array: FloatArray, index?: number): Vector2;
  60841. /**
  60842. * Copy the current vector to an array
  60843. * @returns a new array with 2 elements: the Vector2 coordinates.
  60844. */
  60845. asArray(): number[];
  60846. /**
  60847. * Sets the Vector2 coordinates with the given Vector2 coordinates
  60848. * @param source defines the source Vector2
  60849. * @returns the current updated Vector2
  60850. */
  60851. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  60852. /**
  60853. * Sets the Vector2 coordinates with the given floats
  60854. * @param x defines the first coordinate
  60855. * @param y defines the second coordinate
  60856. * @returns the current updated Vector2
  60857. */
  60858. copyFromFloats(x: number, y: number): Vector2;
  60859. /**
  60860. * Sets the Vector2 coordinates with the given floats
  60861. * @param x defines the first coordinate
  60862. * @param y defines the second coordinate
  60863. * @returns the current updated Vector2
  60864. */
  60865. set(x: number, y: number): Vector2;
  60866. /**
  60867. * Add another vector with the current one
  60868. * @param otherVector defines the other vector
  60869. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  60870. */
  60871. add(otherVector: DeepImmutable<Vector2>): Vector2;
  60872. /**
  60873. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  60874. * @param otherVector defines the other vector
  60875. * @param result defines the target vector
  60876. * @returns the unmodified current Vector2
  60877. */
  60878. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  60879. /**
  60880. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  60881. * @param otherVector defines the other vector
  60882. * @returns the current updated Vector2
  60883. */
  60884. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  60885. /**
  60886. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  60887. * @param otherVector defines the other vector
  60888. * @returns a new Vector2
  60889. */
  60890. addVector3(otherVector: Vector3): Vector2;
  60891. /**
  60892. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  60893. * @param otherVector defines the other vector
  60894. * @returns a new Vector2
  60895. */
  60896. subtract(otherVector: Vector2): Vector2;
  60897. /**
  60898. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  60899. * @param otherVector defines the other vector
  60900. * @param result defines the target vector
  60901. * @returns the unmodified current Vector2
  60902. */
  60903. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  60904. /**
  60905. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  60906. * @param otherVector defines the other vector
  60907. * @returns the current updated Vector2
  60908. */
  60909. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  60910. /**
  60911. * Multiplies in place the current Vector2 coordinates by the given ones
  60912. * @param otherVector defines the other vector
  60913. * @returns the current updated Vector2
  60914. */
  60915. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  60916. /**
  60917. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  60918. * @param otherVector defines the other vector
  60919. * @returns a new Vector2
  60920. */
  60921. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  60922. /**
  60923. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  60924. * @param otherVector defines the other vector
  60925. * @param result defines the target vector
  60926. * @returns the unmodified current Vector2
  60927. */
  60928. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  60929. /**
  60930. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  60931. * @param x defines the first coordinate
  60932. * @param y defines the second coordinate
  60933. * @returns a new Vector2
  60934. */
  60935. multiplyByFloats(x: number, y: number): Vector2;
  60936. /**
  60937. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  60938. * @param otherVector defines the other vector
  60939. * @returns a new Vector2
  60940. */
  60941. divide(otherVector: Vector2): Vector2;
  60942. /**
  60943. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  60944. * @param otherVector defines the other vector
  60945. * @param result defines the target vector
  60946. * @returns the unmodified current Vector2
  60947. */
  60948. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  60949. /**
  60950. * Divides the current Vector2 coordinates by the given ones
  60951. * @param otherVector defines the other vector
  60952. * @returns the current updated Vector2
  60953. */
  60954. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  60955. /**
  60956. * Gets a new Vector2 with current Vector2 negated coordinates
  60957. * @returns a new Vector2
  60958. */
  60959. negate(): Vector2;
  60960. /**
  60961. * Multiply the Vector2 coordinates by scale
  60962. * @param scale defines the scaling factor
  60963. * @returns the current updated Vector2
  60964. */
  60965. scaleInPlace(scale: number): Vector2;
  60966. /**
  60967. * Returns a new Vector2 scaled by "scale" from the current Vector2
  60968. * @param scale defines the scaling factor
  60969. * @returns a new Vector2
  60970. */
  60971. scale(scale: number): Vector2;
  60972. /**
  60973. * Scale the current Vector2 values by a factor to a given Vector2
  60974. * @param scale defines the scale factor
  60975. * @param result defines the Vector2 object where to store the result
  60976. * @returns the unmodified current Vector2
  60977. */
  60978. scaleToRef(scale: number, result: Vector2): Vector2;
  60979. /**
  60980. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  60981. * @param scale defines the scale factor
  60982. * @param result defines the Vector2 object where to store the result
  60983. * @returns the unmodified current Vector2
  60984. */
  60985. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  60986. /**
  60987. * Gets a boolean if two vectors are equals
  60988. * @param otherVector defines the other vector
  60989. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  60990. */
  60991. equals(otherVector: DeepImmutable<Vector2>): boolean;
  60992. /**
  60993. * Gets a boolean if two vectors are equals (using an epsilon value)
  60994. * @param otherVector defines the other vector
  60995. * @param epsilon defines the minimal distance to consider equality
  60996. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  60997. */
  60998. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  60999. /**
  61000. * Gets a new Vector2 from current Vector2 floored values
  61001. * @returns a new Vector2
  61002. */
  61003. floor(): Vector2;
  61004. /**
  61005. * Gets a new Vector2 from current Vector2 floored values
  61006. * @returns a new Vector2
  61007. */
  61008. fract(): Vector2;
  61009. /**
  61010. * Gets the length of the vector
  61011. * @returns the vector length (float)
  61012. */
  61013. length(): number;
  61014. /**
  61015. * Gets the vector squared length
  61016. * @returns the vector squared length (float)
  61017. */
  61018. lengthSquared(): number;
  61019. /**
  61020. * Normalize the vector
  61021. * @returns the current updated Vector2
  61022. */
  61023. normalize(): Vector2;
  61024. /**
  61025. * Gets a new Vector2 copied from the Vector2
  61026. * @returns a new Vector2
  61027. */
  61028. clone(): Vector2;
  61029. /**
  61030. * Gets a new Vector2(0, 0)
  61031. * @returns a new Vector2
  61032. */
  61033. static Zero(): Vector2;
  61034. /**
  61035. * Gets a new Vector2(1, 1)
  61036. * @returns a new Vector2
  61037. */
  61038. static One(): Vector2;
  61039. /**
  61040. * Gets a new Vector2 set from the given index element of the given array
  61041. * @param array defines the data source
  61042. * @param offset defines the offset in the data source
  61043. * @returns a new Vector2
  61044. */
  61045. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  61046. /**
  61047. * Sets "result" from the given index element of the given array
  61048. * @param array defines the data source
  61049. * @param offset defines the offset in the data source
  61050. * @param result defines the target vector
  61051. */
  61052. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  61053. /**
  61054. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  61055. * @param value1 defines 1st point of control
  61056. * @param value2 defines 2nd point of control
  61057. * @param value3 defines 3rd point of control
  61058. * @param value4 defines 4th point of control
  61059. * @param amount defines the interpolation factor
  61060. * @returns a new Vector2
  61061. */
  61062. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  61063. /**
  61064. * 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".
  61065. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  61066. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  61067. * @param value defines the value to clamp
  61068. * @param min defines the lower limit
  61069. * @param max defines the upper limit
  61070. * @returns a new Vector2
  61071. */
  61072. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  61073. /**
  61074. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  61075. * @param value1 defines the 1st control point
  61076. * @param tangent1 defines the outgoing tangent
  61077. * @param value2 defines the 2nd control point
  61078. * @param tangent2 defines the incoming tangent
  61079. * @param amount defines the interpolation factor
  61080. * @returns a new Vector2
  61081. */
  61082. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  61083. /**
  61084. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  61085. * @param start defines the start vector
  61086. * @param end defines the end vector
  61087. * @param amount defines the interpolation factor
  61088. * @returns a new Vector2
  61089. */
  61090. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  61091. /**
  61092. * Gets the dot product of the vector "left" and the vector "right"
  61093. * @param left defines first vector
  61094. * @param right defines second vector
  61095. * @returns the dot product (float)
  61096. */
  61097. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  61098. /**
  61099. * Returns a new Vector2 equal to the normalized given vector
  61100. * @param vector defines the vector to normalize
  61101. * @returns a new Vector2
  61102. */
  61103. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  61104. /**
  61105. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  61106. * @param left defines 1st vector
  61107. * @param right defines 2nd vector
  61108. * @returns a new Vector2
  61109. */
  61110. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  61111. /**
  61112. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  61113. * @param left defines 1st vector
  61114. * @param right defines 2nd vector
  61115. * @returns a new Vector2
  61116. */
  61117. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  61118. /**
  61119. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  61120. * @param vector defines the vector to transform
  61121. * @param transformation defines the matrix to apply
  61122. * @returns a new Vector2
  61123. */
  61124. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  61125. /**
  61126. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  61127. * @param vector defines the vector to transform
  61128. * @param transformation defines the matrix to apply
  61129. * @param result defines the target vector
  61130. */
  61131. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  61132. /**
  61133. * Determines if a given vector is included in a triangle
  61134. * @param p defines the vector to test
  61135. * @param p0 defines 1st triangle point
  61136. * @param p1 defines 2nd triangle point
  61137. * @param p2 defines 3rd triangle point
  61138. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  61139. */
  61140. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  61141. /**
  61142. * Gets the distance between the vectors "value1" and "value2"
  61143. * @param value1 defines first vector
  61144. * @param value2 defines second vector
  61145. * @returns the distance between vectors
  61146. */
  61147. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  61148. /**
  61149. * Returns the squared distance between the vectors "value1" and "value2"
  61150. * @param value1 defines first vector
  61151. * @param value2 defines second vector
  61152. * @returns the squared distance between vectors
  61153. */
  61154. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  61155. /**
  61156. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  61157. * @param value1 defines first vector
  61158. * @param value2 defines second vector
  61159. * @returns a new Vector2
  61160. */
  61161. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  61162. /**
  61163. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  61164. * @param p defines the middle point
  61165. * @param segA defines one point of the segment
  61166. * @param segB defines the other point of the segment
  61167. * @returns the shortest distance
  61168. */
  61169. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  61170. }
  61171. /**
  61172. * Classed used to store (x,y,z) vector representation
  61173. * A Vector3 is the main object used in 3D geometry
  61174. * It can represent etiher the coordinates of a point the space, either a direction
  61175. * Reminder: js uses a left handed forward facing system
  61176. */
  61177. export class Vector3 {
  61178. /**
  61179. * Defines the first coordinates (on X axis)
  61180. */
  61181. x: number;
  61182. /**
  61183. * Defines the second coordinates (on Y axis)
  61184. */
  61185. y: number;
  61186. /**
  61187. * Defines the third coordinates (on Z axis)
  61188. */
  61189. z: number;
  61190. private static _UpReadOnly;
  61191. /**
  61192. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  61193. * @param x defines the first coordinates (on X axis)
  61194. * @param y defines the second coordinates (on Y axis)
  61195. * @param z defines the third coordinates (on Z axis)
  61196. */
  61197. constructor(
  61198. /**
  61199. * Defines the first coordinates (on X axis)
  61200. */
  61201. x?: number,
  61202. /**
  61203. * Defines the second coordinates (on Y axis)
  61204. */
  61205. y?: number,
  61206. /**
  61207. * Defines the third coordinates (on Z axis)
  61208. */
  61209. z?: number);
  61210. /**
  61211. * Creates a string representation of the Vector3
  61212. * @returns a string with the Vector3 coordinates.
  61213. */
  61214. toString(): string;
  61215. /**
  61216. * Gets the class name
  61217. * @returns the string "Vector3"
  61218. */
  61219. getClassName(): string;
  61220. /**
  61221. * Creates the Vector3 hash code
  61222. * @returns a number which tends to be unique between Vector3 instances
  61223. */
  61224. getHashCode(): number;
  61225. /**
  61226. * Creates an array containing three elements : the coordinates of the Vector3
  61227. * @returns a new array of numbers
  61228. */
  61229. asArray(): number[];
  61230. /**
  61231. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  61232. * @param array defines the destination array
  61233. * @param index defines the offset in the destination array
  61234. * @returns the current Vector3
  61235. */
  61236. toArray(array: FloatArray, index?: number): Vector3;
  61237. /**
  61238. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  61239. * @returns a new Quaternion object, computed from the Vector3 coordinates
  61240. */
  61241. toQuaternion(): Quaternion;
  61242. /**
  61243. * Adds the given vector to the current Vector3
  61244. * @param otherVector defines the second operand
  61245. * @returns the current updated Vector3
  61246. */
  61247. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  61248. /**
  61249. * Adds the given coordinates to the current Vector3
  61250. * @param x defines the x coordinate of the operand
  61251. * @param y defines the y coordinate of the operand
  61252. * @param z defines the z coordinate of the operand
  61253. * @returns the current updated Vector3
  61254. */
  61255. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  61256. /**
  61257. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  61258. * @param otherVector defines the second operand
  61259. * @returns the resulting Vector3
  61260. */
  61261. add(otherVector: DeepImmutable<Vector3>): Vector3;
  61262. /**
  61263. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  61264. * @param otherVector defines the second operand
  61265. * @param result defines the Vector3 object where to store the result
  61266. * @returns the current Vector3
  61267. */
  61268. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  61269. /**
  61270. * Subtract the given vector from the current Vector3
  61271. * @param otherVector defines the second operand
  61272. * @returns the current updated Vector3
  61273. */
  61274. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  61275. /**
  61276. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  61277. * @param otherVector defines the second operand
  61278. * @returns the resulting Vector3
  61279. */
  61280. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  61281. /**
  61282. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  61283. * @param otherVector defines the second operand
  61284. * @param result defines the Vector3 object where to store the result
  61285. * @returns the current Vector3
  61286. */
  61287. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  61288. /**
  61289. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  61290. * @param x defines the x coordinate of the operand
  61291. * @param y defines the y coordinate of the operand
  61292. * @param z defines the z coordinate of the operand
  61293. * @returns the resulting Vector3
  61294. */
  61295. subtractFromFloats(x: number, y: number, z: number): Vector3;
  61296. /**
  61297. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  61298. * @param x defines the x coordinate of the operand
  61299. * @param y defines the y coordinate of the operand
  61300. * @param z defines the z coordinate of the operand
  61301. * @param result defines the Vector3 object where to store the result
  61302. * @returns the current Vector3
  61303. */
  61304. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  61305. /**
  61306. * Gets a new Vector3 set with the current Vector3 negated coordinates
  61307. * @returns a new Vector3
  61308. */
  61309. negate(): Vector3;
  61310. /**
  61311. * Multiplies the Vector3 coordinates by the float "scale"
  61312. * @param scale defines the multiplier factor
  61313. * @returns the current updated Vector3
  61314. */
  61315. scaleInPlace(scale: number): Vector3;
  61316. /**
  61317. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  61318. * @param scale defines the multiplier factor
  61319. * @returns a new Vector3
  61320. */
  61321. scale(scale: number): Vector3;
  61322. /**
  61323. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  61324. * @param scale defines the multiplier factor
  61325. * @param result defines the Vector3 object where to store the result
  61326. * @returns the current Vector3
  61327. */
  61328. scaleToRef(scale: number, result: Vector3): Vector3;
  61329. /**
  61330. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  61331. * @param scale defines the scale factor
  61332. * @param result defines the Vector3 object where to store the result
  61333. * @returns the unmodified current Vector3
  61334. */
  61335. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  61336. /**
  61337. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  61338. * @param otherVector defines the second operand
  61339. * @returns true if both vectors are equals
  61340. */
  61341. equals(otherVector: DeepImmutable<Vector3>): boolean;
  61342. /**
  61343. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  61344. * @param otherVector defines the second operand
  61345. * @param epsilon defines the minimal distance to define values as equals
  61346. * @returns true if both vectors are distant less than epsilon
  61347. */
  61348. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  61349. /**
  61350. * Returns true if the current Vector3 coordinates equals the given floats
  61351. * @param x defines the x coordinate of the operand
  61352. * @param y defines the y coordinate of the operand
  61353. * @param z defines the z coordinate of the operand
  61354. * @returns true if both vectors are equals
  61355. */
  61356. equalsToFloats(x: number, y: number, z: number): boolean;
  61357. /**
  61358. * Multiplies the current Vector3 coordinates by the given ones
  61359. * @param otherVector defines the second operand
  61360. * @returns the current updated Vector3
  61361. */
  61362. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  61363. /**
  61364. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  61365. * @param otherVector defines the second operand
  61366. * @returns the new Vector3
  61367. */
  61368. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  61369. /**
  61370. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  61371. * @param otherVector defines the second operand
  61372. * @param result defines the Vector3 object where to store the result
  61373. * @returns the current Vector3
  61374. */
  61375. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  61376. /**
  61377. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  61378. * @param x defines the x coordinate of the operand
  61379. * @param y defines the y coordinate of the operand
  61380. * @param z defines the z coordinate of the operand
  61381. * @returns the new Vector3
  61382. */
  61383. multiplyByFloats(x: number, y: number, z: number): Vector3;
  61384. /**
  61385. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  61386. * @param otherVector defines the second operand
  61387. * @returns the new Vector3
  61388. */
  61389. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  61390. /**
  61391. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  61392. * @param otherVector defines the second operand
  61393. * @param result defines the Vector3 object where to store the result
  61394. * @returns the current Vector3
  61395. */
  61396. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  61397. /**
  61398. * Divides the current Vector3 coordinates by the given ones.
  61399. * @param otherVector defines the second operand
  61400. * @returns the current updated Vector3
  61401. */
  61402. divideInPlace(otherVector: Vector3): Vector3;
  61403. /**
  61404. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  61405. * @param other defines the second operand
  61406. * @returns the current updated Vector3
  61407. */
  61408. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  61409. /**
  61410. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  61411. * @param other defines the second operand
  61412. * @returns the current updated Vector3
  61413. */
  61414. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  61415. /**
  61416. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  61417. * @param x defines the x coordinate of the operand
  61418. * @param y defines the y coordinate of the operand
  61419. * @param z defines the z coordinate of the operand
  61420. * @returns the current updated Vector3
  61421. */
  61422. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  61423. /**
  61424. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  61425. * @param x defines the x coordinate of the operand
  61426. * @param y defines the y coordinate of the operand
  61427. * @param z defines the z coordinate of the operand
  61428. * @returns the current updated Vector3
  61429. */
  61430. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  61431. /**
  61432. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  61433. * Check if is non uniform within a certain amount of decimal places to account for this
  61434. * @param epsilon the amount the values can differ
  61435. * @returns if the the vector is non uniform to a certain number of decimal places
  61436. */
  61437. isNonUniformWithinEpsilon(epsilon: number): boolean;
  61438. /**
  61439. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  61440. */
  61441. readonly isNonUniform: boolean;
  61442. /**
  61443. * Gets a new Vector3 from current Vector3 floored values
  61444. * @returns a new Vector3
  61445. */
  61446. floor(): Vector3;
  61447. /**
  61448. * Gets a new Vector3 from current Vector3 floored values
  61449. * @returns a new Vector3
  61450. */
  61451. fract(): Vector3;
  61452. /**
  61453. * Gets the length of the Vector3
  61454. * @returns the length of the Vecto3
  61455. */
  61456. length(): number;
  61457. /**
  61458. * Gets the squared length of the Vector3
  61459. * @returns squared length of the Vector3
  61460. */
  61461. lengthSquared(): number;
  61462. /**
  61463. * Normalize the current Vector3.
  61464. * Please note that this is an in place operation.
  61465. * @returns the current updated Vector3
  61466. */
  61467. normalize(): Vector3;
  61468. /**
  61469. * Reorders the x y z properties of the vector in place
  61470. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  61471. * @returns the current updated vector
  61472. */
  61473. reorderInPlace(order: string): this;
  61474. /**
  61475. * Rotates the vector around 0,0,0 by a quaternion
  61476. * @param quaternion the rotation quaternion
  61477. * @param result vector to store the result
  61478. * @returns the resulting vector
  61479. */
  61480. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  61481. /**
  61482. * Rotates a vector around a given point
  61483. * @param quaternion the rotation quaternion
  61484. * @param point the point to rotate around
  61485. * @param result vector to store the result
  61486. * @returns the resulting vector
  61487. */
  61488. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  61489. /**
  61490. * Normalize the current Vector3 with the given input length.
  61491. * Please note that this is an in place operation.
  61492. * @param len the length of the vector
  61493. * @returns the current updated Vector3
  61494. */
  61495. normalizeFromLength(len: number): Vector3;
  61496. /**
  61497. * Normalize the current Vector3 to a new vector
  61498. * @returns the new Vector3
  61499. */
  61500. normalizeToNew(): Vector3;
  61501. /**
  61502. * Normalize the current Vector3 to the reference
  61503. * @param reference define the Vector3 to update
  61504. * @returns the updated Vector3
  61505. */
  61506. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  61507. /**
  61508. * Creates a new Vector3 copied from the current Vector3
  61509. * @returns the new Vector3
  61510. */
  61511. clone(): Vector3;
  61512. /**
  61513. * Copies the given vector coordinates to the current Vector3 ones
  61514. * @param source defines the source Vector3
  61515. * @returns the current updated Vector3
  61516. */
  61517. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  61518. /**
  61519. * Copies the given floats to the current Vector3 coordinates
  61520. * @param x defines the x coordinate of the operand
  61521. * @param y defines the y coordinate of the operand
  61522. * @param z defines the z coordinate of the operand
  61523. * @returns the current updated Vector3
  61524. */
  61525. copyFromFloats(x: number, y: number, z: number): Vector3;
  61526. /**
  61527. * Copies the given floats to the current Vector3 coordinates
  61528. * @param x defines the x coordinate of the operand
  61529. * @param y defines the y coordinate of the operand
  61530. * @param z defines the z coordinate of the operand
  61531. * @returns the current updated Vector3
  61532. */
  61533. set(x: number, y: number, z: number): Vector3;
  61534. /**
  61535. * Copies the given float to the current Vector3 coordinates
  61536. * @param v defines the x, y and z coordinates of the operand
  61537. * @returns the current updated Vector3
  61538. */
  61539. setAll(v: number): Vector3;
  61540. /**
  61541. * Get the clip factor between two vectors
  61542. * @param vector0 defines the first operand
  61543. * @param vector1 defines the second operand
  61544. * @param axis defines the axis to use
  61545. * @param size defines the size along the axis
  61546. * @returns the clip factor
  61547. */
  61548. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  61549. /**
  61550. * Get angle between two vectors
  61551. * @param vector0 angle between vector0 and vector1
  61552. * @param vector1 angle between vector0 and vector1
  61553. * @param normal direction of the normal
  61554. * @return the angle between vector0 and vector1
  61555. */
  61556. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  61557. /**
  61558. * Returns a new Vector3 set from the index "offset" of the given array
  61559. * @param array defines the source array
  61560. * @param offset defines the offset in the source array
  61561. * @returns the new Vector3
  61562. */
  61563. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  61564. /**
  61565. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  61566. * This function is deprecated. Use FromArray instead
  61567. * @param array defines the source array
  61568. * @param offset defines the offset in the source array
  61569. * @returns the new Vector3
  61570. */
  61571. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  61572. /**
  61573. * Sets the given vector "result" with the element values from the index "offset" of the given array
  61574. * @param array defines the source array
  61575. * @param offset defines the offset in the source array
  61576. * @param result defines the Vector3 where to store the result
  61577. */
  61578. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  61579. /**
  61580. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  61581. * This function is deprecated. Use FromArrayToRef instead.
  61582. * @param array defines the source array
  61583. * @param offset defines the offset in the source array
  61584. * @param result defines the Vector3 where to store the result
  61585. */
  61586. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  61587. /**
  61588. * Sets the given vector "result" with the given floats.
  61589. * @param x defines the x coordinate of the source
  61590. * @param y defines the y coordinate of the source
  61591. * @param z defines the z coordinate of the source
  61592. * @param result defines the Vector3 where to store the result
  61593. */
  61594. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  61595. /**
  61596. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  61597. * @returns a new empty Vector3
  61598. */
  61599. static Zero(): Vector3;
  61600. /**
  61601. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  61602. * @returns a new unit Vector3
  61603. */
  61604. static One(): Vector3;
  61605. /**
  61606. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  61607. * @returns a new up Vector3
  61608. */
  61609. static Up(): Vector3;
  61610. /**
  61611. * Gets a up Vector3 that must not be updated
  61612. */
  61613. static readonly UpReadOnly: DeepImmutable<Vector3>;
  61614. /**
  61615. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  61616. * @returns a new down Vector3
  61617. */
  61618. static Down(): Vector3;
  61619. /**
  61620. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  61621. * @returns a new forward Vector3
  61622. */
  61623. static Forward(): Vector3;
  61624. /**
  61625. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  61626. * @returns a new forward Vector3
  61627. */
  61628. static Backward(): Vector3;
  61629. /**
  61630. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  61631. * @returns a new right Vector3
  61632. */
  61633. static Right(): Vector3;
  61634. /**
  61635. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  61636. * @returns a new left Vector3
  61637. */
  61638. static Left(): Vector3;
  61639. /**
  61640. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  61641. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  61642. * @param vector defines the Vector3 to transform
  61643. * @param transformation defines the transformation matrix
  61644. * @returns the transformed Vector3
  61645. */
  61646. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  61647. /**
  61648. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  61649. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  61650. * @param vector defines the Vector3 to transform
  61651. * @param transformation defines the transformation matrix
  61652. * @param result defines the Vector3 where to store the result
  61653. */
  61654. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  61655. /**
  61656. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  61657. * This method computes tranformed coordinates only, not transformed direction vectors
  61658. * @param x define the x coordinate of the source vector
  61659. * @param y define the y coordinate of the source vector
  61660. * @param z define the z coordinate of the source vector
  61661. * @param transformation defines the transformation matrix
  61662. * @param result defines the Vector3 where to store the result
  61663. */
  61664. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  61665. /**
  61666. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  61667. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  61668. * @param vector defines the Vector3 to transform
  61669. * @param transformation defines the transformation matrix
  61670. * @returns the new Vector3
  61671. */
  61672. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  61673. /**
  61674. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  61675. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  61676. * @param vector defines the Vector3 to transform
  61677. * @param transformation defines the transformation matrix
  61678. * @param result defines the Vector3 where to store the result
  61679. */
  61680. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  61681. /**
  61682. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  61683. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  61684. * @param x define the x coordinate of the source vector
  61685. * @param y define the y coordinate of the source vector
  61686. * @param z define the z coordinate of the source vector
  61687. * @param transformation defines the transformation matrix
  61688. * @param result defines the Vector3 where to store the result
  61689. */
  61690. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  61691. /**
  61692. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  61693. * @param value1 defines the first control point
  61694. * @param value2 defines the second control point
  61695. * @param value3 defines the third control point
  61696. * @param value4 defines the fourth control point
  61697. * @param amount defines the amount on the spline to use
  61698. * @returns the new Vector3
  61699. */
  61700. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  61701. /**
  61702. * 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"
  61703. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  61704. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  61705. * @param value defines the current value
  61706. * @param min defines the lower range value
  61707. * @param max defines the upper range value
  61708. * @returns the new Vector3
  61709. */
  61710. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  61711. /**
  61712. * 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"
  61713. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  61714. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  61715. * @param value defines the current value
  61716. * @param min defines the lower range value
  61717. * @param max defines the upper range value
  61718. * @param result defines the Vector3 where to store the result
  61719. */
  61720. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  61721. /**
  61722. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  61723. * @param value1 defines the first control point
  61724. * @param tangent1 defines the first tangent vector
  61725. * @param value2 defines the second control point
  61726. * @param tangent2 defines the second tangent vector
  61727. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  61728. * @returns the new Vector3
  61729. */
  61730. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  61731. /**
  61732. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  61733. * @param start defines the start value
  61734. * @param end defines the end value
  61735. * @param amount max defines amount between both (between 0 and 1)
  61736. * @returns the new Vector3
  61737. */
  61738. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  61739. /**
  61740. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  61741. * @param start defines the start value
  61742. * @param end defines the end value
  61743. * @param amount max defines amount between both (between 0 and 1)
  61744. * @param result defines the Vector3 where to store the result
  61745. */
  61746. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  61747. /**
  61748. * Returns the dot product (float) between the vectors "left" and "right"
  61749. * @param left defines the left operand
  61750. * @param right defines the right operand
  61751. * @returns the dot product
  61752. */
  61753. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  61754. /**
  61755. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  61756. * The cross product is then orthogonal to both "left" and "right"
  61757. * @param left defines the left operand
  61758. * @param right defines the right operand
  61759. * @returns the cross product
  61760. */
  61761. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  61762. /**
  61763. * Sets the given vector "result" with the cross product of "left" and "right"
  61764. * The cross product is then orthogonal to both "left" and "right"
  61765. * @param left defines the left operand
  61766. * @param right defines the right operand
  61767. * @param result defines the Vector3 where to store the result
  61768. */
  61769. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  61770. /**
  61771. * Returns a new Vector3 as the normalization of the given vector
  61772. * @param vector defines the Vector3 to normalize
  61773. * @returns the new Vector3
  61774. */
  61775. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  61776. /**
  61777. * Sets the given vector "result" with the normalization of the given first vector
  61778. * @param vector defines the Vector3 to normalize
  61779. * @param result defines the Vector3 where to store the result
  61780. */
  61781. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  61782. /**
  61783. * Project a Vector3 onto screen space
  61784. * @param vector defines the Vector3 to project
  61785. * @param world defines the world matrix to use
  61786. * @param transform defines the transform (view x projection) matrix to use
  61787. * @param viewport defines the screen viewport to use
  61788. * @returns the new Vector3
  61789. */
  61790. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  61791. /** @hidden */
  61792. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  61793. /**
  61794. * Unproject from screen space to object space
  61795. * @param source defines the screen space Vector3 to use
  61796. * @param viewportWidth defines the current width of the viewport
  61797. * @param viewportHeight defines the current height of the viewport
  61798. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  61799. * @param transform defines the transform (view x projection) matrix to use
  61800. * @returns the new Vector3
  61801. */
  61802. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  61803. /**
  61804. * Unproject from screen space to object space
  61805. * @param source defines the screen space Vector3 to use
  61806. * @param viewportWidth defines the current width of the viewport
  61807. * @param viewportHeight defines the current height of the viewport
  61808. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  61809. * @param view defines the view matrix to use
  61810. * @param projection defines the projection matrix to use
  61811. * @returns the new Vector3
  61812. */
  61813. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  61814. /**
  61815. * Unproject from screen space to object space
  61816. * @param source defines the screen space Vector3 to use
  61817. * @param viewportWidth defines the current width of the viewport
  61818. * @param viewportHeight defines the current height of the viewport
  61819. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  61820. * @param view defines the view matrix to use
  61821. * @param projection defines the projection matrix to use
  61822. * @param result defines the Vector3 where to store the result
  61823. */
  61824. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  61825. /**
  61826. * Unproject from screen space to object space
  61827. * @param sourceX defines the screen space x coordinate to use
  61828. * @param sourceY defines the screen space y coordinate to use
  61829. * @param sourceZ defines the screen space z coordinate to use
  61830. * @param viewportWidth defines the current width of the viewport
  61831. * @param viewportHeight defines the current height of the viewport
  61832. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  61833. * @param view defines the view matrix to use
  61834. * @param projection defines the projection matrix to use
  61835. * @param result defines the Vector3 where to store the result
  61836. */
  61837. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  61838. /**
  61839. * Gets the minimal coordinate values between two Vector3
  61840. * @param left defines the first operand
  61841. * @param right defines the second operand
  61842. * @returns the new Vector3
  61843. */
  61844. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  61845. /**
  61846. * Gets the maximal coordinate values between two Vector3
  61847. * @param left defines the first operand
  61848. * @param right defines the second operand
  61849. * @returns the new Vector3
  61850. */
  61851. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  61852. /**
  61853. * Returns the distance between the vectors "value1" and "value2"
  61854. * @param value1 defines the first operand
  61855. * @param value2 defines the second operand
  61856. * @returns the distance
  61857. */
  61858. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  61859. /**
  61860. * Returns the squared distance between the vectors "value1" and "value2"
  61861. * @param value1 defines the first operand
  61862. * @param value2 defines the second operand
  61863. * @returns the squared distance
  61864. */
  61865. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  61866. /**
  61867. * Returns a new Vector3 located at the center between "value1" and "value2"
  61868. * @param value1 defines the first operand
  61869. * @param value2 defines the second operand
  61870. * @returns the new Vector3
  61871. */
  61872. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  61873. /**
  61874. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  61875. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  61876. * to something in order to rotate it from its local system to the given target system
  61877. * Note: axis1, axis2 and axis3 are normalized during this operation
  61878. * @param axis1 defines the first axis
  61879. * @param axis2 defines the second axis
  61880. * @param axis3 defines the third axis
  61881. * @returns a new Vector3
  61882. */
  61883. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  61884. /**
  61885. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  61886. * @param axis1 defines the first axis
  61887. * @param axis2 defines the second axis
  61888. * @param axis3 defines the third axis
  61889. * @param ref defines the Vector3 where to store the result
  61890. */
  61891. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  61892. }
  61893. /**
  61894. * Vector4 class created for EulerAngle class conversion to Quaternion
  61895. */
  61896. export class Vector4 {
  61897. /** x value of the vector */
  61898. x: number;
  61899. /** y value of the vector */
  61900. y: number;
  61901. /** z value of the vector */
  61902. z: number;
  61903. /** w value of the vector */
  61904. w: number;
  61905. /**
  61906. * Creates a Vector4 object from the given floats.
  61907. * @param x x value of the vector
  61908. * @param y y value of the vector
  61909. * @param z z value of the vector
  61910. * @param w w value of the vector
  61911. */
  61912. constructor(
  61913. /** x value of the vector */
  61914. x: number,
  61915. /** y value of the vector */
  61916. y: number,
  61917. /** z value of the vector */
  61918. z: number,
  61919. /** w value of the vector */
  61920. w: number);
  61921. /**
  61922. * Returns the string with the Vector4 coordinates.
  61923. * @returns a string containing all the vector values
  61924. */
  61925. toString(): string;
  61926. /**
  61927. * Returns the string "Vector4".
  61928. * @returns "Vector4"
  61929. */
  61930. getClassName(): string;
  61931. /**
  61932. * Returns the Vector4 hash code.
  61933. * @returns a unique hash code
  61934. */
  61935. getHashCode(): number;
  61936. /**
  61937. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  61938. * @returns the resulting array
  61939. */
  61940. asArray(): number[];
  61941. /**
  61942. * Populates the given array from the given index with the Vector4 coordinates.
  61943. * @param array array to populate
  61944. * @param index index of the array to start at (default: 0)
  61945. * @returns the Vector4.
  61946. */
  61947. toArray(array: FloatArray, index?: number): Vector4;
  61948. /**
  61949. * Adds the given vector to the current Vector4.
  61950. * @param otherVector the vector to add
  61951. * @returns the updated Vector4.
  61952. */
  61953. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  61954. /**
  61955. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  61956. * @param otherVector the vector to add
  61957. * @returns the resulting vector
  61958. */
  61959. add(otherVector: DeepImmutable<Vector4>): Vector4;
  61960. /**
  61961. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  61962. * @param otherVector the vector to add
  61963. * @param result the vector to store the result
  61964. * @returns the current Vector4.
  61965. */
  61966. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  61967. /**
  61968. * Subtract in place the given vector from the current Vector4.
  61969. * @param otherVector the vector to subtract
  61970. * @returns the updated Vector4.
  61971. */
  61972. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  61973. /**
  61974. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  61975. * @param otherVector the vector to add
  61976. * @returns the new vector with the result
  61977. */
  61978. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  61979. /**
  61980. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  61981. * @param otherVector the vector to subtract
  61982. * @param result the vector to store the result
  61983. * @returns the current Vector4.
  61984. */
  61985. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  61986. /**
  61987. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  61988. */
  61989. /**
  61990. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  61991. * @param x value to subtract
  61992. * @param y value to subtract
  61993. * @param z value to subtract
  61994. * @param w value to subtract
  61995. * @returns new vector containing the result
  61996. */
  61997. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  61998. /**
  61999. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  62000. * @param x value to subtract
  62001. * @param y value to subtract
  62002. * @param z value to subtract
  62003. * @param w value to subtract
  62004. * @param result the vector to store the result in
  62005. * @returns the current Vector4.
  62006. */
  62007. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  62008. /**
  62009. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  62010. * @returns a new vector with the negated values
  62011. */
  62012. negate(): Vector4;
  62013. /**
  62014. * Multiplies the current Vector4 coordinates by scale (float).
  62015. * @param scale the number to scale with
  62016. * @returns the updated Vector4.
  62017. */
  62018. scaleInPlace(scale: number): Vector4;
  62019. /**
  62020. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  62021. * @param scale the number to scale with
  62022. * @returns a new vector with the result
  62023. */
  62024. scale(scale: number): Vector4;
  62025. /**
  62026. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  62027. * @param scale the number to scale with
  62028. * @param result a vector to store the result in
  62029. * @returns the current Vector4.
  62030. */
  62031. scaleToRef(scale: number, result: Vector4): Vector4;
  62032. /**
  62033. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  62034. * @param scale defines the scale factor
  62035. * @param result defines the Vector4 object where to store the result
  62036. * @returns the unmodified current Vector4
  62037. */
  62038. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  62039. /**
  62040. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  62041. * @param otherVector the vector to compare against
  62042. * @returns true if they are equal
  62043. */
  62044. equals(otherVector: DeepImmutable<Vector4>): boolean;
  62045. /**
  62046. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  62047. * @param otherVector vector to compare against
  62048. * @param epsilon (Default: very small number)
  62049. * @returns true if they are equal
  62050. */
  62051. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  62052. /**
  62053. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  62054. * @param x x value to compare against
  62055. * @param y y value to compare against
  62056. * @param z z value to compare against
  62057. * @param w w value to compare against
  62058. * @returns true if equal
  62059. */
  62060. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  62061. /**
  62062. * Multiplies in place the current Vector4 by the given one.
  62063. * @param otherVector vector to multiple with
  62064. * @returns the updated Vector4.
  62065. */
  62066. multiplyInPlace(otherVector: Vector4): Vector4;
  62067. /**
  62068. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  62069. * @param otherVector vector to multiple with
  62070. * @returns resulting new vector
  62071. */
  62072. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  62073. /**
  62074. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  62075. * @param otherVector vector to multiple with
  62076. * @param result vector to store the result
  62077. * @returns the current Vector4.
  62078. */
  62079. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  62080. /**
  62081. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  62082. * @param x x value multiply with
  62083. * @param y y value multiply with
  62084. * @param z z value multiply with
  62085. * @param w w value multiply with
  62086. * @returns resulting new vector
  62087. */
  62088. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  62089. /**
  62090. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  62091. * @param otherVector vector to devide with
  62092. * @returns resulting new vector
  62093. */
  62094. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  62095. /**
  62096. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  62097. * @param otherVector vector to devide with
  62098. * @param result vector to store the result
  62099. * @returns the current Vector4.
  62100. */
  62101. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  62102. /**
  62103. * Divides the current Vector3 coordinates by the given ones.
  62104. * @param otherVector vector to devide with
  62105. * @returns the updated Vector3.
  62106. */
  62107. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  62108. /**
  62109. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  62110. * @param other defines the second operand
  62111. * @returns the current updated Vector4
  62112. */
  62113. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  62114. /**
  62115. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  62116. * @param other defines the second operand
  62117. * @returns the current updated Vector4
  62118. */
  62119. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  62120. /**
  62121. * Gets a new Vector4 from current Vector4 floored values
  62122. * @returns a new Vector4
  62123. */
  62124. floor(): Vector4;
  62125. /**
  62126. * Gets a new Vector4 from current Vector3 floored values
  62127. * @returns a new Vector4
  62128. */
  62129. fract(): Vector4;
  62130. /**
  62131. * Returns the Vector4 length (float).
  62132. * @returns the length
  62133. */
  62134. length(): number;
  62135. /**
  62136. * Returns the Vector4 squared length (float).
  62137. * @returns the length squared
  62138. */
  62139. lengthSquared(): number;
  62140. /**
  62141. * Normalizes in place the Vector4.
  62142. * @returns the updated Vector4.
  62143. */
  62144. normalize(): Vector4;
  62145. /**
  62146. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  62147. * @returns this converted to a new vector3
  62148. */
  62149. toVector3(): Vector3;
  62150. /**
  62151. * Returns a new Vector4 copied from the current one.
  62152. * @returns the new cloned vector
  62153. */
  62154. clone(): Vector4;
  62155. /**
  62156. * Updates the current Vector4 with the given one coordinates.
  62157. * @param source the source vector to copy from
  62158. * @returns the updated Vector4.
  62159. */
  62160. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  62161. /**
  62162. * Updates the current Vector4 coordinates with the given floats.
  62163. * @param x float to copy from
  62164. * @param y float to copy from
  62165. * @param z float to copy from
  62166. * @param w float to copy from
  62167. * @returns the updated Vector4.
  62168. */
  62169. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  62170. /**
  62171. * Updates the current Vector4 coordinates with the given floats.
  62172. * @param x float to set from
  62173. * @param y float to set from
  62174. * @param z float to set from
  62175. * @param w float to set from
  62176. * @returns the updated Vector4.
  62177. */
  62178. set(x: number, y: number, z: number, w: number): Vector4;
  62179. /**
  62180. * Copies the given float to the current Vector3 coordinates
  62181. * @param v defines the x, y, z and w coordinates of the operand
  62182. * @returns the current updated Vector3
  62183. */
  62184. setAll(v: number): Vector4;
  62185. /**
  62186. * Returns a new Vector4 set from the starting index of the given array.
  62187. * @param array the array to pull values from
  62188. * @param offset the offset into the array to start at
  62189. * @returns the new vector
  62190. */
  62191. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  62192. /**
  62193. * Updates the given vector "result" from the starting index of the given array.
  62194. * @param array the array to pull values from
  62195. * @param offset the offset into the array to start at
  62196. * @param result the vector to store the result in
  62197. */
  62198. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  62199. /**
  62200. * Updates the given vector "result" from the starting index of the given Float32Array.
  62201. * @param array the array to pull values from
  62202. * @param offset the offset into the array to start at
  62203. * @param result the vector to store the result in
  62204. */
  62205. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  62206. /**
  62207. * Updates the given vector "result" coordinates from the given floats.
  62208. * @param x float to set from
  62209. * @param y float to set from
  62210. * @param z float to set from
  62211. * @param w float to set from
  62212. * @param result the vector to the floats in
  62213. */
  62214. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  62215. /**
  62216. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  62217. * @returns the new vector
  62218. */
  62219. static Zero(): Vector4;
  62220. /**
  62221. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  62222. * @returns the new vector
  62223. */
  62224. static One(): Vector4;
  62225. /**
  62226. * Returns a new normalized Vector4 from the given one.
  62227. * @param vector the vector to normalize
  62228. * @returns the vector
  62229. */
  62230. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  62231. /**
  62232. * Updates the given vector "result" from the normalization of the given one.
  62233. * @param vector the vector to normalize
  62234. * @param result the vector to store the result in
  62235. */
  62236. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  62237. /**
  62238. * Returns a vector with the minimum values from the left and right vectors
  62239. * @param left left vector to minimize
  62240. * @param right right vector to minimize
  62241. * @returns a new vector with the minimum of the left and right vector values
  62242. */
  62243. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  62244. /**
  62245. * Returns a vector with the maximum values from the left and right vectors
  62246. * @param left left vector to maximize
  62247. * @param right right vector to maximize
  62248. * @returns a new vector with the maximum of the left and right vector values
  62249. */
  62250. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  62251. /**
  62252. * Returns the distance (float) between the vectors "value1" and "value2".
  62253. * @param value1 value to calulate the distance between
  62254. * @param value2 value to calulate the distance between
  62255. * @return the distance between the two vectors
  62256. */
  62257. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  62258. /**
  62259. * Returns the squared distance (float) between the vectors "value1" and "value2".
  62260. * @param value1 value to calulate the distance between
  62261. * @param value2 value to calulate the distance between
  62262. * @return the distance between the two vectors squared
  62263. */
  62264. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  62265. /**
  62266. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  62267. * @param value1 value to calulate the center between
  62268. * @param value2 value to calulate the center between
  62269. * @return the center between the two vectors
  62270. */
  62271. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  62272. /**
  62273. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  62274. * This methods computes transformed normalized direction vectors only.
  62275. * @param vector the vector to transform
  62276. * @param transformation the transformation matrix to apply
  62277. * @returns the new vector
  62278. */
  62279. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  62280. /**
  62281. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  62282. * This methods computes transformed normalized direction vectors only.
  62283. * @param vector the vector to transform
  62284. * @param transformation the transformation matrix to apply
  62285. * @param result the vector to store the result in
  62286. */
  62287. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  62288. /**
  62289. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  62290. * This methods computes transformed normalized direction vectors only.
  62291. * @param x value to transform
  62292. * @param y value to transform
  62293. * @param z value to transform
  62294. * @param w value to transform
  62295. * @param transformation the transformation matrix to apply
  62296. * @param result the vector to store the results in
  62297. */
  62298. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  62299. /**
  62300. * Creates a new Vector4 from a Vector3
  62301. * @param source defines the source data
  62302. * @param w defines the 4th component (default is 0)
  62303. * @returns a new Vector4
  62304. */
  62305. static FromVector3(source: Vector3, w?: number): Vector4;
  62306. }
  62307. /**
  62308. * Interface for the size containing width and height
  62309. */
  62310. export interface ISize {
  62311. /**
  62312. * Width
  62313. */
  62314. width: number;
  62315. /**
  62316. * Heighht
  62317. */
  62318. height: number;
  62319. }
  62320. /**
  62321. * Size containing widht and height
  62322. */
  62323. export class Size implements ISize {
  62324. /**
  62325. * Width
  62326. */
  62327. width: number;
  62328. /**
  62329. * Height
  62330. */
  62331. height: number;
  62332. /**
  62333. * Creates a Size object from the given width and height (floats).
  62334. * @param width width of the new size
  62335. * @param height height of the new size
  62336. */
  62337. constructor(width: number, height: number);
  62338. /**
  62339. * Returns a string with the Size width and height
  62340. * @returns a string with the Size width and height
  62341. */
  62342. toString(): string;
  62343. /**
  62344. * "Size"
  62345. * @returns the string "Size"
  62346. */
  62347. getClassName(): string;
  62348. /**
  62349. * Returns the Size hash code.
  62350. * @returns a hash code for a unique width and height
  62351. */
  62352. getHashCode(): number;
  62353. /**
  62354. * Updates the current size from the given one.
  62355. * @param src the given size
  62356. */
  62357. copyFrom(src: Size): void;
  62358. /**
  62359. * Updates in place the current Size from the given floats.
  62360. * @param width width of the new size
  62361. * @param height height of the new size
  62362. * @returns the updated Size.
  62363. */
  62364. copyFromFloats(width: number, height: number): Size;
  62365. /**
  62366. * Updates in place the current Size from the given floats.
  62367. * @param width width to set
  62368. * @param height height to set
  62369. * @returns the updated Size.
  62370. */
  62371. set(width: number, height: number): Size;
  62372. /**
  62373. * Multiplies the width and height by numbers
  62374. * @param w factor to multiple the width by
  62375. * @param h factor to multiple the height by
  62376. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  62377. */
  62378. multiplyByFloats(w: number, h: number): Size;
  62379. /**
  62380. * Clones the size
  62381. * @returns a new Size copied from the given one.
  62382. */
  62383. clone(): Size;
  62384. /**
  62385. * True if the current Size and the given one width and height are strictly equal.
  62386. * @param other the other size to compare against
  62387. * @returns True if the current Size and the given one width and height are strictly equal.
  62388. */
  62389. equals(other: Size): boolean;
  62390. /**
  62391. * The surface of the Size : width * height (float).
  62392. */
  62393. readonly surface: number;
  62394. /**
  62395. * Create a new size of zero
  62396. * @returns a new Size set to (0.0, 0.0)
  62397. */
  62398. static Zero(): Size;
  62399. /**
  62400. * Sums the width and height of two sizes
  62401. * @param otherSize size to add to this size
  62402. * @returns a new Size set as the addition result of the current Size and the given one.
  62403. */
  62404. add(otherSize: Size): Size;
  62405. /**
  62406. * Subtracts the width and height of two
  62407. * @param otherSize size to subtract to this size
  62408. * @returns a new Size set as the subtraction result of the given one from the current Size.
  62409. */
  62410. subtract(otherSize: Size): Size;
  62411. /**
  62412. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  62413. * @param start starting size to lerp between
  62414. * @param end end size to lerp between
  62415. * @param amount amount to lerp between the start and end values
  62416. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  62417. */
  62418. static Lerp(start: Size, end: Size, amount: number): Size;
  62419. }
  62420. /**
  62421. * Class used to store quaternion data
  62422. * @see https://en.wikipedia.org/wiki/Quaternion
  62423. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  62424. */
  62425. export class Quaternion {
  62426. /** defines the first component (0 by default) */
  62427. x: number;
  62428. /** defines the second component (0 by default) */
  62429. y: number;
  62430. /** defines the third component (0 by default) */
  62431. z: number;
  62432. /** defines the fourth component (1.0 by default) */
  62433. w: number;
  62434. /**
  62435. * Creates a new Quaternion from the given floats
  62436. * @param x defines the first component (0 by default)
  62437. * @param y defines the second component (0 by default)
  62438. * @param z defines the third component (0 by default)
  62439. * @param w defines the fourth component (1.0 by default)
  62440. */
  62441. constructor(
  62442. /** defines the first component (0 by default) */
  62443. x?: number,
  62444. /** defines the second component (0 by default) */
  62445. y?: number,
  62446. /** defines the third component (0 by default) */
  62447. z?: number,
  62448. /** defines the fourth component (1.0 by default) */
  62449. w?: number);
  62450. /**
  62451. * Gets a string representation for the current quaternion
  62452. * @returns a string with the Quaternion coordinates
  62453. */
  62454. toString(): string;
  62455. /**
  62456. * Gets the class name of the quaternion
  62457. * @returns the string "Quaternion"
  62458. */
  62459. getClassName(): string;
  62460. /**
  62461. * Gets a hash code for this quaternion
  62462. * @returns the quaternion hash code
  62463. */
  62464. getHashCode(): number;
  62465. /**
  62466. * Copy the quaternion to an array
  62467. * @returns a new array populated with 4 elements from the quaternion coordinates
  62468. */
  62469. asArray(): number[];
  62470. /**
  62471. * Check if two quaternions are equals
  62472. * @param otherQuaternion defines the second operand
  62473. * @return true if the current quaternion and the given one coordinates are strictly equals
  62474. */
  62475. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  62476. /**
  62477. * Clone the current quaternion
  62478. * @returns a new quaternion copied from the current one
  62479. */
  62480. clone(): Quaternion;
  62481. /**
  62482. * Copy a quaternion to the current one
  62483. * @param other defines the other quaternion
  62484. * @returns the updated current quaternion
  62485. */
  62486. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  62487. /**
  62488. * Updates the current quaternion with the given float coordinates
  62489. * @param x defines the x coordinate
  62490. * @param y defines the y coordinate
  62491. * @param z defines the z coordinate
  62492. * @param w defines the w coordinate
  62493. * @returns the updated current quaternion
  62494. */
  62495. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  62496. /**
  62497. * Updates the current quaternion from the given float coordinates
  62498. * @param x defines the x coordinate
  62499. * @param y defines the y coordinate
  62500. * @param z defines the z coordinate
  62501. * @param w defines the w coordinate
  62502. * @returns the updated current quaternion
  62503. */
  62504. set(x: number, y: number, z: number, w: number): Quaternion;
  62505. /**
  62506. * Adds two quaternions
  62507. * @param other defines the second operand
  62508. * @returns a new quaternion as the addition result of the given one and the current quaternion
  62509. */
  62510. add(other: DeepImmutable<Quaternion>): Quaternion;
  62511. /**
  62512. * Add a quaternion to the current one
  62513. * @param other defines the quaternion to add
  62514. * @returns the current quaternion
  62515. */
  62516. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  62517. /**
  62518. * Subtract two quaternions
  62519. * @param other defines the second operand
  62520. * @returns a new quaternion as the subtraction result of the given one from the current one
  62521. */
  62522. subtract(other: Quaternion): Quaternion;
  62523. /**
  62524. * Multiplies the current quaternion by a scale factor
  62525. * @param value defines the scale factor
  62526. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  62527. */
  62528. scale(value: number): Quaternion;
  62529. /**
  62530. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  62531. * @param scale defines the scale factor
  62532. * @param result defines the Quaternion object where to store the result
  62533. * @returns the unmodified current quaternion
  62534. */
  62535. scaleToRef(scale: number, result: Quaternion): Quaternion;
  62536. /**
  62537. * Multiplies in place the current quaternion by a scale factor
  62538. * @param value defines the scale factor
  62539. * @returns the current modified quaternion
  62540. */
  62541. scaleInPlace(value: number): Quaternion;
  62542. /**
  62543. * Scale the current quaternion values by a factor and add the result to a given quaternion
  62544. * @param scale defines the scale factor
  62545. * @param result defines the Quaternion object where to store the result
  62546. * @returns the unmodified current quaternion
  62547. */
  62548. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  62549. /**
  62550. * Multiplies two quaternions
  62551. * @param q1 defines the second operand
  62552. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  62553. */
  62554. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  62555. /**
  62556. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  62557. * @param q1 defines the second operand
  62558. * @param result defines the target quaternion
  62559. * @returns the current quaternion
  62560. */
  62561. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  62562. /**
  62563. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  62564. * @param q1 defines the second operand
  62565. * @returns the currentupdated quaternion
  62566. */
  62567. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  62568. /**
  62569. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  62570. * @param ref defines the target quaternion
  62571. * @returns the current quaternion
  62572. */
  62573. conjugateToRef(ref: Quaternion): Quaternion;
  62574. /**
  62575. * Conjugates in place (1-q) the current quaternion
  62576. * @returns the current updated quaternion
  62577. */
  62578. conjugateInPlace(): Quaternion;
  62579. /**
  62580. * Conjugates in place (1-q) the current quaternion
  62581. * @returns a new quaternion
  62582. */
  62583. conjugate(): Quaternion;
  62584. /**
  62585. * Gets length of current quaternion
  62586. * @returns the quaternion length (float)
  62587. */
  62588. length(): number;
  62589. /**
  62590. * Normalize in place the current quaternion
  62591. * @returns the current updated quaternion
  62592. */
  62593. normalize(): Quaternion;
  62594. /**
  62595. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  62596. * @param order is a reserved parameter and is ignore for now
  62597. * @returns a new Vector3 containing the Euler angles
  62598. */
  62599. toEulerAngles(order?: string): Vector3;
  62600. /**
  62601. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  62602. * @param result defines the vector which will be filled with the Euler angles
  62603. * @param order is a reserved parameter and is ignore for now
  62604. * @returns the current unchanged quaternion
  62605. */
  62606. toEulerAnglesToRef(result: Vector3): Quaternion;
  62607. /**
  62608. * Updates the given rotation matrix with the current quaternion values
  62609. * @param result defines the target matrix
  62610. * @returns the current unchanged quaternion
  62611. */
  62612. toRotationMatrix(result: Matrix): Quaternion;
  62613. /**
  62614. * Updates the current quaternion from the given rotation matrix values
  62615. * @param matrix defines the source matrix
  62616. * @returns the current updated quaternion
  62617. */
  62618. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  62619. /**
  62620. * Creates a new quaternion from a rotation matrix
  62621. * @param matrix defines the source matrix
  62622. * @returns a new quaternion created from the given rotation matrix values
  62623. */
  62624. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  62625. /**
  62626. * Updates the given quaternion with the given rotation matrix values
  62627. * @param matrix defines the source matrix
  62628. * @param result defines the target quaternion
  62629. */
  62630. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  62631. /**
  62632. * Returns the dot product (float) between the quaternions "left" and "right"
  62633. * @param left defines the left operand
  62634. * @param right defines the right operand
  62635. * @returns the dot product
  62636. */
  62637. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  62638. /**
  62639. * Checks if the two quaternions are close to each other
  62640. * @param quat0 defines the first quaternion to check
  62641. * @param quat1 defines the second quaternion to check
  62642. * @returns true if the two quaternions are close to each other
  62643. */
  62644. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  62645. /**
  62646. * Creates an empty quaternion
  62647. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  62648. */
  62649. static Zero(): Quaternion;
  62650. /**
  62651. * Inverse a given quaternion
  62652. * @param q defines the source quaternion
  62653. * @returns a new quaternion as the inverted current quaternion
  62654. */
  62655. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  62656. /**
  62657. * Inverse a given quaternion
  62658. * @param q defines the source quaternion
  62659. * @param result the quaternion the result will be stored in
  62660. * @returns the result quaternion
  62661. */
  62662. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  62663. /**
  62664. * Creates an identity quaternion
  62665. * @returns the identity quaternion
  62666. */
  62667. static Identity(): Quaternion;
  62668. /**
  62669. * Gets a boolean indicating if the given quaternion is identity
  62670. * @param quaternion defines the quaternion to check
  62671. * @returns true if the quaternion is identity
  62672. */
  62673. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  62674. /**
  62675. * Creates a quaternion from a rotation around an axis
  62676. * @param axis defines the axis to use
  62677. * @param angle defines the angle to use
  62678. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  62679. */
  62680. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  62681. /**
  62682. * Creates a rotation around an axis and stores it into the given quaternion
  62683. * @param axis defines the axis to use
  62684. * @param angle defines the angle to use
  62685. * @param result defines the target quaternion
  62686. * @returns the target quaternion
  62687. */
  62688. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  62689. /**
  62690. * Creates a new quaternion from data stored into an array
  62691. * @param array defines the data source
  62692. * @param offset defines the offset in the source array where the data starts
  62693. * @returns a new quaternion
  62694. */
  62695. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  62696. /**
  62697. * Create a quaternion from Euler rotation angles
  62698. * @param x Pitch
  62699. * @param y Yaw
  62700. * @param z Roll
  62701. * @returns the new Quaternion
  62702. */
  62703. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  62704. /**
  62705. * Updates a quaternion from Euler rotation angles
  62706. * @param x Pitch
  62707. * @param y Yaw
  62708. * @param z Roll
  62709. * @param result the quaternion to store the result
  62710. * @returns the updated quaternion
  62711. */
  62712. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  62713. /**
  62714. * Create a quaternion from Euler rotation vector
  62715. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  62716. * @returns the new Quaternion
  62717. */
  62718. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  62719. /**
  62720. * Updates a quaternion from Euler rotation vector
  62721. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  62722. * @param result the quaternion to store the result
  62723. * @returns the updated quaternion
  62724. */
  62725. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  62726. /**
  62727. * Creates a new quaternion from the given Euler float angles (y, x, z)
  62728. * @param yaw defines the rotation around Y axis
  62729. * @param pitch defines the rotation around X axis
  62730. * @param roll defines the rotation around Z axis
  62731. * @returns the new quaternion
  62732. */
  62733. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  62734. /**
  62735. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  62736. * @param yaw defines the rotation around Y axis
  62737. * @param pitch defines the rotation around X axis
  62738. * @param roll defines the rotation around Z axis
  62739. * @param result defines the target quaternion
  62740. */
  62741. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  62742. /**
  62743. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  62744. * @param alpha defines the rotation around first axis
  62745. * @param beta defines the rotation around second axis
  62746. * @param gamma defines the rotation around third axis
  62747. * @returns the new quaternion
  62748. */
  62749. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  62750. /**
  62751. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  62752. * @param alpha defines the rotation around first axis
  62753. * @param beta defines the rotation around second axis
  62754. * @param gamma defines the rotation around third axis
  62755. * @param result defines the target quaternion
  62756. */
  62757. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  62758. /**
  62759. * 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)
  62760. * @param axis1 defines the first axis
  62761. * @param axis2 defines the second axis
  62762. * @param axis3 defines the third axis
  62763. * @returns the new quaternion
  62764. */
  62765. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  62766. /**
  62767. * 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
  62768. * @param axis1 defines the first axis
  62769. * @param axis2 defines the second axis
  62770. * @param axis3 defines the third axis
  62771. * @param ref defines the target quaternion
  62772. */
  62773. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  62774. /**
  62775. * Interpolates between two quaternions
  62776. * @param left defines first quaternion
  62777. * @param right defines second quaternion
  62778. * @param amount defines the gradient to use
  62779. * @returns the new interpolated quaternion
  62780. */
  62781. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  62782. /**
  62783. * Interpolates between two quaternions and stores it into a target quaternion
  62784. * @param left defines first quaternion
  62785. * @param right defines second quaternion
  62786. * @param amount defines the gradient to use
  62787. * @param result defines the target quaternion
  62788. */
  62789. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  62790. /**
  62791. * Interpolate between two quaternions using Hermite interpolation
  62792. * @param value1 defines first quaternion
  62793. * @param tangent1 defines the incoming tangent
  62794. * @param value2 defines second quaternion
  62795. * @param tangent2 defines the outgoing tangent
  62796. * @param amount defines the target quaternion
  62797. * @returns the new interpolated quaternion
  62798. */
  62799. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  62800. }
  62801. /**
  62802. * Class used to store matrix data (4x4)
  62803. */
  62804. export class Matrix {
  62805. private static _updateFlagSeed;
  62806. private static _identityReadOnly;
  62807. private _isIdentity;
  62808. private _isIdentityDirty;
  62809. private _isIdentity3x2;
  62810. private _isIdentity3x2Dirty;
  62811. /**
  62812. * Gets the update flag of the matrix which is an unique number for the matrix.
  62813. * It will be incremented every time the matrix data change.
  62814. * You can use it to speed the comparison between two versions of the same matrix.
  62815. */
  62816. updateFlag: number;
  62817. private readonly _m;
  62818. /**
  62819. * Gets the internal data of the matrix
  62820. */
  62821. readonly m: DeepImmutable<Float32Array>;
  62822. /** @hidden */
  62823. _markAsUpdated(): void;
  62824. /** @hidden */
  62825. private _updateIdentityStatus;
  62826. /**
  62827. * Creates an empty matrix (filled with zeros)
  62828. */
  62829. constructor();
  62830. /**
  62831. * Check if the current matrix is identity
  62832. * @returns true is the matrix is the identity matrix
  62833. */
  62834. isIdentity(): boolean;
  62835. /**
  62836. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  62837. * @returns true is the matrix is the identity matrix
  62838. */
  62839. isIdentityAs3x2(): boolean;
  62840. /**
  62841. * Gets the determinant of the matrix
  62842. * @returns the matrix determinant
  62843. */
  62844. determinant(): number;
  62845. /**
  62846. * Returns the matrix as a Float32Array
  62847. * @returns the matrix underlying array
  62848. */
  62849. toArray(): DeepImmutable<Float32Array>;
  62850. /**
  62851. * Returns the matrix as a Float32Array
  62852. * @returns the matrix underlying array.
  62853. */
  62854. asArray(): DeepImmutable<Float32Array>;
  62855. /**
  62856. * Inverts the current matrix in place
  62857. * @returns the current inverted matrix
  62858. */
  62859. invert(): Matrix;
  62860. /**
  62861. * Sets all the matrix elements to zero
  62862. * @returns the current matrix
  62863. */
  62864. reset(): Matrix;
  62865. /**
  62866. * Adds the current matrix with a second one
  62867. * @param other defines the matrix to add
  62868. * @returns a new matrix as the addition of the current matrix and the given one
  62869. */
  62870. add(other: DeepImmutable<Matrix>): Matrix;
  62871. /**
  62872. * Sets the given matrix "result" to the addition of the current matrix and the given one
  62873. * @param other defines the matrix to add
  62874. * @param result defines the target matrix
  62875. * @returns the current matrix
  62876. */
  62877. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  62878. /**
  62879. * Adds in place the given matrix to the current matrix
  62880. * @param other defines the second operand
  62881. * @returns the current updated matrix
  62882. */
  62883. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  62884. /**
  62885. * Sets the given matrix to the current inverted Matrix
  62886. * @param other defines the target matrix
  62887. * @returns the unmodified current matrix
  62888. */
  62889. invertToRef(other: Matrix): Matrix;
  62890. /**
  62891. * add a value at the specified position in the current Matrix
  62892. * @param index the index of the value within the matrix. between 0 and 15.
  62893. * @param value the value to be added
  62894. * @returns the current updated matrix
  62895. */
  62896. addAtIndex(index: number, value: number): Matrix;
  62897. /**
  62898. * mutiply the specified position in the current Matrix by a value
  62899. * @param index the index of the value within the matrix. between 0 and 15.
  62900. * @param value the value to be added
  62901. * @returns the current updated matrix
  62902. */
  62903. multiplyAtIndex(index: number, value: number): Matrix;
  62904. /**
  62905. * Inserts the translation vector (using 3 floats) in the current matrix
  62906. * @param x defines the 1st component of the translation
  62907. * @param y defines the 2nd component of the translation
  62908. * @param z defines the 3rd component of the translation
  62909. * @returns the current updated matrix
  62910. */
  62911. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  62912. /**
  62913. * Adds the translation vector (using 3 floats) in the current matrix
  62914. * @param x defines the 1st component of the translation
  62915. * @param y defines the 2nd component of the translation
  62916. * @param z defines the 3rd component of the translation
  62917. * @returns the current updated matrix
  62918. */
  62919. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  62920. /**
  62921. * Inserts the translation vector in the current matrix
  62922. * @param vector3 defines the translation to insert
  62923. * @returns the current updated matrix
  62924. */
  62925. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  62926. /**
  62927. * Gets the translation value of the current matrix
  62928. * @returns a new Vector3 as the extracted translation from the matrix
  62929. */
  62930. getTranslation(): Vector3;
  62931. /**
  62932. * Fill a Vector3 with the extracted translation from the matrix
  62933. * @param result defines the Vector3 where to store the translation
  62934. * @returns the current matrix
  62935. */
  62936. getTranslationToRef(result: Vector3): Matrix;
  62937. /**
  62938. * Remove rotation and scaling part from the matrix
  62939. * @returns the updated matrix
  62940. */
  62941. removeRotationAndScaling(): Matrix;
  62942. /**
  62943. * Multiply two matrices
  62944. * @param other defines the second operand
  62945. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  62946. */
  62947. multiply(other: DeepImmutable<Matrix>): Matrix;
  62948. /**
  62949. * Copy the current matrix from the given one
  62950. * @param other defines the source matrix
  62951. * @returns the current updated matrix
  62952. */
  62953. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  62954. /**
  62955. * Populates the given array from the starting index with the current matrix values
  62956. * @param array defines the target array
  62957. * @param offset defines the offset in the target array where to start storing values
  62958. * @returns the current matrix
  62959. */
  62960. copyToArray(array: Float32Array, offset?: number): Matrix;
  62961. /**
  62962. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  62963. * @param other defines the second operand
  62964. * @param result defines the matrix where to store the multiplication
  62965. * @returns the current matrix
  62966. */
  62967. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  62968. /**
  62969. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  62970. * @param other defines the second operand
  62971. * @param result defines the array where to store the multiplication
  62972. * @param offset defines the offset in the target array where to start storing values
  62973. * @returns the current matrix
  62974. */
  62975. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  62976. /**
  62977. * Check equality between this matrix and a second one
  62978. * @param value defines the second matrix to compare
  62979. * @returns true is the current matrix and the given one values are strictly equal
  62980. */
  62981. equals(value: DeepImmutable<Matrix>): boolean;
  62982. /**
  62983. * Clone the current matrix
  62984. * @returns a new matrix from the current matrix
  62985. */
  62986. clone(): Matrix;
  62987. /**
  62988. * Returns the name of the current matrix class
  62989. * @returns the string "Matrix"
  62990. */
  62991. getClassName(): string;
  62992. /**
  62993. * Gets the hash code of the current matrix
  62994. * @returns the hash code
  62995. */
  62996. getHashCode(): number;
  62997. /**
  62998. * Decomposes the current Matrix into a translation, rotation and scaling components
  62999. * @param scale defines the scale vector3 given as a reference to update
  63000. * @param rotation defines the rotation quaternion given as a reference to update
  63001. * @param translation defines the translation vector3 given as a reference to update
  63002. * @returns true if operation was successful
  63003. */
  63004. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  63005. /**
  63006. * Gets specific row of the matrix
  63007. * @param index defines the number of the row to get
  63008. * @returns the index-th row of the current matrix as a new Vector4
  63009. */
  63010. getRow(index: number): Nullable<Vector4>;
  63011. /**
  63012. * Sets the index-th row of the current matrix to the vector4 values
  63013. * @param index defines the number of the row to set
  63014. * @param row defines the target vector4
  63015. * @returns the updated current matrix
  63016. */
  63017. setRow(index: number, row: Vector4): Matrix;
  63018. /**
  63019. * Compute the transpose of the matrix
  63020. * @returns the new transposed matrix
  63021. */
  63022. transpose(): Matrix;
  63023. /**
  63024. * Compute the transpose of the matrix and store it in a given matrix
  63025. * @param result defines the target matrix
  63026. * @returns the current matrix
  63027. */
  63028. transposeToRef(result: Matrix): Matrix;
  63029. /**
  63030. * Sets the index-th row of the current matrix with the given 4 x float values
  63031. * @param index defines the row index
  63032. * @param x defines the x component to set
  63033. * @param y defines the y component to set
  63034. * @param z defines the z component to set
  63035. * @param w defines the w component to set
  63036. * @returns the updated current matrix
  63037. */
  63038. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  63039. /**
  63040. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  63041. * @param scale defines the scale factor
  63042. * @returns a new matrix
  63043. */
  63044. scale(scale: number): Matrix;
  63045. /**
  63046. * Scale the current matrix values by a factor to a given result matrix
  63047. * @param scale defines the scale factor
  63048. * @param result defines the matrix to store the result
  63049. * @returns the current matrix
  63050. */
  63051. scaleToRef(scale: number, result: Matrix): Matrix;
  63052. /**
  63053. * Scale the current matrix values by a factor and add the result to a given matrix
  63054. * @param scale defines the scale factor
  63055. * @param result defines the Matrix to store the result
  63056. * @returns the current matrix
  63057. */
  63058. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  63059. /**
  63060. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  63061. * @param ref matrix to store the result
  63062. */
  63063. toNormalMatrix(ref: Matrix): void;
  63064. /**
  63065. * Gets only rotation part of the current matrix
  63066. * @returns a new matrix sets to the extracted rotation matrix from the current one
  63067. */
  63068. getRotationMatrix(): Matrix;
  63069. /**
  63070. * Extracts the rotation matrix from the current one and sets it as the given "result"
  63071. * @param result defines the target matrix to store data to
  63072. * @returns the current matrix
  63073. */
  63074. getRotationMatrixToRef(result: Matrix): Matrix;
  63075. /**
  63076. * Toggles model matrix from being right handed to left handed in place and vice versa
  63077. */
  63078. toggleModelMatrixHandInPlace(): void;
  63079. /**
  63080. * Toggles projection matrix from being right handed to left handed in place and vice versa
  63081. */
  63082. toggleProjectionMatrixHandInPlace(): void;
  63083. /**
  63084. * Creates a matrix from an array
  63085. * @param array defines the source array
  63086. * @param offset defines an offset in the source array
  63087. * @returns a new Matrix set from the starting index of the given array
  63088. */
  63089. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  63090. /**
  63091. * Copy the content of an array into a given matrix
  63092. * @param array defines the source array
  63093. * @param offset defines an offset in the source array
  63094. * @param result defines the target matrix
  63095. */
  63096. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  63097. /**
  63098. * Stores an array into a matrix after having multiplied each component by a given factor
  63099. * @param array defines the source array
  63100. * @param offset defines the offset in the source array
  63101. * @param scale defines the scaling factor
  63102. * @param result defines the target matrix
  63103. */
  63104. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  63105. /**
  63106. * Gets an identity matrix that must not be updated
  63107. */
  63108. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  63109. /**
  63110. * Stores a list of values (16) inside a given matrix
  63111. * @param initialM11 defines 1st value of 1st row
  63112. * @param initialM12 defines 2nd value of 1st row
  63113. * @param initialM13 defines 3rd value of 1st row
  63114. * @param initialM14 defines 4th value of 1st row
  63115. * @param initialM21 defines 1st value of 2nd row
  63116. * @param initialM22 defines 2nd value of 2nd row
  63117. * @param initialM23 defines 3rd value of 2nd row
  63118. * @param initialM24 defines 4th value of 2nd row
  63119. * @param initialM31 defines 1st value of 3rd row
  63120. * @param initialM32 defines 2nd value of 3rd row
  63121. * @param initialM33 defines 3rd value of 3rd row
  63122. * @param initialM34 defines 4th value of 3rd row
  63123. * @param initialM41 defines 1st value of 4th row
  63124. * @param initialM42 defines 2nd value of 4th row
  63125. * @param initialM43 defines 3rd value of 4th row
  63126. * @param initialM44 defines 4th value of 4th row
  63127. * @param result defines the target matrix
  63128. */
  63129. 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;
  63130. /**
  63131. * Creates new matrix from a list of values (16)
  63132. * @param initialM11 defines 1st value of 1st row
  63133. * @param initialM12 defines 2nd value of 1st row
  63134. * @param initialM13 defines 3rd value of 1st row
  63135. * @param initialM14 defines 4th value of 1st row
  63136. * @param initialM21 defines 1st value of 2nd row
  63137. * @param initialM22 defines 2nd value of 2nd row
  63138. * @param initialM23 defines 3rd value of 2nd row
  63139. * @param initialM24 defines 4th value of 2nd row
  63140. * @param initialM31 defines 1st value of 3rd row
  63141. * @param initialM32 defines 2nd value of 3rd row
  63142. * @param initialM33 defines 3rd value of 3rd row
  63143. * @param initialM34 defines 4th value of 3rd row
  63144. * @param initialM41 defines 1st value of 4th row
  63145. * @param initialM42 defines 2nd value of 4th row
  63146. * @param initialM43 defines 3rd value of 4th row
  63147. * @param initialM44 defines 4th value of 4th row
  63148. * @returns the new matrix
  63149. */
  63150. 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;
  63151. /**
  63152. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  63153. * @param scale defines the scale vector3
  63154. * @param rotation defines the rotation quaternion
  63155. * @param translation defines the translation vector3
  63156. * @returns a new matrix
  63157. */
  63158. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  63159. /**
  63160. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  63161. * @param scale defines the scale vector3
  63162. * @param rotation defines the rotation quaternion
  63163. * @param translation defines the translation vector3
  63164. * @param result defines the target matrix
  63165. */
  63166. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  63167. /**
  63168. * Creates a new identity matrix
  63169. * @returns a new identity matrix
  63170. */
  63171. static Identity(): Matrix;
  63172. /**
  63173. * Creates a new identity matrix and stores the result in a given matrix
  63174. * @param result defines the target matrix
  63175. */
  63176. static IdentityToRef(result: Matrix): void;
  63177. /**
  63178. * Creates a new zero matrix
  63179. * @returns a new zero matrix
  63180. */
  63181. static Zero(): Matrix;
  63182. /**
  63183. * Creates a new rotation matrix for "angle" radians around the X axis
  63184. * @param angle defines the angle (in radians) to use
  63185. * @return the new matrix
  63186. */
  63187. static RotationX(angle: number): Matrix;
  63188. /**
  63189. * Creates a new matrix as the invert of a given matrix
  63190. * @param source defines the source matrix
  63191. * @returns the new matrix
  63192. */
  63193. static Invert(source: DeepImmutable<Matrix>): Matrix;
  63194. /**
  63195. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  63196. * @param angle defines the angle (in radians) to use
  63197. * @param result defines the target matrix
  63198. */
  63199. static RotationXToRef(angle: number, result: Matrix): void;
  63200. /**
  63201. * Creates a new rotation matrix for "angle" radians around the Y axis
  63202. * @param angle defines the angle (in radians) to use
  63203. * @return the new matrix
  63204. */
  63205. static RotationY(angle: number): Matrix;
  63206. /**
  63207. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  63208. * @param angle defines the angle (in radians) to use
  63209. * @param result defines the target matrix
  63210. */
  63211. static RotationYToRef(angle: number, result: Matrix): void;
  63212. /**
  63213. * Creates a new rotation matrix for "angle" radians around the Z axis
  63214. * @param angle defines the angle (in radians) to use
  63215. * @return the new matrix
  63216. */
  63217. static RotationZ(angle: number): Matrix;
  63218. /**
  63219. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  63220. * @param angle defines the angle (in radians) to use
  63221. * @param result defines the target matrix
  63222. */
  63223. static RotationZToRef(angle: number, result: Matrix): void;
  63224. /**
  63225. * Creates a new rotation matrix for "angle" radians around the given axis
  63226. * @param axis defines the axis to use
  63227. * @param angle defines the angle (in radians) to use
  63228. * @return the new matrix
  63229. */
  63230. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  63231. /**
  63232. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  63233. * @param axis defines the axis to use
  63234. * @param angle defines the angle (in radians) to use
  63235. * @param result defines the target matrix
  63236. */
  63237. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  63238. /**
  63239. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  63240. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  63241. * @param from defines the vector to align
  63242. * @param to defines the vector to align to
  63243. * @param result defines the target matrix
  63244. */
  63245. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  63246. /**
  63247. * Creates a rotation matrix
  63248. * @param yaw defines the yaw angle in radians (Y axis)
  63249. * @param pitch defines the pitch angle in radians (X axis)
  63250. * @param roll defines the roll angle in radians (X axis)
  63251. * @returns the new rotation matrix
  63252. */
  63253. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  63254. /**
  63255. * Creates a rotation matrix and stores it in a given matrix
  63256. * @param yaw defines the yaw angle in radians (Y axis)
  63257. * @param pitch defines the pitch angle in radians (X axis)
  63258. * @param roll defines the roll angle in radians (X axis)
  63259. * @param result defines the target matrix
  63260. */
  63261. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  63262. /**
  63263. * Creates a scaling matrix
  63264. * @param x defines the scale factor on X axis
  63265. * @param y defines the scale factor on Y axis
  63266. * @param z defines the scale factor on Z axis
  63267. * @returns the new matrix
  63268. */
  63269. static Scaling(x: number, y: number, z: number): Matrix;
  63270. /**
  63271. * Creates a scaling matrix and stores it in a given matrix
  63272. * @param x defines the scale factor on X axis
  63273. * @param y defines the scale factor on Y axis
  63274. * @param z defines the scale factor on Z axis
  63275. * @param result defines the target matrix
  63276. */
  63277. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  63278. /**
  63279. * Creates a translation matrix
  63280. * @param x defines the translation on X axis
  63281. * @param y defines the translation on Y axis
  63282. * @param z defines the translationon Z axis
  63283. * @returns the new matrix
  63284. */
  63285. static Translation(x: number, y: number, z: number): Matrix;
  63286. /**
  63287. * Creates a translation matrix and stores it in a given matrix
  63288. * @param x defines the translation on X axis
  63289. * @param y defines the translation on Y axis
  63290. * @param z defines the translationon Z axis
  63291. * @param result defines the target matrix
  63292. */
  63293. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  63294. /**
  63295. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  63296. * @param startValue defines the start value
  63297. * @param endValue defines the end value
  63298. * @param gradient defines the gradient factor
  63299. * @returns the new matrix
  63300. */
  63301. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  63302. /**
  63303. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  63304. * @param startValue defines the start value
  63305. * @param endValue defines the end value
  63306. * @param gradient defines the gradient factor
  63307. * @param result defines the Matrix object where to store data
  63308. */
  63309. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  63310. /**
  63311. * Builds a new matrix whose values are computed by:
  63312. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  63313. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  63314. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  63315. * @param startValue defines the first matrix
  63316. * @param endValue defines the second matrix
  63317. * @param gradient defines the gradient between the two matrices
  63318. * @returns the new matrix
  63319. */
  63320. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  63321. /**
  63322. * Update a matrix to values which are computed by:
  63323. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  63324. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  63325. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  63326. * @param startValue defines the first matrix
  63327. * @param endValue defines the second matrix
  63328. * @param gradient defines the gradient between the two matrices
  63329. * @param result defines the target matrix
  63330. */
  63331. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  63332. /**
  63333. * 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"
  63334. * This function works in left handed mode
  63335. * @param eye defines the final position of the entity
  63336. * @param target defines where the entity should look at
  63337. * @param up defines the up vector for the entity
  63338. * @returns the new matrix
  63339. */
  63340. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  63341. /**
  63342. * 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".
  63343. * This function works in left handed mode
  63344. * @param eye defines the final position of the entity
  63345. * @param target defines where the entity should look at
  63346. * @param up defines the up vector for the entity
  63347. * @param result defines the target matrix
  63348. */
  63349. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  63350. /**
  63351. * 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"
  63352. * This function works in right handed mode
  63353. * @param eye defines the final position of the entity
  63354. * @param target defines where the entity should look at
  63355. * @param up defines the up vector for the entity
  63356. * @returns the new matrix
  63357. */
  63358. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  63359. /**
  63360. * 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".
  63361. * This function works in right handed mode
  63362. * @param eye defines the final position of the entity
  63363. * @param target defines where the entity should look at
  63364. * @param up defines the up vector for the entity
  63365. * @param result defines the target matrix
  63366. */
  63367. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  63368. /**
  63369. * Create a left-handed orthographic projection matrix
  63370. * @param width defines the viewport width
  63371. * @param height defines the viewport height
  63372. * @param znear defines the near clip plane
  63373. * @param zfar defines the far clip plane
  63374. * @returns a new matrix as a left-handed orthographic projection matrix
  63375. */
  63376. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  63377. /**
  63378. * Store a left-handed orthographic projection to a given matrix
  63379. * @param width defines the viewport width
  63380. * @param height defines the viewport height
  63381. * @param znear defines the near clip plane
  63382. * @param zfar defines the far clip plane
  63383. * @param result defines the target matrix
  63384. */
  63385. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  63386. /**
  63387. * Create a left-handed orthographic projection matrix
  63388. * @param left defines the viewport left coordinate
  63389. * @param right defines the viewport right coordinate
  63390. * @param bottom defines the viewport bottom coordinate
  63391. * @param top defines the viewport top coordinate
  63392. * @param znear defines the near clip plane
  63393. * @param zfar defines the far clip plane
  63394. * @returns a new matrix as a left-handed orthographic projection matrix
  63395. */
  63396. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  63397. /**
  63398. * Stores a left-handed orthographic projection into a given matrix
  63399. * @param left defines the viewport left coordinate
  63400. * @param right defines the viewport right coordinate
  63401. * @param bottom defines the viewport bottom coordinate
  63402. * @param top defines the viewport top coordinate
  63403. * @param znear defines the near clip plane
  63404. * @param zfar defines the far clip plane
  63405. * @param result defines the target matrix
  63406. */
  63407. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  63408. /**
  63409. * Creates a right-handed orthographic projection matrix
  63410. * @param left defines the viewport left coordinate
  63411. * @param right defines the viewport right coordinate
  63412. * @param bottom defines the viewport bottom coordinate
  63413. * @param top defines the viewport top coordinate
  63414. * @param znear defines the near clip plane
  63415. * @param zfar defines the far clip plane
  63416. * @returns a new matrix as a right-handed orthographic projection matrix
  63417. */
  63418. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  63419. /**
  63420. * Stores a right-handed orthographic projection into a given matrix
  63421. * @param left defines the viewport left coordinate
  63422. * @param right defines the viewport right coordinate
  63423. * @param bottom defines the viewport bottom coordinate
  63424. * @param top defines the viewport top coordinate
  63425. * @param znear defines the near clip plane
  63426. * @param zfar defines the far clip plane
  63427. * @param result defines the target matrix
  63428. */
  63429. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  63430. /**
  63431. * Creates a left-handed perspective projection matrix
  63432. * @param width defines the viewport width
  63433. * @param height defines the viewport height
  63434. * @param znear defines the near clip plane
  63435. * @param zfar defines the far clip plane
  63436. * @returns a new matrix as a left-handed perspective projection matrix
  63437. */
  63438. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  63439. /**
  63440. * Creates a left-handed perspective projection matrix
  63441. * @param fov defines the horizontal field of view
  63442. * @param aspect defines the aspect ratio
  63443. * @param znear defines the near clip plane
  63444. * @param zfar defines the far clip plane
  63445. * @returns a new matrix as a left-handed perspective projection matrix
  63446. */
  63447. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  63448. /**
  63449. * Stores a left-handed perspective projection into a given matrix
  63450. * @param fov defines the horizontal field of view
  63451. * @param aspect defines the aspect ratio
  63452. * @param znear defines the near clip plane
  63453. * @param zfar defines the far clip plane
  63454. * @param result defines the target matrix
  63455. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  63456. */
  63457. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  63458. /**
  63459. * Creates a right-handed perspective projection matrix
  63460. * @param fov defines the horizontal field of view
  63461. * @param aspect defines the aspect ratio
  63462. * @param znear defines the near clip plane
  63463. * @param zfar defines the far clip plane
  63464. * @returns a new matrix as a right-handed perspective projection matrix
  63465. */
  63466. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  63467. /**
  63468. * Stores a right-handed perspective projection into a given matrix
  63469. * @param fov defines the horizontal field of view
  63470. * @param aspect defines the aspect ratio
  63471. * @param znear defines the near clip plane
  63472. * @param zfar defines the far clip plane
  63473. * @param result defines the target matrix
  63474. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  63475. */
  63476. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  63477. /**
  63478. * Stores a perspective projection for WebVR info a given matrix
  63479. * @param fov defines the field of view
  63480. * @param znear defines the near clip plane
  63481. * @param zfar defines the far clip plane
  63482. * @param result defines the target matrix
  63483. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  63484. */
  63485. static PerspectiveFovWebVRToRef(fov: {
  63486. upDegrees: number;
  63487. downDegrees: number;
  63488. leftDegrees: number;
  63489. rightDegrees: number;
  63490. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  63491. /**
  63492. * Computes a complete transformation matrix
  63493. * @param viewport defines the viewport to use
  63494. * @param world defines the world matrix
  63495. * @param view defines the view matrix
  63496. * @param projection defines the projection matrix
  63497. * @param zmin defines the near clip plane
  63498. * @param zmax defines the far clip plane
  63499. * @returns the transformation matrix
  63500. */
  63501. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  63502. /**
  63503. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  63504. * @param matrix defines the matrix to use
  63505. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  63506. */
  63507. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  63508. /**
  63509. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  63510. * @param matrix defines the matrix to use
  63511. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  63512. */
  63513. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  63514. /**
  63515. * Compute the transpose of a given matrix
  63516. * @param matrix defines the matrix to transpose
  63517. * @returns the new matrix
  63518. */
  63519. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  63520. /**
  63521. * Compute the transpose of a matrix and store it in a target matrix
  63522. * @param matrix defines the matrix to transpose
  63523. * @param result defines the target matrix
  63524. */
  63525. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  63526. /**
  63527. * Computes a reflection matrix from a plane
  63528. * @param plane defines the reflection plane
  63529. * @returns a new matrix
  63530. */
  63531. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  63532. /**
  63533. * Computes a reflection matrix from a plane
  63534. * @param plane defines the reflection plane
  63535. * @param result defines the target matrix
  63536. */
  63537. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  63538. /**
  63539. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  63540. * @param xaxis defines the value of the 1st axis
  63541. * @param yaxis defines the value of the 2nd axis
  63542. * @param zaxis defines the value of the 3rd axis
  63543. * @param result defines the target matrix
  63544. */
  63545. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  63546. /**
  63547. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  63548. * @param quat defines the quaternion to use
  63549. * @param result defines the target matrix
  63550. */
  63551. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  63552. }
  63553. /**
  63554. * Represens a plane by the equation ax + by + cz + d = 0
  63555. */
  63556. export class Plane {
  63557. /**
  63558. * Normal of the plane (a,b,c)
  63559. */
  63560. normal: Vector3;
  63561. /**
  63562. * d component of the plane
  63563. */
  63564. d: number;
  63565. /**
  63566. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  63567. * @param a a component of the plane
  63568. * @param b b component of the plane
  63569. * @param c c component of the plane
  63570. * @param d d component of the plane
  63571. */
  63572. constructor(a: number, b: number, c: number, d: number);
  63573. /**
  63574. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  63575. */
  63576. asArray(): number[];
  63577. /**
  63578. * @returns a new plane copied from the current Plane.
  63579. */
  63580. clone(): Plane;
  63581. /**
  63582. * @returns the string "Plane".
  63583. */
  63584. getClassName(): string;
  63585. /**
  63586. * @returns the Plane hash code.
  63587. */
  63588. getHashCode(): number;
  63589. /**
  63590. * Normalize the current Plane in place.
  63591. * @returns the updated Plane.
  63592. */
  63593. normalize(): Plane;
  63594. /**
  63595. * Applies a transformation the plane and returns the result
  63596. * @param transformation the transformation matrix to be applied to the plane
  63597. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  63598. */
  63599. transform(transformation: DeepImmutable<Matrix>): Plane;
  63600. /**
  63601. * Calcualtte the dot product between the point and the plane normal
  63602. * @param point point to calculate the dot product with
  63603. * @returns the dot product (float) of the point coordinates and the plane normal.
  63604. */
  63605. dotCoordinate(point: DeepImmutable<Vector3>): number;
  63606. /**
  63607. * Updates the current Plane from the plane defined by the three given points.
  63608. * @param point1 one of the points used to contruct the plane
  63609. * @param point2 one of the points used to contruct the plane
  63610. * @param point3 one of the points used to contruct the plane
  63611. * @returns the updated Plane.
  63612. */
  63613. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  63614. /**
  63615. * Checks if the plane is facing a given direction
  63616. * @param direction the direction to check if the plane is facing
  63617. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  63618. * @returns True is the vector "direction" is the same side than the plane normal.
  63619. */
  63620. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  63621. /**
  63622. * Calculates the distance to a point
  63623. * @param point point to calculate distance to
  63624. * @returns the signed distance (float) from the given point to the Plane.
  63625. */
  63626. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  63627. /**
  63628. * Creates a plane from an array
  63629. * @param array the array to create a plane from
  63630. * @returns a new Plane from the given array.
  63631. */
  63632. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  63633. /**
  63634. * Creates a plane from three points
  63635. * @param point1 point used to create the plane
  63636. * @param point2 point used to create the plane
  63637. * @param point3 point used to create the plane
  63638. * @returns a new Plane defined by the three given points.
  63639. */
  63640. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  63641. /**
  63642. * Creates a plane from an origin point and a normal
  63643. * @param origin origin of the plane to be constructed
  63644. * @param normal normal of the plane to be constructed
  63645. * @returns a new Plane the normal vector to this plane at the given origin point.
  63646. * Note : the vector "normal" is updated because normalized.
  63647. */
  63648. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  63649. /**
  63650. * Calculates the distance from a plane and a point
  63651. * @param origin origin of the plane to be constructed
  63652. * @param normal normal of the plane to be constructed
  63653. * @param point point to calculate distance to
  63654. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  63655. */
  63656. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  63657. }
  63658. /**
  63659. * Class used to represent a viewport on screen
  63660. */
  63661. export class Viewport {
  63662. /** viewport left coordinate */
  63663. x: number;
  63664. /** viewport top coordinate */
  63665. y: number;
  63666. /**viewport width */
  63667. width: number;
  63668. /** viewport height */
  63669. height: number;
  63670. /**
  63671. * Creates a Viewport object located at (x, y) and sized (width, height)
  63672. * @param x defines viewport left coordinate
  63673. * @param y defines viewport top coordinate
  63674. * @param width defines the viewport width
  63675. * @param height defines the viewport height
  63676. */
  63677. constructor(
  63678. /** viewport left coordinate */
  63679. x: number,
  63680. /** viewport top coordinate */
  63681. y: number,
  63682. /**viewport width */
  63683. width: number,
  63684. /** viewport height */
  63685. height: number);
  63686. /**
  63687. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  63688. * @param renderWidth defines the rendering width
  63689. * @param renderHeight defines the rendering height
  63690. * @returns a new Viewport
  63691. */
  63692. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  63693. /**
  63694. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  63695. * @param renderWidth defines the rendering width
  63696. * @param renderHeight defines the rendering height
  63697. * @param ref defines the target viewport
  63698. * @returns the current viewport
  63699. */
  63700. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  63701. /**
  63702. * Returns a new Viewport copied from the current one
  63703. * @returns a new Viewport
  63704. */
  63705. clone(): Viewport;
  63706. }
  63707. /**
  63708. * Reprasents a camera frustum
  63709. */
  63710. export class Frustum {
  63711. /**
  63712. * Gets the planes representing the frustum
  63713. * @param transform matrix to be applied to the returned planes
  63714. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  63715. */
  63716. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  63717. /**
  63718. * Gets the near frustum plane transformed by the transform matrix
  63719. * @param transform transformation matrix to be applied to the resulting frustum plane
  63720. * @param frustumPlane the resuling frustum plane
  63721. */
  63722. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63723. /**
  63724. * Gets the far frustum plane transformed by the transform matrix
  63725. * @param transform transformation matrix to be applied to the resulting frustum plane
  63726. * @param frustumPlane the resuling frustum plane
  63727. */
  63728. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63729. /**
  63730. * Gets the left frustum plane transformed by the transform matrix
  63731. * @param transform transformation matrix to be applied to the resulting frustum plane
  63732. * @param frustumPlane the resuling frustum plane
  63733. */
  63734. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63735. /**
  63736. * Gets the right frustum plane transformed by the transform matrix
  63737. * @param transform transformation matrix to be applied to the resulting frustum plane
  63738. * @param frustumPlane the resuling frustum plane
  63739. */
  63740. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63741. /**
  63742. * Gets the top frustum plane transformed by the transform matrix
  63743. * @param transform transformation matrix to be applied to the resulting frustum plane
  63744. * @param frustumPlane the resuling frustum plane
  63745. */
  63746. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63747. /**
  63748. * Gets the bottom frustum plane transformed by the transform matrix
  63749. * @param transform transformation matrix to be applied to the resulting frustum plane
  63750. * @param frustumPlane the resuling frustum plane
  63751. */
  63752. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63753. /**
  63754. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  63755. * @param transform transformation matrix to be applied to the resulting frustum planes
  63756. * @param frustumPlanes the resuling frustum planes
  63757. */
  63758. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  63759. }
  63760. /** Defines supported spaces */
  63761. export enum Space {
  63762. /** Local (object) space */
  63763. LOCAL = 0,
  63764. /** World space */
  63765. WORLD = 1,
  63766. /** Bone space */
  63767. BONE = 2
  63768. }
  63769. /** Defines the 3 main axes */
  63770. export class Axis {
  63771. /** X axis */
  63772. static X: Vector3;
  63773. /** Y axis */
  63774. static Y: Vector3;
  63775. /** Z axis */
  63776. static Z: Vector3;
  63777. }
  63778. /** Class used to represent a Bezier curve */
  63779. export class BezierCurve {
  63780. /**
  63781. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  63782. * @param t defines the time
  63783. * @param x1 defines the left coordinate on X axis
  63784. * @param y1 defines the left coordinate on Y axis
  63785. * @param x2 defines the right coordinate on X axis
  63786. * @param y2 defines the right coordinate on Y axis
  63787. * @returns the interpolated value
  63788. */
  63789. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  63790. }
  63791. /**
  63792. * Defines potential orientation for back face culling
  63793. */
  63794. export enum Orientation {
  63795. /**
  63796. * Clockwise
  63797. */
  63798. CW = 0,
  63799. /** Counter clockwise */
  63800. CCW = 1
  63801. }
  63802. /**
  63803. * Defines angle representation
  63804. */
  63805. export class Angle {
  63806. private _radians;
  63807. /**
  63808. * Creates an Angle object of "radians" radians (float).
  63809. * @param radians the angle in radians
  63810. */
  63811. constructor(radians: number);
  63812. /**
  63813. * Get value in degrees
  63814. * @returns the Angle value in degrees (float)
  63815. */
  63816. degrees(): number;
  63817. /**
  63818. * Get value in radians
  63819. * @returns the Angle value in radians (float)
  63820. */
  63821. radians(): number;
  63822. /**
  63823. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  63824. * @param a defines first vector
  63825. * @param b defines second vector
  63826. * @returns a new Angle
  63827. */
  63828. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  63829. /**
  63830. * Gets a new Angle object from the given float in radians
  63831. * @param radians defines the angle value in radians
  63832. * @returns a new Angle
  63833. */
  63834. static FromRadians(radians: number): Angle;
  63835. /**
  63836. * Gets a new Angle object from the given float in degrees
  63837. * @param degrees defines the angle value in degrees
  63838. * @returns a new Angle
  63839. */
  63840. static FromDegrees(degrees: number): Angle;
  63841. }
  63842. /**
  63843. * This represents an arc in a 2d space.
  63844. */
  63845. export class Arc2 {
  63846. /** Defines the start point of the arc */
  63847. startPoint: Vector2;
  63848. /** Defines the mid point of the arc */
  63849. midPoint: Vector2;
  63850. /** Defines the end point of the arc */
  63851. endPoint: Vector2;
  63852. /**
  63853. * Defines the center point of the arc.
  63854. */
  63855. centerPoint: Vector2;
  63856. /**
  63857. * Defines the radius of the arc.
  63858. */
  63859. radius: number;
  63860. /**
  63861. * Defines the angle of the arc (from mid point to end point).
  63862. */
  63863. angle: Angle;
  63864. /**
  63865. * Defines the start angle of the arc (from start point to middle point).
  63866. */
  63867. startAngle: Angle;
  63868. /**
  63869. * Defines the orientation of the arc (clock wise/counter clock wise).
  63870. */
  63871. orientation: Orientation;
  63872. /**
  63873. * Creates an Arc object from the three given points : start, middle and end.
  63874. * @param startPoint Defines the start point of the arc
  63875. * @param midPoint Defines the midlle point of the arc
  63876. * @param endPoint Defines the end point of the arc
  63877. */
  63878. constructor(
  63879. /** Defines the start point of the arc */
  63880. startPoint: Vector2,
  63881. /** Defines the mid point of the arc */
  63882. midPoint: Vector2,
  63883. /** Defines the end point of the arc */
  63884. endPoint: Vector2);
  63885. }
  63886. /**
  63887. * Represents a 2D path made up of multiple 2D points
  63888. */
  63889. export class Path2 {
  63890. private _points;
  63891. private _length;
  63892. /**
  63893. * If the path start and end point are the same
  63894. */
  63895. closed: boolean;
  63896. /**
  63897. * Creates a Path2 object from the starting 2D coordinates x and y.
  63898. * @param x the starting points x value
  63899. * @param y the starting points y value
  63900. */
  63901. constructor(x: number, y: number);
  63902. /**
  63903. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  63904. * @param x the added points x value
  63905. * @param y the added points y value
  63906. * @returns the updated Path2.
  63907. */
  63908. addLineTo(x: number, y: number): Path2;
  63909. /**
  63910. * 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.
  63911. * @param midX middle point x value
  63912. * @param midY middle point y value
  63913. * @param endX end point x value
  63914. * @param endY end point y value
  63915. * @param numberOfSegments (default: 36)
  63916. * @returns the updated Path2.
  63917. */
  63918. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  63919. /**
  63920. * Closes the Path2.
  63921. * @returns the Path2.
  63922. */
  63923. close(): Path2;
  63924. /**
  63925. * Gets the sum of the distance between each sequential point in the path
  63926. * @returns the Path2 total length (float).
  63927. */
  63928. length(): number;
  63929. /**
  63930. * Gets the points which construct the path
  63931. * @returns the Path2 internal array of points.
  63932. */
  63933. getPoints(): Vector2[];
  63934. /**
  63935. * Retreives the point at the distance aways from the starting point
  63936. * @param normalizedLengthPosition the length along the path to retreive the point from
  63937. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  63938. */
  63939. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  63940. /**
  63941. * Creates a new path starting from an x and y position
  63942. * @param x starting x value
  63943. * @param y starting y value
  63944. * @returns a new Path2 starting at the coordinates (x, y).
  63945. */
  63946. static StartingAt(x: number, y: number): Path2;
  63947. }
  63948. /**
  63949. * Represents a 3D path made up of multiple 3D points
  63950. */
  63951. export class Path3D {
  63952. /**
  63953. * an array of Vector3, the curve axis of the Path3D
  63954. */
  63955. path: Vector3[];
  63956. private _curve;
  63957. private _distances;
  63958. private _tangents;
  63959. private _normals;
  63960. private _binormals;
  63961. private _raw;
  63962. /**
  63963. * new Path3D(path, normal, raw)
  63964. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  63965. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  63966. * @param path an array of Vector3, the curve axis of the Path3D
  63967. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  63968. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  63969. */
  63970. constructor(
  63971. /**
  63972. * an array of Vector3, the curve axis of the Path3D
  63973. */
  63974. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  63975. /**
  63976. * Returns the Path3D array of successive Vector3 designing its curve.
  63977. * @returns the Path3D array of successive Vector3 designing its curve.
  63978. */
  63979. getCurve(): Vector3[];
  63980. /**
  63981. * Returns an array populated with tangent vectors on each Path3D curve point.
  63982. * @returns an array populated with tangent vectors on each Path3D curve point.
  63983. */
  63984. getTangents(): Vector3[];
  63985. /**
  63986. * Returns an array populated with normal vectors on each Path3D curve point.
  63987. * @returns an array populated with normal vectors on each Path3D curve point.
  63988. */
  63989. getNormals(): Vector3[];
  63990. /**
  63991. * Returns an array populated with binormal vectors on each Path3D curve point.
  63992. * @returns an array populated with binormal vectors on each Path3D curve point.
  63993. */
  63994. getBinormals(): Vector3[];
  63995. /**
  63996. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  63997. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  63998. */
  63999. getDistances(): number[];
  64000. /**
  64001. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  64002. * @param path path which all values are copied into the curves points
  64003. * @param firstNormal which should be projected onto the curve
  64004. * @returns the same object updated.
  64005. */
  64006. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  64007. private _compute;
  64008. private _getFirstNonNullVector;
  64009. private _getLastNonNullVector;
  64010. private _normalVector;
  64011. }
  64012. /**
  64013. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  64014. * A Curve3 is designed from a series of successive Vector3.
  64015. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  64016. */
  64017. export class Curve3 {
  64018. private _points;
  64019. private _length;
  64020. /**
  64021. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  64022. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  64023. * @param v1 (Vector3) the control point
  64024. * @param v2 (Vector3) the end point of the Quadratic Bezier
  64025. * @param nbPoints (integer) the wanted number of points in the curve
  64026. * @returns the created Curve3
  64027. */
  64028. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  64029. /**
  64030. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  64031. * @param v0 (Vector3) the origin point of the Cubic Bezier
  64032. * @param v1 (Vector3) the first control point
  64033. * @param v2 (Vector3) the second control point
  64034. * @param v3 (Vector3) the end point of the Cubic Bezier
  64035. * @param nbPoints (integer) the wanted number of points in the curve
  64036. * @returns the created Curve3
  64037. */
  64038. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  64039. /**
  64040. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  64041. * @param p1 (Vector3) the origin point of the Hermite Spline
  64042. * @param t1 (Vector3) the tangent vector at the origin point
  64043. * @param p2 (Vector3) the end point of the Hermite Spline
  64044. * @param t2 (Vector3) the tangent vector at the end point
  64045. * @param nbPoints (integer) the wanted number of points in the curve
  64046. * @returns the created Curve3
  64047. */
  64048. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  64049. /**
  64050. * Returns a Curve3 object along a CatmullRom Spline curve :
  64051. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  64052. * @param nbPoints (integer) the wanted number of points between each curve control points
  64053. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  64054. * @returns the created Curve3
  64055. */
  64056. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  64057. /**
  64058. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  64059. * A Curve3 is designed from a series of successive Vector3.
  64060. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  64061. * @param points points which make up the curve
  64062. */
  64063. constructor(points: Vector3[]);
  64064. /**
  64065. * @returns the Curve3 stored array of successive Vector3
  64066. */
  64067. getPoints(): Vector3[];
  64068. /**
  64069. * @returns the computed length (float) of the curve.
  64070. */
  64071. length(): number;
  64072. /**
  64073. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  64074. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  64075. * curveA and curveB keep unchanged.
  64076. * @param curve the curve to continue from this curve
  64077. * @returns the newly constructed curve
  64078. */
  64079. continue(curve: DeepImmutable<Curve3>): Curve3;
  64080. private _computeLength;
  64081. }
  64082. /**
  64083. * Contains position and normal vectors for a vertex
  64084. */
  64085. export class PositionNormalVertex {
  64086. /** the position of the vertex (defaut: 0,0,0) */
  64087. position: Vector3;
  64088. /** the normal of the vertex (defaut: 0,1,0) */
  64089. normal: Vector3;
  64090. /**
  64091. * Creates a PositionNormalVertex
  64092. * @param position the position of the vertex (defaut: 0,0,0)
  64093. * @param normal the normal of the vertex (defaut: 0,1,0)
  64094. */
  64095. constructor(
  64096. /** the position of the vertex (defaut: 0,0,0) */
  64097. position?: Vector3,
  64098. /** the normal of the vertex (defaut: 0,1,0) */
  64099. normal?: Vector3);
  64100. /**
  64101. * Clones the PositionNormalVertex
  64102. * @returns the cloned PositionNormalVertex
  64103. */
  64104. clone(): PositionNormalVertex;
  64105. }
  64106. /**
  64107. * Contains position, normal and uv vectors for a vertex
  64108. */
  64109. export class PositionNormalTextureVertex {
  64110. /** the position of the vertex (defaut: 0,0,0) */
  64111. position: Vector3;
  64112. /** the normal of the vertex (defaut: 0,1,0) */
  64113. normal: Vector3;
  64114. /** the uv of the vertex (default: 0,0) */
  64115. uv: Vector2;
  64116. /**
  64117. * Creates a PositionNormalTextureVertex
  64118. * @param position the position of the vertex (defaut: 0,0,0)
  64119. * @param normal the normal of the vertex (defaut: 0,1,0)
  64120. * @param uv the uv of the vertex (default: 0,0)
  64121. */
  64122. constructor(
  64123. /** the position of the vertex (defaut: 0,0,0) */
  64124. position?: Vector3,
  64125. /** the normal of the vertex (defaut: 0,1,0) */
  64126. normal?: Vector3,
  64127. /** the uv of the vertex (default: 0,0) */
  64128. uv?: Vector2);
  64129. /**
  64130. * Clones the PositionNormalTextureVertex
  64131. * @returns the cloned PositionNormalTextureVertex
  64132. */
  64133. clone(): PositionNormalTextureVertex;
  64134. }
  64135. /**
  64136. * @hidden
  64137. */
  64138. export class Tmp {
  64139. static Color3: Color3[];
  64140. static Color4: Color4[];
  64141. static Vector2: Vector2[];
  64142. static Vector3: Vector3[];
  64143. static Vector4: Vector4[];
  64144. static Quaternion: Quaternion[];
  64145. static Matrix: Matrix[];
  64146. }
  64147. }
  64148. declare module BABYLON {
  64149. /**
  64150. * Class used to enable access to offline support
  64151. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  64152. */
  64153. export interface IOfflineProvider {
  64154. /**
  64155. * Gets a boolean indicating if scene must be saved in the database
  64156. */
  64157. enableSceneOffline: boolean;
  64158. /**
  64159. * Gets a boolean indicating if textures must be saved in the database
  64160. */
  64161. enableTexturesOffline: boolean;
  64162. /**
  64163. * Open the offline support and make it available
  64164. * @param successCallback defines the callback to call on success
  64165. * @param errorCallback defines the callback to call on error
  64166. */
  64167. open(successCallback: () => void, errorCallback: () => void): void;
  64168. /**
  64169. * Loads an image from the offline support
  64170. * @param url defines the url to load from
  64171. * @param image defines the target DOM image
  64172. */
  64173. loadImage(url: string, image: HTMLImageElement): void;
  64174. /**
  64175. * Loads a file from offline support
  64176. * @param url defines the URL to load from
  64177. * @param sceneLoaded defines a callback to call on success
  64178. * @param progressCallBack defines a callback to call when progress changed
  64179. * @param errorCallback defines a callback to call on error
  64180. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  64181. */
  64182. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  64183. }
  64184. }
  64185. declare module BABYLON {
  64186. /**
  64187. * A class serves as a medium between the observable and its observers
  64188. */
  64189. export class EventState {
  64190. /**
  64191. * Create a new EventState
  64192. * @param mask defines the mask associated with this state
  64193. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  64194. * @param target defines the original target of the state
  64195. * @param currentTarget defines the current target of the state
  64196. */
  64197. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  64198. /**
  64199. * Initialize the current event state
  64200. * @param mask defines the mask associated with this state
  64201. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  64202. * @param target defines the original target of the state
  64203. * @param currentTarget defines the current target of the state
  64204. * @returns the current event state
  64205. */
  64206. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  64207. /**
  64208. * An Observer can set this property to true to prevent subsequent observers of being notified
  64209. */
  64210. skipNextObservers: boolean;
  64211. /**
  64212. * Get the mask value that were used to trigger the event corresponding to this EventState object
  64213. */
  64214. mask: number;
  64215. /**
  64216. * The object that originally notified the event
  64217. */
  64218. target?: any;
  64219. /**
  64220. * The current object in the bubbling phase
  64221. */
  64222. currentTarget?: any;
  64223. /**
  64224. * This will be populated with the return value of the last function that was executed.
  64225. * If it is the first function in the callback chain it will be the event data.
  64226. */
  64227. lastReturnValue?: any;
  64228. }
  64229. /**
  64230. * Represent an Observer registered to a given Observable object.
  64231. */
  64232. export class Observer<T> {
  64233. /**
  64234. * Defines the callback to call when the observer is notified
  64235. */
  64236. callback: (eventData: T, eventState: EventState) => void;
  64237. /**
  64238. * Defines the mask of the observer (used to filter notifications)
  64239. */
  64240. mask: number;
  64241. /**
  64242. * Defines the current scope used to restore the JS context
  64243. */
  64244. scope: any;
  64245. /** @hidden */
  64246. _willBeUnregistered: boolean;
  64247. /**
  64248. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  64249. */
  64250. unregisterOnNextCall: boolean;
  64251. /**
  64252. * Creates a new observer
  64253. * @param callback defines the callback to call when the observer is notified
  64254. * @param mask defines the mask of the observer (used to filter notifications)
  64255. * @param scope defines the current scope used to restore the JS context
  64256. */
  64257. constructor(
  64258. /**
  64259. * Defines the callback to call when the observer is notified
  64260. */
  64261. callback: (eventData: T, eventState: EventState) => void,
  64262. /**
  64263. * Defines the mask of the observer (used to filter notifications)
  64264. */
  64265. mask: number,
  64266. /**
  64267. * Defines the current scope used to restore the JS context
  64268. */
  64269. scope?: any);
  64270. }
  64271. /**
  64272. * Represent a list of observers registered to multiple Observables object.
  64273. */
  64274. export class MultiObserver<T> {
  64275. private _observers;
  64276. private _observables;
  64277. /**
  64278. * Release associated resources
  64279. */
  64280. dispose(): void;
  64281. /**
  64282. * Raise a callback when one of the observable will notify
  64283. * @param observables defines a list of observables to watch
  64284. * @param callback defines the callback to call on notification
  64285. * @param mask defines the mask used to filter notifications
  64286. * @param scope defines the current scope used to restore the JS context
  64287. * @returns the new MultiObserver
  64288. */
  64289. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  64290. }
  64291. /**
  64292. * The Observable class is a simple implementation of the Observable pattern.
  64293. *
  64294. * 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.
  64295. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  64296. * 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).
  64297. * 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.
  64298. */
  64299. export class Observable<T> {
  64300. private _observers;
  64301. private _eventState;
  64302. private _onObserverAdded;
  64303. /**
  64304. * Creates a new observable
  64305. * @param onObserverAdded defines a callback to call when a new observer is added
  64306. */
  64307. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  64308. /**
  64309. * Create a new Observer with the specified callback
  64310. * @param callback the callback that will be executed for that Observer
  64311. * @param mask the mask used to filter observers
  64312. * @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.
  64313. * @param scope optional scope for the callback to be called from
  64314. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  64315. * @returns the new observer created for the callback
  64316. */
  64317. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  64318. /**
  64319. * Create a new Observer with the specified callback and unregisters after the next notification
  64320. * @param callback the callback that will be executed for that Observer
  64321. * @returns the new observer created for the callback
  64322. */
  64323. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  64324. /**
  64325. * Remove an Observer from the Observable object
  64326. * @param observer the instance of the Observer to remove
  64327. * @returns false if it doesn't belong to this Observable
  64328. */
  64329. remove(observer: Nullable<Observer<T>>): boolean;
  64330. /**
  64331. * Remove a callback from the Observable object
  64332. * @param callback the callback to remove
  64333. * @param scope optional scope. If used only the callbacks with this scope will be removed
  64334. * @returns false if it doesn't belong to this Observable
  64335. */
  64336. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  64337. private _deferUnregister;
  64338. private _remove;
  64339. /**
  64340. * Moves the observable to the top of the observer list making it get called first when notified
  64341. * @param observer the observer to move
  64342. */
  64343. makeObserverTopPriority(observer: Observer<T>): void;
  64344. /**
  64345. * Moves the observable to the bottom of the observer list making it get called last when notified
  64346. * @param observer the observer to move
  64347. */
  64348. makeObserverBottomPriority(observer: Observer<T>): void;
  64349. /**
  64350. * Notify all Observers by calling their respective callback with the given data
  64351. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  64352. * @param eventData defines the data to send to all observers
  64353. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  64354. * @param target defines the original target of the state
  64355. * @param currentTarget defines the current target of the state
  64356. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  64357. */
  64358. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  64359. /**
  64360. * Calling this will execute each callback, expecting it to be a promise or return a value.
  64361. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  64362. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  64363. * and it is crucial that all callbacks will be executed.
  64364. * The order of the callbacks is kept, callbacks are not executed parallel.
  64365. *
  64366. * @param eventData The data to be sent to each callback
  64367. * @param mask is used to filter observers defaults to -1
  64368. * @param target defines the callback target (see EventState)
  64369. * @param currentTarget defines he current object in the bubbling phase
  64370. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  64371. */
  64372. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  64373. /**
  64374. * Notify a specific observer
  64375. * @param observer defines the observer to notify
  64376. * @param eventData defines the data to be sent to each callback
  64377. * @param mask is used to filter observers defaults to -1
  64378. */
  64379. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  64380. /**
  64381. * Gets a boolean indicating if the observable has at least one observer
  64382. * @returns true is the Observable has at least one Observer registered
  64383. */
  64384. hasObservers(): boolean;
  64385. /**
  64386. * Clear the list of observers
  64387. */
  64388. clear(): void;
  64389. /**
  64390. * Clone the current observable
  64391. * @returns a new observable
  64392. */
  64393. clone(): Observable<T>;
  64394. /**
  64395. * Does this observable handles observer registered with a given mask
  64396. * @param mask defines the mask to be tested
  64397. * @return whether or not one observer registered with the given mask is handeled
  64398. **/
  64399. hasSpecificMask(mask?: number): boolean;
  64400. }
  64401. }
  64402. declare module BABYLON {
  64403. /**
  64404. * Class used to help managing file picking and drag'n'drop
  64405. * File Storage
  64406. */
  64407. export class FilesInputStore {
  64408. /**
  64409. * List of files ready to be loaded
  64410. */
  64411. static FilesToLoad: {
  64412. [key: string]: File;
  64413. };
  64414. }
  64415. }
  64416. declare module BABYLON {
  64417. /** Defines the cross module used constants to avoid circular dependncies */
  64418. export class Constants {
  64419. /** Defines that alpha blending is disabled */
  64420. static readonly ALPHA_DISABLE: number;
  64421. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  64422. static readonly ALPHA_ADD: number;
  64423. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  64424. static readonly ALPHA_COMBINE: number;
  64425. /** Defines that alpha blending to DEST - SRC * DEST */
  64426. static readonly ALPHA_SUBTRACT: number;
  64427. /** Defines that alpha blending to SRC * DEST */
  64428. static readonly ALPHA_MULTIPLY: number;
  64429. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  64430. static readonly ALPHA_MAXIMIZED: number;
  64431. /** Defines that alpha blending to SRC + DEST */
  64432. static readonly ALPHA_ONEONE: number;
  64433. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  64434. static readonly ALPHA_PREMULTIPLIED: number;
  64435. /**
  64436. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  64437. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  64438. */
  64439. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  64440. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  64441. static readonly ALPHA_INTERPOLATE: number;
  64442. /**
  64443. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  64444. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  64445. */
  64446. static readonly ALPHA_SCREENMODE: number;
  64447. /** Defines that the ressource is not delayed*/
  64448. static readonly DELAYLOADSTATE_NONE: number;
  64449. /** Defines that the ressource was successfully delay loaded */
  64450. static readonly DELAYLOADSTATE_LOADED: number;
  64451. /** Defines that the ressource is currently delay loading */
  64452. static readonly DELAYLOADSTATE_LOADING: number;
  64453. /** Defines that the ressource is delayed and has not started loading */
  64454. static readonly DELAYLOADSTATE_NOTLOADED: number;
  64455. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  64456. static readonly NEVER: number;
  64457. /** 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 */
  64458. static readonly ALWAYS: number;
  64459. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  64460. static readonly LESS: number;
  64461. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  64462. static readonly EQUAL: number;
  64463. /** 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 */
  64464. static readonly LEQUAL: number;
  64465. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  64466. static readonly GREATER: number;
  64467. /** 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 */
  64468. static readonly GEQUAL: number;
  64469. /** 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 */
  64470. static readonly NOTEQUAL: number;
  64471. /** Passed to stencilOperation to specify that stencil value must be kept */
  64472. static readonly KEEP: number;
  64473. /** Passed to stencilOperation to specify that stencil value must be replaced */
  64474. static readonly REPLACE: number;
  64475. /** Passed to stencilOperation to specify that stencil value must be incremented */
  64476. static readonly INCR: number;
  64477. /** Passed to stencilOperation to specify that stencil value must be decremented */
  64478. static readonly DECR: number;
  64479. /** Passed to stencilOperation to specify that stencil value must be inverted */
  64480. static readonly INVERT: number;
  64481. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  64482. static readonly INCR_WRAP: number;
  64483. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  64484. static readonly DECR_WRAP: number;
  64485. /** Texture is not repeating outside of 0..1 UVs */
  64486. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  64487. /** Texture is repeating outside of 0..1 UVs */
  64488. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  64489. /** Texture is repeating and mirrored */
  64490. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  64491. /** ALPHA */
  64492. static readonly TEXTUREFORMAT_ALPHA: number;
  64493. /** LUMINANCE */
  64494. static readonly TEXTUREFORMAT_LUMINANCE: number;
  64495. /** LUMINANCE_ALPHA */
  64496. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  64497. /** RGB */
  64498. static readonly TEXTUREFORMAT_RGB: number;
  64499. /** RGBA */
  64500. static readonly TEXTUREFORMAT_RGBA: number;
  64501. /** RED */
  64502. static readonly TEXTUREFORMAT_RED: number;
  64503. /** RED (2nd reference) */
  64504. static readonly TEXTUREFORMAT_R: number;
  64505. /** RG */
  64506. static readonly TEXTUREFORMAT_RG: number;
  64507. /** RED_INTEGER */
  64508. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  64509. /** RED_INTEGER (2nd reference) */
  64510. static readonly TEXTUREFORMAT_R_INTEGER: number;
  64511. /** RG_INTEGER */
  64512. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  64513. /** RGB_INTEGER */
  64514. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  64515. /** RGBA_INTEGER */
  64516. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  64517. /** UNSIGNED_BYTE */
  64518. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  64519. /** UNSIGNED_BYTE (2nd reference) */
  64520. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  64521. /** FLOAT */
  64522. static readonly TEXTURETYPE_FLOAT: number;
  64523. /** HALF_FLOAT */
  64524. static readonly TEXTURETYPE_HALF_FLOAT: number;
  64525. /** BYTE */
  64526. static readonly TEXTURETYPE_BYTE: number;
  64527. /** SHORT */
  64528. static readonly TEXTURETYPE_SHORT: number;
  64529. /** UNSIGNED_SHORT */
  64530. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  64531. /** INT */
  64532. static readonly TEXTURETYPE_INT: number;
  64533. /** UNSIGNED_INT */
  64534. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  64535. /** UNSIGNED_SHORT_4_4_4_4 */
  64536. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  64537. /** UNSIGNED_SHORT_5_5_5_1 */
  64538. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  64539. /** UNSIGNED_SHORT_5_6_5 */
  64540. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  64541. /** UNSIGNED_INT_2_10_10_10_REV */
  64542. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  64543. /** UNSIGNED_INT_24_8 */
  64544. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  64545. /** UNSIGNED_INT_10F_11F_11F_REV */
  64546. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  64547. /** UNSIGNED_INT_5_9_9_9_REV */
  64548. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  64549. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  64550. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  64551. /** nearest is mag = nearest and min = nearest and mip = linear */
  64552. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  64553. /** Bilinear is mag = linear and min = linear and mip = nearest */
  64554. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  64555. /** Trilinear is mag = linear and min = linear and mip = linear */
  64556. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  64557. /** nearest is mag = nearest and min = nearest and mip = linear */
  64558. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  64559. /** Bilinear is mag = linear and min = linear and mip = nearest */
  64560. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  64561. /** Trilinear is mag = linear and min = linear and mip = linear */
  64562. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  64563. /** mag = nearest and min = nearest and mip = nearest */
  64564. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  64565. /** mag = nearest and min = linear and mip = nearest */
  64566. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  64567. /** mag = nearest and min = linear and mip = linear */
  64568. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  64569. /** mag = nearest and min = linear and mip = none */
  64570. static readonly TEXTURE_NEAREST_LINEAR: number;
  64571. /** mag = nearest and min = nearest and mip = none */
  64572. static readonly TEXTURE_NEAREST_NEAREST: number;
  64573. /** mag = linear and min = nearest and mip = nearest */
  64574. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  64575. /** mag = linear and min = nearest and mip = linear */
  64576. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  64577. /** mag = linear and min = linear and mip = none */
  64578. static readonly TEXTURE_LINEAR_LINEAR: number;
  64579. /** mag = linear and min = nearest and mip = none */
  64580. static readonly TEXTURE_LINEAR_NEAREST: number;
  64581. /** Explicit coordinates mode */
  64582. static readonly TEXTURE_EXPLICIT_MODE: number;
  64583. /** Spherical coordinates mode */
  64584. static readonly TEXTURE_SPHERICAL_MODE: number;
  64585. /** Planar coordinates mode */
  64586. static readonly TEXTURE_PLANAR_MODE: number;
  64587. /** Cubic coordinates mode */
  64588. static readonly TEXTURE_CUBIC_MODE: number;
  64589. /** Projection coordinates mode */
  64590. static readonly TEXTURE_PROJECTION_MODE: number;
  64591. /** Skybox coordinates mode */
  64592. static readonly TEXTURE_SKYBOX_MODE: number;
  64593. /** Inverse Cubic coordinates mode */
  64594. static readonly TEXTURE_INVCUBIC_MODE: number;
  64595. /** Equirectangular coordinates mode */
  64596. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  64597. /** Equirectangular Fixed coordinates mode */
  64598. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  64599. /** Equirectangular Fixed Mirrored coordinates mode */
  64600. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  64601. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  64602. static readonly SCALEMODE_FLOOR: number;
  64603. /** Defines that texture rescaling will look for the nearest power of 2 size */
  64604. static readonly SCALEMODE_NEAREST: number;
  64605. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  64606. static readonly SCALEMODE_CEILING: number;
  64607. /**
  64608. * The dirty texture flag value
  64609. */
  64610. static readonly MATERIAL_TextureDirtyFlag: number;
  64611. /**
  64612. * The dirty light flag value
  64613. */
  64614. static readonly MATERIAL_LightDirtyFlag: number;
  64615. /**
  64616. * The dirty fresnel flag value
  64617. */
  64618. static readonly MATERIAL_FresnelDirtyFlag: number;
  64619. /**
  64620. * The dirty attribute flag value
  64621. */
  64622. static readonly MATERIAL_AttributesDirtyFlag: number;
  64623. /**
  64624. * The dirty misc flag value
  64625. */
  64626. static readonly MATERIAL_MiscDirtyFlag: number;
  64627. /**
  64628. * The all dirty flag value
  64629. */
  64630. static readonly MATERIAL_AllDirtyFlag: number;
  64631. /**
  64632. * Returns the triangle fill mode
  64633. */
  64634. static readonly MATERIAL_TriangleFillMode: number;
  64635. /**
  64636. * Returns the wireframe mode
  64637. */
  64638. static readonly MATERIAL_WireFrameFillMode: number;
  64639. /**
  64640. * Returns the point fill mode
  64641. */
  64642. static readonly MATERIAL_PointFillMode: number;
  64643. /**
  64644. * Returns the point list draw mode
  64645. */
  64646. static readonly MATERIAL_PointListDrawMode: number;
  64647. /**
  64648. * Returns the line list draw mode
  64649. */
  64650. static readonly MATERIAL_LineListDrawMode: number;
  64651. /**
  64652. * Returns the line loop draw mode
  64653. */
  64654. static readonly MATERIAL_LineLoopDrawMode: number;
  64655. /**
  64656. * Returns the line strip draw mode
  64657. */
  64658. static readonly MATERIAL_LineStripDrawMode: number;
  64659. /**
  64660. * Returns the triangle strip draw mode
  64661. */
  64662. static readonly MATERIAL_TriangleStripDrawMode: number;
  64663. /**
  64664. * Returns the triangle fan draw mode
  64665. */
  64666. static readonly MATERIAL_TriangleFanDrawMode: number;
  64667. /**
  64668. * Stores the clock-wise side orientation
  64669. */
  64670. static readonly MATERIAL_ClockWiseSideOrientation: number;
  64671. /**
  64672. * Stores the counter clock-wise side orientation
  64673. */
  64674. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  64675. /**
  64676. * Nothing
  64677. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64678. */
  64679. static readonly ACTION_NothingTrigger: number;
  64680. /**
  64681. * On pick
  64682. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64683. */
  64684. static readonly ACTION_OnPickTrigger: number;
  64685. /**
  64686. * On left pick
  64687. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64688. */
  64689. static readonly ACTION_OnLeftPickTrigger: number;
  64690. /**
  64691. * On right pick
  64692. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64693. */
  64694. static readonly ACTION_OnRightPickTrigger: number;
  64695. /**
  64696. * On center pick
  64697. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64698. */
  64699. static readonly ACTION_OnCenterPickTrigger: number;
  64700. /**
  64701. * On pick down
  64702. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64703. */
  64704. static readonly ACTION_OnPickDownTrigger: number;
  64705. /**
  64706. * On double pick
  64707. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64708. */
  64709. static readonly ACTION_OnDoublePickTrigger: number;
  64710. /**
  64711. * On pick up
  64712. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64713. */
  64714. static readonly ACTION_OnPickUpTrigger: number;
  64715. /**
  64716. * On pick out.
  64717. * This trigger will only be raised if you also declared a OnPickDown
  64718. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64719. */
  64720. static readonly ACTION_OnPickOutTrigger: number;
  64721. /**
  64722. * On long press
  64723. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64724. */
  64725. static readonly ACTION_OnLongPressTrigger: number;
  64726. /**
  64727. * On pointer over
  64728. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64729. */
  64730. static readonly ACTION_OnPointerOverTrigger: number;
  64731. /**
  64732. * On pointer out
  64733. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64734. */
  64735. static readonly ACTION_OnPointerOutTrigger: number;
  64736. /**
  64737. * On every frame
  64738. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64739. */
  64740. static readonly ACTION_OnEveryFrameTrigger: number;
  64741. /**
  64742. * On intersection enter
  64743. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64744. */
  64745. static readonly ACTION_OnIntersectionEnterTrigger: number;
  64746. /**
  64747. * On intersection exit
  64748. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64749. */
  64750. static readonly ACTION_OnIntersectionExitTrigger: number;
  64751. /**
  64752. * On key down
  64753. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64754. */
  64755. static readonly ACTION_OnKeyDownTrigger: number;
  64756. /**
  64757. * On key up
  64758. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64759. */
  64760. static readonly ACTION_OnKeyUpTrigger: number;
  64761. /**
  64762. * Billboard mode will only apply to Y axis
  64763. */
  64764. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  64765. /**
  64766. * Billboard mode will apply to all axes
  64767. */
  64768. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  64769. /**
  64770. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  64771. */
  64772. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  64773. /**
  64774. * Gets or sets base Assets URL
  64775. */
  64776. static readonly PARTICLES_BaseAssetsUrl: string;
  64777. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  64778. * Test order :
  64779. * Is the bounding sphere outside the frustum ?
  64780. * If not, are the bounding box vertices outside the frustum ?
  64781. * It not, then the cullable object is in the frustum.
  64782. */
  64783. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  64784. /** Culling strategy : Bounding Sphere Only.
  64785. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  64786. * It's also less accurate than the standard because some not visible objects can still be selected.
  64787. * Test : is the bounding sphere outside the frustum ?
  64788. * If not, then the cullable object is in the frustum.
  64789. */
  64790. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  64791. /** Culling strategy : Optimistic Inclusion.
  64792. * This in an inclusion test first, then the standard exclusion test.
  64793. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  64794. * 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.
  64795. * Anyway, it's as accurate as the standard strategy.
  64796. * Test :
  64797. * Is the cullable object bounding sphere center in the frustum ?
  64798. * If not, apply the default culling strategy.
  64799. */
  64800. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  64801. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  64802. * This in an inclusion test first, then the bounding sphere only exclusion test.
  64803. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  64804. * 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.
  64805. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  64806. * Test :
  64807. * Is the cullable object bounding sphere center in the frustum ?
  64808. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  64809. */
  64810. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  64811. /**
  64812. * No logging while loading
  64813. */
  64814. static readonly SCENELOADER_NO_LOGGING: number;
  64815. /**
  64816. * Minimal logging while loading
  64817. */
  64818. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  64819. /**
  64820. * Summary logging while loading
  64821. */
  64822. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  64823. /**
  64824. * Detailled logging while loading
  64825. */
  64826. static readonly SCENELOADER_DETAILED_LOGGING: number;
  64827. }
  64828. }
  64829. declare module BABYLON {
  64830. /**
  64831. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  64832. * Babylon.js
  64833. */
  64834. export class DomManagement {
  64835. /**
  64836. * Checks if the window object exists
  64837. * @returns true if the window object exists
  64838. */
  64839. static IsWindowObjectExist(): boolean;
  64840. /**
  64841. * Extracts text content from a DOM element hierarchy
  64842. * @param element defines the root element
  64843. * @returns a string
  64844. */
  64845. static GetDOMTextContent(element: HTMLElement): string;
  64846. }
  64847. }
  64848. declare module BABYLON {
  64849. /**
  64850. * Logger used througouht the application to allow configuration of
  64851. * the log level required for the messages.
  64852. */
  64853. export class Logger {
  64854. /**
  64855. * No log
  64856. */
  64857. static readonly NoneLogLevel: number;
  64858. /**
  64859. * Only message logs
  64860. */
  64861. static readonly MessageLogLevel: number;
  64862. /**
  64863. * Only warning logs
  64864. */
  64865. static readonly WarningLogLevel: number;
  64866. /**
  64867. * Only error logs
  64868. */
  64869. static readonly ErrorLogLevel: number;
  64870. /**
  64871. * All logs
  64872. */
  64873. static readonly AllLogLevel: number;
  64874. private static _LogCache;
  64875. /**
  64876. * Gets a value indicating the number of loading errors
  64877. * @ignorenaming
  64878. */
  64879. static errorsCount: number;
  64880. /**
  64881. * Callback called when a new log is added
  64882. */
  64883. static OnNewCacheEntry: (entry: string) => void;
  64884. private static _AddLogEntry;
  64885. private static _FormatMessage;
  64886. private static _LogDisabled;
  64887. private static _LogEnabled;
  64888. private static _WarnDisabled;
  64889. private static _WarnEnabled;
  64890. private static _ErrorDisabled;
  64891. private static _ErrorEnabled;
  64892. /**
  64893. * Log a message to the console
  64894. */
  64895. static Log: (message: string) => void;
  64896. /**
  64897. * Write a warning message to the console
  64898. */
  64899. static Warn: (message: string) => void;
  64900. /**
  64901. * Write an error message to the console
  64902. */
  64903. static Error: (message: string) => void;
  64904. /**
  64905. * Gets current log cache (list of logs)
  64906. */
  64907. static readonly LogCache: string;
  64908. /**
  64909. * Clears the log cache
  64910. */
  64911. static ClearLogCache(): void;
  64912. /**
  64913. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  64914. */
  64915. static LogLevels: number;
  64916. }
  64917. }
  64918. declare module BABYLON {
  64919. /** @hidden */
  64920. export class _TypeStore {
  64921. /** @hidden */
  64922. static RegisteredTypes: {
  64923. [key: string]: Object;
  64924. };
  64925. /** @hidden */
  64926. static GetClass(fqdn: string): any;
  64927. }
  64928. }
  64929. declare module BABYLON {
  64930. /**
  64931. * Class containing a set of static utilities functions for deep copy.
  64932. */
  64933. export class DeepCopier {
  64934. /**
  64935. * Tries to copy an object by duplicating every property
  64936. * @param source defines the source object
  64937. * @param destination defines the target object
  64938. * @param doNotCopyList defines a list of properties to avoid
  64939. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  64940. */
  64941. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  64942. }
  64943. }
  64944. declare module BABYLON {
  64945. /**
  64946. * Class containing a set of static utilities functions for precision date
  64947. */
  64948. export class PrecisionDate {
  64949. /**
  64950. * Gets either window.performance.now() if supported or Date.now() else
  64951. */
  64952. static readonly Now: number;
  64953. }
  64954. }
  64955. declare module BABYLON {
  64956. /** @hidden */
  64957. export class _DevTools {
  64958. static WarnImport(name: string): string;
  64959. }
  64960. }
  64961. declare module BABYLON {
  64962. /**
  64963. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  64964. */
  64965. export class WebRequest {
  64966. private _xhr;
  64967. /**
  64968. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  64969. * i.e. when loading files, where the server/service expects an Authorization header
  64970. */
  64971. static CustomRequestHeaders: {
  64972. [key: string]: string;
  64973. };
  64974. /**
  64975. * Add callback functions in this array to update all the requests before they get sent to the network
  64976. */
  64977. static CustomRequestModifiers: ((request: XMLHttpRequest) => void)[];
  64978. private _injectCustomRequestHeaders;
  64979. /**
  64980. * Gets or sets a function to be called when loading progress changes
  64981. */
  64982. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  64983. /**
  64984. * Returns client's state
  64985. */
  64986. readonly readyState: number;
  64987. /**
  64988. * Returns client's status
  64989. */
  64990. readonly status: number;
  64991. /**
  64992. * Returns client's status as a text
  64993. */
  64994. readonly statusText: string;
  64995. /**
  64996. * Returns client's response
  64997. */
  64998. readonly response: any;
  64999. /**
  65000. * Returns client's response url
  65001. */
  65002. readonly responseURL: string;
  65003. /**
  65004. * Returns client's response as text
  65005. */
  65006. readonly responseText: string;
  65007. /**
  65008. * Gets or sets the expected response type
  65009. */
  65010. responseType: XMLHttpRequestResponseType;
  65011. /** @hidden */
  65012. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  65013. /** @hidden */
  65014. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  65015. /**
  65016. * Cancels any network activity
  65017. */
  65018. abort(): void;
  65019. /**
  65020. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  65021. * @param body defines an optional request body
  65022. */
  65023. send(body?: Document | BodyInit | null): void;
  65024. /**
  65025. * Sets the request method, request URL
  65026. * @param method defines the method to use (GET, POST, etc..)
  65027. * @param url defines the url to connect with
  65028. */
  65029. open(method: string, url: string): void;
  65030. }
  65031. }
  65032. declare module BABYLON {
  65033. /**
  65034. * Class used to evalaute queries containing `and` and `or` operators
  65035. */
  65036. export class AndOrNotEvaluator {
  65037. /**
  65038. * Evaluate a query
  65039. * @param query defines the query to evaluate
  65040. * @param evaluateCallback defines the callback used to filter result
  65041. * @returns true if the query matches
  65042. */
  65043. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  65044. private static _HandleParenthesisContent;
  65045. private static _SimplifyNegation;
  65046. }
  65047. }
  65048. declare module BABYLON {
  65049. /**
  65050. * Class used to store custom tags
  65051. */
  65052. export class Tags {
  65053. /**
  65054. * Adds support for tags on the given object
  65055. * @param obj defines the object to use
  65056. */
  65057. static EnableFor(obj: any): void;
  65058. /**
  65059. * Removes tags support
  65060. * @param obj defines the object to use
  65061. */
  65062. static DisableFor(obj: any): void;
  65063. /**
  65064. * Gets a boolean indicating if the given object has tags
  65065. * @param obj defines the object to use
  65066. * @returns a boolean
  65067. */
  65068. static HasTags(obj: any): boolean;
  65069. /**
  65070. * Gets the tags available on a given object
  65071. * @param obj defines the object to use
  65072. * @param asString defines if the tags must be returned as a string instead of an array of strings
  65073. * @returns the tags
  65074. */
  65075. static GetTags(obj: any, asString?: boolean): any;
  65076. /**
  65077. * Adds tags to an object
  65078. * @param obj defines the object to use
  65079. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  65080. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  65081. */
  65082. static AddTagsTo(obj: any, tagsString: string): void;
  65083. /**
  65084. * @hidden
  65085. */
  65086. static _AddTagTo(obj: any, tag: string): void;
  65087. /**
  65088. * Removes specific tags from a specific object
  65089. * @param obj defines the object to use
  65090. * @param tagsString defines the tags to remove
  65091. */
  65092. static RemoveTagsFrom(obj: any, tagsString: string): void;
  65093. /**
  65094. * @hidden
  65095. */
  65096. static _RemoveTagFrom(obj: any, tag: string): void;
  65097. /**
  65098. * Defines if tags hosted on an object match a given query
  65099. * @param obj defines the object to use
  65100. * @param tagsQuery defines the tag query
  65101. * @returns a boolean
  65102. */
  65103. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  65104. }
  65105. }
  65106. declare module BABYLON {
  65107. /**
  65108. * Manages the defines for the Material
  65109. */
  65110. export class MaterialDefines {
  65111. private _keys;
  65112. private _isDirty;
  65113. /** @hidden */
  65114. _renderId: number;
  65115. /** @hidden */
  65116. _areLightsDirty: boolean;
  65117. /** @hidden */
  65118. _areAttributesDirty: boolean;
  65119. /** @hidden */
  65120. _areTexturesDirty: boolean;
  65121. /** @hidden */
  65122. _areFresnelDirty: boolean;
  65123. /** @hidden */
  65124. _areMiscDirty: boolean;
  65125. /** @hidden */
  65126. _areImageProcessingDirty: boolean;
  65127. /** @hidden */
  65128. _normals: boolean;
  65129. /** @hidden */
  65130. _uvs: boolean;
  65131. /** @hidden */
  65132. _needNormals: boolean;
  65133. /** @hidden */
  65134. _needUVs: boolean;
  65135. /**
  65136. * Specifies if the material needs to be re-calculated
  65137. */
  65138. readonly isDirty: boolean;
  65139. /**
  65140. * Marks the material to indicate that it has been re-calculated
  65141. */
  65142. markAsProcessed(): void;
  65143. /**
  65144. * Marks the material to indicate that it needs to be re-calculated
  65145. */
  65146. markAsUnprocessed(): void;
  65147. /**
  65148. * Marks the material to indicate all of its defines need to be re-calculated
  65149. */
  65150. markAllAsDirty(): void;
  65151. /**
  65152. * Marks the material to indicate that image processing needs to be re-calculated
  65153. */
  65154. markAsImageProcessingDirty(): void;
  65155. /**
  65156. * Marks the material to indicate the lights need to be re-calculated
  65157. */
  65158. markAsLightDirty(): void;
  65159. /**
  65160. * Marks the attribute state as changed
  65161. */
  65162. markAsAttributesDirty(): void;
  65163. /**
  65164. * Marks the texture state as changed
  65165. */
  65166. markAsTexturesDirty(): void;
  65167. /**
  65168. * Marks the fresnel state as changed
  65169. */
  65170. markAsFresnelDirty(): void;
  65171. /**
  65172. * Marks the misc state as changed
  65173. */
  65174. markAsMiscDirty(): void;
  65175. /**
  65176. * Rebuilds the material defines
  65177. */
  65178. rebuild(): void;
  65179. /**
  65180. * Specifies if two material defines are equal
  65181. * @param other - A material define instance to compare to
  65182. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  65183. */
  65184. isEqual(other: MaterialDefines): boolean;
  65185. /**
  65186. * Clones this instance's defines to another instance
  65187. * @param other - material defines to clone values to
  65188. */
  65189. cloneTo(other: MaterialDefines): void;
  65190. /**
  65191. * Resets the material define values
  65192. */
  65193. reset(): void;
  65194. /**
  65195. * Converts the material define values to a string
  65196. * @returns - String of material define information
  65197. */
  65198. toString(): string;
  65199. }
  65200. }
  65201. declare module BABYLON {
  65202. /**
  65203. * Class used to store and describe the pipeline context associated with an effect
  65204. */
  65205. export interface IPipelineContext {
  65206. /**
  65207. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  65208. */
  65209. isAsync: boolean;
  65210. /**
  65211. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  65212. */
  65213. isReady: boolean;
  65214. /** @hidden */
  65215. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  65216. }
  65217. }
  65218. declare module BABYLON {
  65219. /**
  65220. * Class used to store gfx data (like WebGLBuffer)
  65221. */
  65222. export class DataBuffer {
  65223. /**
  65224. * Gets or sets the number of objects referencing this buffer
  65225. */
  65226. references: number;
  65227. /** Gets or sets the size of the underlying buffer */
  65228. capacity: number;
  65229. /**
  65230. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  65231. */
  65232. is32Bits: boolean;
  65233. /**
  65234. * Gets the underlying buffer
  65235. */
  65236. readonly underlyingResource: any;
  65237. }
  65238. }
  65239. declare module BABYLON {
  65240. /**
  65241. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  65242. */
  65243. export class PerformanceMonitor {
  65244. private _enabled;
  65245. private _rollingFrameTime;
  65246. private _lastFrameTimeMs;
  65247. /**
  65248. * constructor
  65249. * @param frameSampleSize The number of samples required to saturate the sliding window
  65250. */
  65251. constructor(frameSampleSize?: number);
  65252. /**
  65253. * Samples current frame
  65254. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  65255. */
  65256. sampleFrame(timeMs?: number): void;
  65257. /**
  65258. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  65259. */
  65260. readonly averageFrameTime: number;
  65261. /**
  65262. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  65263. */
  65264. readonly averageFrameTimeVariance: number;
  65265. /**
  65266. * Returns the frame time of the most recent frame
  65267. */
  65268. readonly instantaneousFrameTime: number;
  65269. /**
  65270. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  65271. */
  65272. readonly averageFPS: number;
  65273. /**
  65274. * Returns the average framerate in frames per second using the most recent frame time
  65275. */
  65276. readonly instantaneousFPS: number;
  65277. /**
  65278. * Returns true if enough samples have been taken to completely fill the sliding window
  65279. */
  65280. readonly isSaturated: boolean;
  65281. /**
  65282. * Enables contributions to the sliding window sample set
  65283. */
  65284. enable(): void;
  65285. /**
  65286. * Disables contributions to the sliding window sample set
  65287. * Samples will not be interpolated over the disabled period
  65288. */
  65289. disable(): void;
  65290. /**
  65291. * Returns true if sampling is enabled
  65292. */
  65293. readonly isEnabled: boolean;
  65294. /**
  65295. * Resets performance monitor
  65296. */
  65297. reset(): void;
  65298. }
  65299. /**
  65300. * RollingAverage
  65301. *
  65302. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  65303. */
  65304. export class RollingAverage {
  65305. /**
  65306. * Current average
  65307. */
  65308. average: number;
  65309. /**
  65310. * Current variance
  65311. */
  65312. variance: number;
  65313. protected _samples: Array<number>;
  65314. protected _sampleCount: number;
  65315. protected _pos: number;
  65316. protected _m2: number;
  65317. /**
  65318. * constructor
  65319. * @param length The number of samples required to saturate the sliding window
  65320. */
  65321. constructor(length: number);
  65322. /**
  65323. * Adds a sample to the sample set
  65324. * @param v The sample value
  65325. */
  65326. add(v: number): void;
  65327. /**
  65328. * Returns previously added values or null if outside of history or outside the sliding window domain
  65329. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  65330. * @return Value previously recorded with add() or null if outside of range
  65331. */
  65332. history(i: number): number;
  65333. /**
  65334. * Returns true if enough samples have been taken to completely fill the sliding window
  65335. * @return true if sample-set saturated
  65336. */
  65337. isSaturated(): boolean;
  65338. /**
  65339. * Resets the rolling average (equivalent to 0 samples taken so far)
  65340. */
  65341. reset(): void;
  65342. /**
  65343. * Wraps a value around the sample range boundaries
  65344. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  65345. * @return Wrapped position in sample range
  65346. */
  65347. protected _wrapPosition(i: number): number;
  65348. }
  65349. }
  65350. declare module BABYLON {
  65351. /**
  65352. * This class implement a typical dictionary using a string as key and the generic type T as value.
  65353. * The underlying implementation relies on an associative array to ensure the best performances.
  65354. * The value can be anything including 'null' but except 'undefined'
  65355. */
  65356. export class StringDictionary<T> {
  65357. /**
  65358. * This will clear this dictionary and copy the content from the 'source' one.
  65359. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  65360. * @param source the dictionary to take the content from and copy to this dictionary
  65361. */
  65362. copyFrom(source: StringDictionary<T>): void;
  65363. /**
  65364. * Get a value based from its key
  65365. * @param key the given key to get the matching value from
  65366. * @return the value if found, otherwise undefined is returned
  65367. */
  65368. get(key: string): T | undefined;
  65369. /**
  65370. * Get a value from its key or add it if it doesn't exist.
  65371. * This method will ensure you that a given key/data will be present in the dictionary.
  65372. * @param key the given key to get the matching value from
  65373. * @param factory the factory that will create the value if the key is not present in the dictionary.
  65374. * The factory will only be invoked if there's no data for the given key.
  65375. * @return the value corresponding to the key.
  65376. */
  65377. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  65378. /**
  65379. * Get a value from its key if present in the dictionary otherwise add it
  65380. * @param key the key to get the value from
  65381. * @param val if there's no such key/value pair in the dictionary add it with this value
  65382. * @return the value corresponding to the key
  65383. */
  65384. getOrAdd(key: string, val: T): T;
  65385. /**
  65386. * Check if there's a given key in the dictionary
  65387. * @param key the key to check for
  65388. * @return true if the key is present, false otherwise
  65389. */
  65390. contains(key: string): boolean;
  65391. /**
  65392. * Add a new key and its corresponding value
  65393. * @param key the key to add
  65394. * @param value the value corresponding to the key
  65395. * @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
  65396. */
  65397. add(key: string, value: T): boolean;
  65398. /**
  65399. * Update a specific value associated to a key
  65400. * @param key defines the key to use
  65401. * @param value defines the value to store
  65402. * @returns true if the value was updated (or false if the key was not found)
  65403. */
  65404. set(key: string, value: T): boolean;
  65405. /**
  65406. * Get the element of the given key and remove it from the dictionary
  65407. * @param key defines the key to search
  65408. * @returns the value associated with the key or null if not found
  65409. */
  65410. getAndRemove(key: string): Nullable<T>;
  65411. /**
  65412. * Remove a key/value from the dictionary.
  65413. * @param key the key to remove
  65414. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  65415. */
  65416. remove(key: string): boolean;
  65417. /**
  65418. * Clear the whole content of the dictionary
  65419. */
  65420. clear(): void;
  65421. /**
  65422. * Gets the current count
  65423. */
  65424. readonly count: number;
  65425. /**
  65426. * Execute a callback on each key/val of the dictionary.
  65427. * Note that you can remove any element in this dictionary in the callback implementation
  65428. * @param callback the callback to execute on a given key/value pair
  65429. */
  65430. forEach(callback: (key: string, val: T) => void): void;
  65431. /**
  65432. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  65433. * If the callback returns null or undefined the method will iterate to the next key/value pair
  65434. * Note that you can remove any element in this dictionary in the callback implementation
  65435. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  65436. * @returns the first item
  65437. */
  65438. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  65439. private _count;
  65440. private _data;
  65441. }
  65442. }
  65443. declare module BABYLON {
  65444. /**
  65445. * Helper class that provides a small promise polyfill
  65446. */
  65447. export class PromisePolyfill {
  65448. /**
  65449. * Static function used to check if the polyfill is required
  65450. * If this is the case then the function will inject the polyfill to window.Promise
  65451. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  65452. */
  65453. static Apply(force?: boolean): void;
  65454. }
  65455. }
  65456. declare module BABYLON {
  65457. /**
  65458. * Class used to store data that will be store in GPU memory
  65459. */
  65460. export class Buffer {
  65461. private _engine;
  65462. private _buffer;
  65463. /** @hidden */
  65464. _data: Nullable<DataArray>;
  65465. private _updatable;
  65466. private _instanced;
  65467. /**
  65468. * Gets the byte stride.
  65469. */
  65470. readonly byteStride: number;
  65471. /**
  65472. * Constructor
  65473. * @param engine the engine
  65474. * @param data the data to use for this buffer
  65475. * @param updatable whether the data is updatable
  65476. * @param stride the stride (optional)
  65477. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  65478. * @param instanced whether the buffer is instanced (optional)
  65479. * @param useBytes set to true if the stride in in bytes (optional)
  65480. */
  65481. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  65482. /**
  65483. * Create a new VertexBuffer based on the current buffer
  65484. * @param kind defines the vertex buffer kind (position, normal, etc.)
  65485. * @param offset defines offset in the buffer (0 by default)
  65486. * @param size defines the size in floats of attributes (position is 3 for instance)
  65487. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  65488. * @param instanced defines if the vertex buffer contains indexed data
  65489. * @param useBytes defines if the offset and stride are in bytes
  65490. * @returns the new vertex buffer
  65491. */
  65492. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  65493. /**
  65494. * Gets a boolean indicating if the Buffer is updatable?
  65495. * @returns true if the buffer is updatable
  65496. */
  65497. isUpdatable(): boolean;
  65498. /**
  65499. * Gets current buffer's data
  65500. * @returns a DataArray or null
  65501. */
  65502. getData(): Nullable<DataArray>;
  65503. /**
  65504. * Gets underlying native buffer
  65505. * @returns underlying native buffer
  65506. */
  65507. getBuffer(): Nullable<DataBuffer>;
  65508. /**
  65509. * Gets the stride in float32 units (i.e. byte stride / 4).
  65510. * May not be an integer if the byte stride is not divisible by 4.
  65511. * DEPRECATED. Use byteStride instead.
  65512. * @returns the stride in float32 units
  65513. */
  65514. getStrideSize(): number;
  65515. /**
  65516. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  65517. * @param data defines the data to store
  65518. */
  65519. create(data?: Nullable<DataArray>): void;
  65520. /** @hidden */
  65521. _rebuild(): void;
  65522. /**
  65523. * Update current buffer data
  65524. * @param data defines the data to store
  65525. */
  65526. update(data: DataArray): void;
  65527. /**
  65528. * Updates the data directly.
  65529. * @param data the new data
  65530. * @param offset the new offset
  65531. * @param vertexCount the vertex count (optional)
  65532. * @param useBytes set to true if the offset is in bytes
  65533. */
  65534. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  65535. /**
  65536. * Release all resources
  65537. */
  65538. dispose(): void;
  65539. }
  65540. /**
  65541. * Specialized buffer used to store vertex data
  65542. */
  65543. export class VertexBuffer {
  65544. /** @hidden */
  65545. _buffer: Buffer;
  65546. private _kind;
  65547. private _size;
  65548. private _ownsBuffer;
  65549. private _instanced;
  65550. private _instanceDivisor;
  65551. /**
  65552. * The byte type.
  65553. */
  65554. static readonly BYTE: number;
  65555. /**
  65556. * The unsigned byte type.
  65557. */
  65558. static readonly UNSIGNED_BYTE: number;
  65559. /**
  65560. * The short type.
  65561. */
  65562. static readonly SHORT: number;
  65563. /**
  65564. * The unsigned short type.
  65565. */
  65566. static readonly UNSIGNED_SHORT: number;
  65567. /**
  65568. * The integer type.
  65569. */
  65570. static readonly INT: number;
  65571. /**
  65572. * The unsigned integer type.
  65573. */
  65574. static readonly UNSIGNED_INT: number;
  65575. /**
  65576. * The float type.
  65577. */
  65578. static readonly FLOAT: number;
  65579. /**
  65580. * Gets or sets the instance divisor when in instanced mode
  65581. */
  65582. instanceDivisor: number;
  65583. /**
  65584. * Gets the byte stride.
  65585. */
  65586. readonly byteStride: number;
  65587. /**
  65588. * Gets the byte offset.
  65589. */
  65590. readonly byteOffset: number;
  65591. /**
  65592. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  65593. */
  65594. readonly normalized: boolean;
  65595. /**
  65596. * Gets the data type of each component in the array.
  65597. */
  65598. readonly type: number;
  65599. /**
  65600. * Constructor
  65601. * @param engine the engine
  65602. * @param data the data to use for this vertex buffer
  65603. * @param kind the vertex buffer kind
  65604. * @param updatable whether the data is updatable
  65605. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  65606. * @param stride the stride (optional)
  65607. * @param instanced whether the buffer is instanced (optional)
  65608. * @param offset the offset of the data (optional)
  65609. * @param size the number of components (optional)
  65610. * @param type the type of the component (optional)
  65611. * @param normalized whether the data contains normalized data (optional)
  65612. * @param useBytes set to true if stride and offset are in bytes (optional)
  65613. */
  65614. 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);
  65615. /** @hidden */
  65616. _rebuild(): void;
  65617. /**
  65618. * Returns the kind of the VertexBuffer (string)
  65619. * @returns a string
  65620. */
  65621. getKind(): string;
  65622. /**
  65623. * Gets a boolean indicating if the VertexBuffer is updatable?
  65624. * @returns true if the buffer is updatable
  65625. */
  65626. isUpdatable(): boolean;
  65627. /**
  65628. * Gets current buffer's data
  65629. * @returns a DataArray or null
  65630. */
  65631. getData(): Nullable<DataArray>;
  65632. /**
  65633. * Gets underlying native buffer
  65634. * @returns underlying native buffer
  65635. */
  65636. getBuffer(): Nullable<DataBuffer>;
  65637. /**
  65638. * Gets the stride in float32 units (i.e. byte stride / 4).
  65639. * May not be an integer if the byte stride is not divisible by 4.
  65640. * DEPRECATED. Use byteStride instead.
  65641. * @returns the stride in float32 units
  65642. */
  65643. getStrideSize(): number;
  65644. /**
  65645. * Returns the offset as a multiple of the type byte length.
  65646. * DEPRECATED. Use byteOffset instead.
  65647. * @returns the offset in bytes
  65648. */
  65649. getOffset(): number;
  65650. /**
  65651. * Returns the number of components per vertex attribute (integer)
  65652. * @returns the size in float
  65653. */
  65654. getSize(): number;
  65655. /**
  65656. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  65657. * @returns true if this buffer is instanced
  65658. */
  65659. getIsInstanced(): boolean;
  65660. /**
  65661. * Returns the instancing divisor, zero for non-instanced (integer).
  65662. * @returns a number
  65663. */
  65664. getInstanceDivisor(): number;
  65665. /**
  65666. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  65667. * @param data defines the data to store
  65668. */
  65669. create(data?: DataArray): void;
  65670. /**
  65671. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  65672. * This function will create a new buffer if the current one is not updatable
  65673. * @param data defines the data to store
  65674. */
  65675. update(data: DataArray): void;
  65676. /**
  65677. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  65678. * Returns the directly updated WebGLBuffer.
  65679. * @param data the new data
  65680. * @param offset the new offset
  65681. * @param useBytes set to true if the offset is in bytes
  65682. */
  65683. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  65684. /**
  65685. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  65686. */
  65687. dispose(): void;
  65688. /**
  65689. * Enumerates each value of this vertex buffer as numbers.
  65690. * @param count the number of values to enumerate
  65691. * @param callback the callback function called for each value
  65692. */
  65693. forEach(count: number, callback: (value: number, index: number) => void): void;
  65694. /**
  65695. * Positions
  65696. */
  65697. static readonly PositionKind: string;
  65698. /**
  65699. * Normals
  65700. */
  65701. static readonly NormalKind: string;
  65702. /**
  65703. * Tangents
  65704. */
  65705. static readonly TangentKind: string;
  65706. /**
  65707. * Texture coordinates
  65708. */
  65709. static readonly UVKind: string;
  65710. /**
  65711. * Texture coordinates 2
  65712. */
  65713. static readonly UV2Kind: string;
  65714. /**
  65715. * Texture coordinates 3
  65716. */
  65717. static readonly UV3Kind: string;
  65718. /**
  65719. * Texture coordinates 4
  65720. */
  65721. static readonly UV4Kind: string;
  65722. /**
  65723. * Texture coordinates 5
  65724. */
  65725. static readonly UV5Kind: string;
  65726. /**
  65727. * Texture coordinates 6
  65728. */
  65729. static readonly UV6Kind: string;
  65730. /**
  65731. * Colors
  65732. */
  65733. static readonly ColorKind: string;
  65734. /**
  65735. * Matrix indices (for bones)
  65736. */
  65737. static readonly MatricesIndicesKind: string;
  65738. /**
  65739. * Matrix weights (for bones)
  65740. */
  65741. static readonly MatricesWeightsKind: string;
  65742. /**
  65743. * Additional matrix indices (for bones)
  65744. */
  65745. static readonly MatricesIndicesExtraKind: string;
  65746. /**
  65747. * Additional matrix weights (for bones)
  65748. */
  65749. static readonly MatricesWeightsExtraKind: string;
  65750. /**
  65751. * Deduces the stride given a kind.
  65752. * @param kind The kind string to deduce
  65753. * @returns The deduced stride
  65754. */
  65755. static DeduceStride(kind: string): number;
  65756. /**
  65757. * Gets the byte length of the given type.
  65758. * @param type the type
  65759. * @returns the number of bytes
  65760. */
  65761. static GetTypeByteLength(type: number): number;
  65762. /**
  65763. * Enumerates each value of the given parameters as numbers.
  65764. * @param data the data to enumerate
  65765. * @param byteOffset the byte offset of the data
  65766. * @param byteStride the byte stride of the data
  65767. * @param componentCount the number of components per element
  65768. * @param componentType the type of the component
  65769. * @param count the total number of components
  65770. * @param normalized whether the data is normalized
  65771. * @param callback the callback function called for each value
  65772. */
  65773. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  65774. private static _GetFloatValue;
  65775. }
  65776. }
  65777. declare module BABYLON {
  65778. /**
  65779. * Class representing spherical harmonics coefficients to the 3rd degree
  65780. */
  65781. export class SphericalHarmonics {
  65782. /**
  65783. * Defines whether or not the harmonics have been prescaled for rendering.
  65784. */
  65785. preScaled: boolean;
  65786. /**
  65787. * The l0,0 coefficients of the spherical harmonics
  65788. */
  65789. l00: Vector3;
  65790. /**
  65791. * The l1,-1 coefficients of the spherical harmonics
  65792. */
  65793. l1_1: Vector3;
  65794. /**
  65795. * The l1,0 coefficients of the spherical harmonics
  65796. */
  65797. l10: Vector3;
  65798. /**
  65799. * The l1,1 coefficients of the spherical harmonics
  65800. */
  65801. l11: Vector3;
  65802. /**
  65803. * The l2,-2 coefficients of the spherical harmonics
  65804. */
  65805. l2_2: Vector3;
  65806. /**
  65807. * The l2,-1 coefficients of the spherical harmonics
  65808. */
  65809. l2_1: Vector3;
  65810. /**
  65811. * The l2,0 coefficients of the spherical harmonics
  65812. */
  65813. l20: Vector3;
  65814. /**
  65815. * The l2,1 coefficients of the spherical harmonics
  65816. */
  65817. l21: Vector3;
  65818. /**
  65819. * The l2,2 coefficients of the spherical harmonics
  65820. */
  65821. l22: Vector3;
  65822. /**
  65823. * Adds a light to the spherical harmonics
  65824. * @param direction the direction of the light
  65825. * @param color the color of the light
  65826. * @param deltaSolidAngle the delta solid angle of the light
  65827. */
  65828. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  65829. /**
  65830. * Scales the spherical harmonics by the given amount
  65831. * @param scale the amount to scale
  65832. */
  65833. scaleInPlace(scale: number): void;
  65834. /**
  65835. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  65836. *
  65837. * ```
  65838. * E_lm = A_l * L_lm
  65839. * ```
  65840. *
  65841. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  65842. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  65843. * the scaling factors are given in equation 9.
  65844. */
  65845. convertIncidentRadianceToIrradiance(): void;
  65846. /**
  65847. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  65848. *
  65849. * ```
  65850. * L = (1/pi) * E * rho
  65851. * ```
  65852. *
  65853. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  65854. */
  65855. convertIrradianceToLambertianRadiance(): void;
  65856. /**
  65857. * Integrates the reconstruction coefficients directly in to the SH preventing further
  65858. * required operations at run time.
  65859. *
  65860. * This is simply done by scaling back the SH with Ylm constants parameter.
  65861. * The trigonometric part being applied by the shader at run time.
  65862. */
  65863. preScaleForRendering(): void;
  65864. /**
  65865. * Constructs a spherical harmonics from an array.
  65866. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  65867. * @returns the spherical harmonics
  65868. */
  65869. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  65870. /**
  65871. * Gets the spherical harmonics from polynomial
  65872. * @param polynomial the spherical polynomial
  65873. * @returns the spherical harmonics
  65874. */
  65875. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  65876. }
  65877. /**
  65878. * Class representing spherical polynomial coefficients to the 3rd degree
  65879. */
  65880. export class SphericalPolynomial {
  65881. private _harmonics;
  65882. /**
  65883. * The spherical harmonics used to create the polynomials.
  65884. */
  65885. readonly preScaledHarmonics: SphericalHarmonics;
  65886. /**
  65887. * The x coefficients of the spherical polynomial
  65888. */
  65889. x: Vector3;
  65890. /**
  65891. * The y coefficients of the spherical polynomial
  65892. */
  65893. y: Vector3;
  65894. /**
  65895. * The z coefficients of the spherical polynomial
  65896. */
  65897. z: Vector3;
  65898. /**
  65899. * The xx coefficients of the spherical polynomial
  65900. */
  65901. xx: Vector3;
  65902. /**
  65903. * The yy coefficients of the spherical polynomial
  65904. */
  65905. yy: Vector3;
  65906. /**
  65907. * The zz coefficients of the spherical polynomial
  65908. */
  65909. zz: Vector3;
  65910. /**
  65911. * The xy coefficients of the spherical polynomial
  65912. */
  65913. xy: Vector3;
  65914. /**
  65915. * The yz coefficients of the spherical polynomial
  65916. */
  65917. yz: Vector3;
  65918. /**
  65919. * The zx coefficients of the spherical polynomial
  65920. */
  65921. zx: Vector3;
  65922. /**
  65923. * Adds an ambient color to the spherical polynomial
  65924. * @param color the color to add
  65925. */
  65926. addAmbient(color: Color3): void;
  65927. /**
  65928. * Scales the spherical polynomial by the given amount
  65929. * @param scale the amount to scale
  65930. */
  65931. scaleInPlace(scale: number): void;
  65932. /**
  65933. * Gets the spherical polynomial from harmonics
  65934. * @param harmonics the spherical harmonics
  65935. * @returns the spherical polynomial
  65936. */
  65937. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  65938. /**
  65939. * Constructs a spherical polynomial from an array.
  65940. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  65941. * @returns the spherical polynomial
  65942. */
  65943. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  65944. }
  65945. }
  65946. declare module BABYLON {
  65947. /**
  65948. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  65949. */
  65950. export interface CubeMapInfo {
  65951. /**
  65952. * The pixel array for the front face.
  65953. * This is stored in format, left to right, up to down format.
  65954. */
  65955. front: Nullable<ArrayBufferView>;
  65956. /**
  65957. * The pixel array for the back face.
  65958. * This is stored in format, left to right, up to down format.
  65959. */
  65960. back: Nullable<ArrayBufferView>;
  65961. /**
  65962. * The pixel array for the left face.
  65963. * This is stored in format, left to right, up to down format.
  65964. */
  65965. left: Nullable<ArrayBufferView>;
  65966. /**
  65967. * The pixel array for the right face.
  65968. * This is stored in format, left to right, up to down format.
  65969. */
  65970. right: Nullable<ArrayBufferView>;
  65971. /**
  65972. * The pixel array for the up face.
  65973. * This is stored in format, left to right, up to down format.
  65974. */
  65975. up: Nullable<ArrayBufferView>;
  65976. /**
  65977. * The pixel array for the down face.
  65978. * This is stored in format, left to right, up to down format.
  65979. */
  65980. down: Nullable<ArrayBufferView>;
  65981. /**
  65982. * The size of the cubemap stored.
  65983. *
  65984. * Each faces will be size * size pixels.
  65985. */
  65986. size: number;
  65987. /**
  65988. * The format of the texture.
  65989. *
  65990. * RGBA, RGB.
  65991. */
  65992. format: number;
  65993. /**
  65994. * The type of the texture data.
  65995. *
  65996. * UNSIGNED_INT, FLOAT.
  65997. */
  65998. type: number;
  65999. /**
  66000. * Specifies whether the texture is in gamma space.
  66001. */
  66002. gammaSpace: boolean;
  66003. }
  66004. /**
  66005. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  66006. */
  66007. export class PanoramaToCubeMapTools {
  66008. private static FACE_FRONT;
  66009. private static FACE_BACK;
  66010. private static FACE_RIGHT;
  66011. private static FACE_LEFT;
  66012. private static FACE_DOWN;
  66013. private static FACE_UP;
  66014. /**
  66015. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  66016. *
  66017. * @param float32Array The source data.
  66018. * @param inputWidth The width of the input panorama.
  66019. * @param inputHeight The height of the input panorama.
  66020. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  66021. * @return The cubemap data
  66022. */
  66023. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  66024. private static CreateCubemapTexture;
  66025. private static CalcProjectionSpherical;
  66026. }
  66027. }
  66028. declare module BABYLON {
  66029. /**
  66030. * Helper class dealing with the extraction of spherical polynomial dataArray
  66031. * from a cube map.
  66032. */
  66033. export class CubeMapToSphericalPolynomialTools {
  66034. private static FileFaces;
  66035. /**
  66036. * Converts a texture to the according Spherical Polynomial data.
  66037. * This extracts the first 3 orders only as they are the only one used in the lighting.
  66038. *
  66039. * @param texture The texture to extract the information from.
  66040. * @return The Spherical Polynomial data.
  66041. */
  66042. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  66043. /**
  66044. * Converts a cubemap to the according Spherical Polynomial data.
  66045. * This extracts the first 3 orders only as they are the only one used in the lighting.
  66046. *
  66047. * @param cubeInfo The Cube map to extract the information from.
  66048. * @return The Spherical Polynomial data.
  66049. */
  66050. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  66051. }
  66052. }
  66053. declare module BABYLON {
  66054. /**
  66055. * The engine store class is responsible to hold all the instances of Engine and Scene created
  66056. * during the life time of the application.
  66057. */
  66058. export class EngineStore {
  66059. /** Gets the list of created engines */
  66060. static Instances: Engine[];
  66061. /** @hidden */
  66062. static _LastCreatedScene: Nullable<Scene>;
  66063. /**
  66064. * Gets the latest created engine
  66065. */
  66066. static readonly LastCreatedEngine: Nullable<Engine>;
  66067. /**
  66068. * Gets the latest created scene
  66069. */
  66070. static readonly LastCreatedScene: Nullable<Scene>;
  66071. }
  66072. }
  66073. declare module BABYLON {
  66074. /**
  66075. * Define options used to create a render target texture
  66076. */
  66077. export class RenderTargetCreationOptions {
  66078. /**
  66079. * Specifies is mipmaps must be generated
  66080. */
  66081. generateMipMaps?: boolean;
  66082. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  66083. generateDepthBuffer?: boolean;
  66084. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  66085. generateStencilBuffer?: boolean;
  66086. /** Defines texture type (int by default) */
  66087. type?: number;
  66088. /** Defines sampling mode (trilinear by default) */
  66089. samplingMode?: number;
  66090. /** Defines format (RGBA by default) */
  66091. format?: number;
  66092. }
  66093. }
  66094. declare module BABYLON {
  66095. /**
  66096. * @hidden
  66097. **/
  66098. export class _AlphaState {
  66099. private _isAlphaBlendDirty;
  66100. private _isBlendFunctionParametersDirty;
  66101. private _isBlendEquationParametersDirty;
  66102. private _isBlendConstantsDirty;
  66103. private _alphaBlend;
  66104. private _blendFunctionParameters;
  66105. private _blendEquationParameters;
  66106. private _blendConstants;
  66107. /**
  66108. * Initializes the state.
  66109. */
  66110. constructor();
  66111. readonly isDirty: boolean;
  66112. alphaBlend: boolean;
  66113. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  66114. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  66115. setAlphaEquationParameters(rgb: number, alpha: number): void;
  66116. reset(): void;
  66117. apply(gl: WebGLRenderingContext): void;
  66118. }
  66119. }
  66120. declare module BABYLON {
  66121. /**
  66122. * @hidden
  66123. **/
  66124. export class _DepthCullingState {
  66125. private _isDepthTestDirty;
  66126. private _isDepthMaskDirty;
  66127. private _isDepthFuncDirty;
  66128. private _isCullFaceDirty;
  66129. private _isCullDirty;
  66130. private _isZOffsetDirty;
  66131. private _isFrontFaceDirty;
  66132. private _depthTest;
  66133. private _depthMask;
  66134. private _depthFunc;
  66135. private _cull;
  66136. private _cullFace;
  66137. private _zOffset;
  66138. private _frontFace;
  66139. /**
  66140. * Initializes the state.
  66141. */
  66142. constructor();
  66143. readonly isDirty: boolean;
  66144. zOffset: number;
  66145. cullFace: Nullable<number>;
  66146. cull: Nullable<boolean>;
  66147. depthFunc: Nullable<number>;
  66148. depthMask: boolean;
  66149. depthTest: boolean;
  66150. frontFace: Nullable<number>;
  66151. reset(): void;
  66152. apply(gl: WebGLRenderingContext): void;
  66153. }
  66154. }
  66155. declare module BABYLON {
  66156. /**
  66157. * @hidden
  66158. **/
  66159. export class _StencilState {
  66160. /** 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 */
  66161. static readonly ALWAYS: number;
  66162. /** Passed to stencilOperation to specify that stencil value must be kept */
  66163. static readonly KEEP: number;
  66164. /** Passed to stencilOperation to specify that stencil value must be replaced */
  66165. static readonly REPLACE: number;
  66166. private _isStencilTestDirty;
  66167. private _isStencilMaskDirty;
  66168. private _isStencilFuncDirty;
  66169. private _isStencilOpDirty;
  66170. private _stencilTest;
  66171. private _stencilMask;
  66172. private _stencilFunc;
  66173. private _stencilFuncRef;
  66174. private _stencilFuncMask;
  66175. private _stencilOpStencilFail;
  66176. private _stencilOpDepthFail;
  66177. private _stencilOpStencilDepthPass;
  66178. readonly isDirty: boolean;
  66179. stencilFunc: number;
  66180. stencilFuncRef: number;
  66181. stencilFuncMask: number;
  66182. stencilOpStencilFail: number;
  66183. stencilOpDepthFail: number;
  66184. stencilOpStencilDepthPass: number;
  66185. stencilMask: number;
  66186. stencilTest: boolean;
  66187. constructor();
  66188. reset(): void;
  66189. apply(gl: WebGLRenderingContext): void;
  66190. }
  66191. }
  66192. declare module BABYLON {
  66193. /**
  66194. * @hidden
  66195. **/
  66196. export class _TimeToken {
  66197. _startTimeQuery: Nullable<WebGLQuery>;
  66198. _endTimeQuery: Nullable<WebGLQuery>;
  66199. _timeElapsedQuery: Nullable<WebGLQuery>;
  66200. _timeElapsedQueryEnded: boolean;
  66201. }
  66202. }
  66203. declare module BABYLON {
  66204. /**
  66205. * Class used to store data associated with WebGL texture data for the engine
  66206. * This class should not be used directly
  66207. */
  66208. export class InternalTexture {
  66209. /** hidden */
  66210. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  66211. /**
  66212. * The source of the texture data is unknown
  66213. */
  66214. static DATASOURCE_UNKNOWN: number;
  66215. /**
  66216. * Texture data comes from an URL
  66217. */
  66218. static DATASOURCE_URL: number;
  66219. /**
  66220. * Texture data is only used for temporary storage
  66221. */
  66222. static DATASOURCE_TEMP: number;
  66223. /**
  66224. * Texture data comes from raw data (ArrayBuffer)
  66225. */
  66226. static DATASOURCE_RAW: number;
  66227. /**
  66228. * Texture content is dynamic (video or dynamic texture)
  66229. */
  66230. static DATASOURCE_DYNAMIC: number;
  66231. /**
  66232. * Texture content is generated by rendering to it
  66233. */
  66234. static DATASOURCE_RENDERTARGET: number;
  66235. /**
  66236. * Texture content is part of a multi render target process
  66237. */
  66238. static DATASOURCE_MULTIRENDERTARGET: number;
  66239. /**
  66240. * Texture data comes from a cube data file
  66241. */
  66242. static DATASOURCE_CUBE: number;
  66243. /**
  66244. * Texture data comes from a raw cube data
  66245. */
  66246. static DATASOURCE_CUBERAW: number;
  66247. /**
  66248. * Texture data come from a prefiltered cube data file
  66249. */
  66250. static DATASOURCE_CUBEPREFILTERED: number;
  66251. /**
  66252. * Texture content is raw 3D data
  66253. */
  66254. static DATASOURCE_RAW3D: number;
  66255. /**
  66256. * Texture content is a depth texture
  66257. */
  66258. static DATASOURCE_DEPTHTEXTURE: number;
  66259. /**
  66260. * Texture data comes from a raw cube data encoded with RGBD
  66261. */
  66262. static DATASOURCE_CUBERAW_RGBD: number;
  66263. /**
  66264. * Defines if the texture is ready
  66265. */
  66266. isReady: boolean;
  66267. /**
  66268. * Defines if the texture is a cube texture
  66269. */
  66270. isCube: boolean;
  66271. /**
  66272. * Defines if the texture contains 3D data
  66273. */
  66274. is3D: boolean;
  66275. /**
  66276. * Defines if the texture contains multiview data
  66277. */
  66278. isMultiview: boolean;
  66279. /**
  66280. * Gets the URL used to load this texture
  66281. */
  66282. url: string;
  66283. /**
  66284. * Gets the sampling mode of the texture
  66285. */
  66286. samplingMode: number;
  66287. /**
  66288. * Gets a boolean indicating if the texture needs mipmaps generation
  66289. */
  66290. generateMipMaps: boolean;
  66291. /**
  66292. * Gets the number of samples used by the texture (WebGL2+ only)
  66293. */
  66294. samples: number;
  66295. /**
  66296. * Gets the type of the texture (int, float...)
  66297. */
  66298. type: number;
  66299. /**
  66300. * Gets the format of the texture (RGB, RGBA...)
  66301. */
  66302. format: number;
  66303. /**
  66304. * Observable called when the texture is loaded
  66305. */
  66306. onLoadedObservable: Observable<InternalTexture>;
  66307. /**
  66308. * Gets the width of the texture
  66309. */
  66310. width: number;
  66311. /**
  66312. * Gets the height of the texture
  66313. */
  66314. height: number;
  66315. /**
  66316. * Gets the depth of the texture
  66317. */
  66318. depth: number;
  66319. /**
  66320. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  66321. */
  66322. baseWidth: number;
  66323. /**
  66324. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  66325. */
  66326. baseHeight: number;
  66327. /**
  66328. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  66329. */
  66330. baseDepth: number;
  66331. /**
  66332. * Gets a boolean indicating if the texture is inverted on Y axis
  66333. */
  66334. invertY: boolean;
  66335. /** @hidden */
  66336. _invertVScale: boolean;
  66337. /** @hidden */
  66338. _associatedChannel: number;
  66339. /** @hidden */
  66340. _dataSource: number;
  66341. /** @hidden */
  66342. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  66343. /** @hidden */
  66344. _bufferView: Nullable<ArrayBufferView>;
  66345. /** @hidden */
  66346. _bufferViewArray: Nullable<ArrayBufferView[]>;
  66347. /** @hidden */
  66348. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  66349. /** @hidden */
  66350. _size: number;
  66351. /** @hidden */
  66352. _extension: string;
  66353. /** @hidden */
  66354. _files: Nullable<string[]>;
  66355. /** @hidden */
  66356. _workingCanvas: Nullable<HTMLCanvasElement>;
  66357. /** @hidden */
  66358. _workingContext: Nullable<CanvasRenderingContext2D>;
  66359. /** @hidden */
  66360. _framebuffer: Nullable<WebGLFramebuffer>;
  66361. /** @hidden */
  66362. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  66363. /** @hidden */
  66364. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  66365. /** @hidden */
  66366. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  66367. /** @hidden */
  66368. _attachments: Nullable<number[]>;
  66369. /** @hidden */
  66370. _cachedCoordinatesMode: Nullable<number>;
  66371. /** @hidden */
  66372. _cachedWrapU: Nullable<number>;
  66373. /** @hidden */
  66374. _cachedWrapV: Nullable<number>;
  66375. /** @hidden */
  66376. _cachedWrapR: Nullable<number>;
  66377. /** @hidden */
  66378. _cachedAnisotropicFilteringLevel: Nullable<number>;
  66379. /** @hidden */
  66380. _isDisabled: boolean;
  66381. /** @hidden */
  66382. _compression: Nullable<string>;
  66383. /** @hidden */
  66384. _generateStencilBuffer: boolean;
  66385. /** @hidden */
  66386. _generateDepthBuffer: boolean;
  66387. /** @hidden */
  66388. _comparisonFunction: number;
  66389. /** @hidden */
  66390. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  66391. /** @hidden */
  66392. _lodGenerationScale: number;
  66393. /** @hidden */
  66394. _lodGenerationOffset: number;
  66395. /** @hidden */
  66396. _colorTextureArray: Nullable<WebGLTexture>;
  66397. /** @hidden */
  66398. _depthStencilTextureArray: Nullable<WebGLTexture>;
  66399. /** @hidden */
  66400. _lodTextureHigh: Nullable<BaseTexture>;
  66401. /** @hidden */
  66402. _lodTextureMid: Nullable<BaseTexture>;
  66403. /** @hidden */
  66404. _lodTextureLow: Nullable<BaseTexture>;
  66405. /** @hidden */
  66406. _isRGBD: boolean;
  66407. /** @hidden */
  66408. _webGLTexture: Nullable<WebGLTexture>;
  66409. /** @hidden */
  66410. _references: number;
  66411. private _engine;
  66412. /**
  66413. * Gets the Engine the texture belongs to.
  66414. * @returns The babylon engine
  66415. */
  66416. getEngine(): Engine;
  66417. /**
  66418. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  66419. */
  66420. readonly dataSource: number;
  66421. /**
  66422. * Creates a new InternalTexture
  66423. * @param engine defines the engine to use
  66424. * @param dataSource defines the type of data that will be used
  66425. * @param delayAllocation if the texture allocation should be delayed (default: false)
  66426. */
  66427. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  66428. /**
  66429. * Increments the number of references (ie. the number of Texture that point to it)
  66430. */
  66431. incrementReferences(): void;
  66432. /**
  66433. * Change the size of the texture (not the size of the content)
  66434. * @param width defines the new width
  66435. * @param height defines the new height
  66436. * @param depth defines the new depth (1 by default)
  66437. */
  66438. updateSize(width: int, height: int, depth?: int): void;
  66439. /** @hidden */
  66440. _rebuild(): void;
  66441. /** @hidden */
  66442. _swapAndDie(target: InternalTexture): void;
  66443. /**
  66444. * Dispose the current allocated resources
  66445. */
  66446. dispose(): void;
  66447. }
  66448. }
  66449. declare module BABYLON {
  66450. /**
  66451. * This represents the main contract an easing function should follow.
  66452. * Easing functions are used throughout the animation system.
  66453. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66454. */
  66455. export interface IEasingFunction {
  66456. /**
  66457. * Given an input gradient between 0 and 1, this returns the corrseponding value
  66458. * of the easing function.
  66459. * The link below provides some of the most common examples of easing functions.
  66460. * @see https://easings.net/
  66461. * @param gradient Defines the value between 0 and 1 we want the easing value for
  66462. * @returns the corresponding value on the curve defined by the easing function
  66463. */
  66464. ease(gradient: number): number;
  66465. }
  66466. /**
  66467. * Base class used for every default easing function.
  66468. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66469. */
  66470. export class EasingFunction implements IEasingFunction {
  66471. /**
  66472. * Interpolation follows the mathematical formula associated with the easing function.
  66473. */
  66474. static readonly EASINGMODE_EASEIN: number;
  66475. /**
  66476. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  66477. */
  66478. static readonly EASINGMODE_EASEOUT: number;
  66479. /**
  66480. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  66481. */
  66482. static readonly EASINGMODE_EASEINOUT: number;
  66483. private _easingMode;
  66484. /**
  66485. * Sets the easing mode of the current function.
  66486. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  66487. */
  66488. setEasingMode(easingMode: number): void;
  66489. /**
  66490. * Gets the current easing mode.
  66491. * @returns the easing mode
  66492. */
  66493. getEasingMode(): number;
  66494. /**
  66495. * @hidden
  66496. */
  66497. easeInCore(gradient: number): number;
  66498. /**
  66499. * Given an input gradient between 0 and 1, this returns the corrseponding value
  66500. * of the easing function.
  66501. * @param gradient Defines the value between 0 and 1 we want the easing value for
  66502. * @returns the corresponding value on the curve defined by the easing function
  66503. */
  66504. ease(gradient: number): number;
  66505. }
  66506. /**
  66507. * Easing function with a circle shape (see link below).
  66508. * @see https://easings.net/#easeInCirc
  66509. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66510. */
  66511. export class CircleEase extends EasingFunction implements IEasingFunction {
  66512. /** @hidden */
  66513. easeInCore(gradient: number): number;
  66514. }
  66515. /**
  66516. * Easing function with a ease back shape (see link below).
  66517. * @see https://easings.net/#easeInBack
  66518. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66519. */
  66520. export class BackEase extends EasingFunction implements IEasingFunction {
  66521. /** Defines the amplitude of the function */
  66522. amplitude: number;
  66523. /**
  66524. * Instantiates a back ease easing
  66525. * @see https://easings.net/#easeInBack
  66526. * @param amplitude Defines the amplitude of the function
  66527. */
  66528. constructor(
  66529. /** Defines the amplitude of the function */
  66530. amplitude?: number);
  66531. /** @hidden */
  66532. easeInCore(gradient: number): number;
  66533. }
  66534. /**
  66535. * Easing function with a bouncing shape (see link below).
  66536. * @see https://easings.net/#easeInBounce
  66537. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66538. */
  66539. export class BounceEase extends EasingFunction implements IEasingFunction {
  66540. /** Defines the number of bounces */
  66541. bounces: number;
  66542. /** Defines the amplitude of the bounce */
  66543. bounciness: number;
  66544. /**
  66545. * Instantiates a bounce easing
  66546. * @see https://easings.net/#easeInBounce
  66547. * @param bounces Defines the number of bounces
  66548. * @param bounciness Defines the amplitude of the bounce
  66549. */
  66550. constructor(
  66551. /** Defines the number of bounces */
  66552. bounces?: number,
  66553. /** Defines the amplitude of the bounce */
  66554. bounciness?: number);
  66555. /** @hidden */
  66556. easeInCore(gradient: number): number;
  66557. }
  66558. /**
  66559. * Easing function with a power of 3 shape (see link below).
  66560. * @see https://easings.net/#easeInCubic
  66561. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66562. */
  66563. export class CubicEase extends EasingFunction implements IEasingFunction {
  66564. /** @hidden */
  66565. easeInCore(gradient: number): number;
  66566. }
  66567. /**
  66568. * Easing function with an elastic shape (see link below).
  66569. * @see https://easings.net/#easeInElastic
  66570. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66571. */
  66572. export class ElasticEase extends EasingFunction implements IEasingFunction {
  66573. /** Defines the number of oscillations*/
  66574. oscillations: number;
  66575. /** Defines the amplitude of the oscillations*/
  66576. springiness: number;
  66577. /**
  66578. * Instantiates an elastic easing function
  66579. * @see https://easings.net/#easeInElastic
  66580. * @param oscillations Defines the number of oscillations
  66581. * @param springiness Defines the amplitude of the oscillations
  66582. */
  66583. constructor(
  66584. /** Defines the number of oscillations*/
  66585. oscillations?: number,
  66586. /** Defines the amplitude of the oscillations*/
  66587. springiness?: number);
  66588. /** @hidden */
  66589. easeInCore(gradient: number): number;
  66590. }
  66591. /**
  66592. * Easing function with an exponential shape (see link below).
  66593. * @see https://easings.net/#easeInExpo
  66594. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66595. */
  66596. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  66597. /** Defines the exponent of the function */
  66598. exponent: number;
  66599. /**
  66600. * Instantiates an exponential easing function
  66601. * @see https://easings.net/#easeInExpo
  66602. * @param exponent Defines the exponent of the function
  66603. */
  66604. constructor(
  66605. /** Defines the exponent of the function */
  66606. exponent?: number);
  66607. /** @hidden */
  66608. easeInCore(gradient: number): number;
  66609. }
  66610. /**
  66611. * Easing function with a power shape (see link below).
  66612. * @see https://easings.net/#easeInQuad
  66613. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66614. */
  66615. export class PowerEase extends EasingFunction implements IEasingFunction {
  66616. /** Defines the power of the function */
  66617. power: number;
  66618. /**
  66619. * Instantiates an power base easing function
  66620. * @see https://easings.net/#easeInQuad
  66621. * @param power Defines the power of the function
  66622. */
  66623. constructor(
  66624. /** Defines the power of the function */
  66625. power?: number);
  66626. /** @hidden */
  66627. easeInCore(gradient: number): number;
  66628. }
  66629. /**
  66630. * Easing function with a power of 2 shape (see link below).
  66631. * @see https://easings.net/#easeInQuad
  66632. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66633. */
  66634. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  66635. /** @hidden */
  66636. easeInCore(gradient: number): number;
  66637. }
  66638. /**
  66639. * Easing function with a power of 4 shape (see link below).
  66640. * @see https://easings.net/#easeInQuart
  66641. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66642. */
  66643. export class QuarticEase extends EasingFunction implements IEasingFunction {
  66644. /** @hidden */
  66645. easeInCore(gradient: number): number;
  66646. }
  66647. /**
  66648. * Easing function with a power of 5 shape (see link below).
  66649. * @see https://easings.net/#easeInQuint
  66650. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66651. */
  66652. export class QuinticEase extends EasingFunction implements IEasingFunction {
  66653. /** @hidden */
  66654. easeInCore(gradient: number): number;
  66655. }
  66656. /**
  66657. * Easing function with a sin shape (see link below).
  66658. * @see https://easings.net/#easeInSine
  66659. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66660. */
  66661. export class SineEase extends EasingFunction implements IEasingFunction {
  66662. /** @hidden */
  66663. easeInCore(gradient: number): number;
  66664. }
  66665. /**
  66666. * Easing function with a bezier shape (see link below).
  66667. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  66668. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66669. */
  66670. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  66671. /** Defines the x component of the start tangent in the bezier curve */
  66672. x1: number;
  66673. /** Defines the y component of the start tangent in the bezier curve */
  66674. y1: number;
  66675. /** Defines the x component of the end tangent in the bezier curve */
  66676. x2: number;
  66677. /** Defines the y component of the end tangent in the bezier curve */
  66678. y2: number;
  66679. /**
  66680. * Instantiates a bezier function
  66681. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  66682. * @param x1 Defines the x component of the start tangent in the bezier curve
  66683. * @param y1 Defines the y component of the start tangent in the bezier curve
  66684. * @param x2 Defines the x component of the end tangent in the bezier curve
  66685. * @param y2 Defines the y component of the end tangent in the bezier curve
  66686. */
  66687. constructor(
  66688. /** Defines the x component of the start tangent in the bezier curve */
  66689. x1?: number,
  66690. /** Defines the y component of the start tangent in the bezier curve */
  66691. y1?: number,
  66692. /** Defines the x component of the end tangent in the bezier curve */
  66693. x2?: number,
  66694. /** Defines the y component of the end tangent in the bezier curve */
  66695. y2?: number);
  66696. /** @hidden */
  66697. easeInCore(gradient: number): number;
  66698. }
  66699. }
  66700. declare module BABYLON {
  66701. /**
  66702. * Defines an interface which represents an animation key frame
  66703. */
  66704. export interface IAnimationKey {
  66705. /**
  66706. * Frame of the key frame
  66707. */
  66708. frame: number;
  66709. /**
  66710. * Value at the specifies key frame
  66711. */
  66712. value: any;
  66713. /**
  66714. * The input tangent for the cubic hermite spline
  66715. */
  66716. inTangent?: any;
  66717. /**
  66718. * The output tangent for the cubic hermite spline
  66719. */
  66720. outTangent?: any;
  66721. /**
  66722. * The animation interpolation type
  66723. */
  66724. interpolation?: AnimationKeyInterpolation;
  66725. }
  66726. /**
  66727. * Enum for the animation key frame interpolation type
  66728. */
  66729. export enum AnimationKeyInterpolation {
  66730. /**
  66731. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  66732. */
  66733. STEP = 1
  66734. }
  66735. }
  66736. declare module BABYLON {
  66737. /**
  66738. * Represents the range of an animation
  66739. */
  66740. export class AnimationRange {
  66741. /**The name of the animation range**/
  66742. name: string;
  66743. /**The starting frame of the animation */
  66744. from: number;
  66745. /**The ending frame of the animation*/
  66746. to: number;
  66747. /**
  66748. * Initializes the range of an animation
  66749. * @param name The name of the animation range
  66750. * @param from The starting frame of the animation
  66751. * @param to The ending frame of the animation
  66752. */
  66753. constructor(
  66754. /**The name of the animation range**/
  66755. name: string,
  66756. /**The starting frame of the animation */
  66757. from: number,
  66758. /**The ending frame of the animation*/
  66759. to: number);
  66760. /**
  66761. * Makes a copy of the animation range
  66762. * @returns A copy of the animation range
  66763. */
  66764. clone(): AnimationRange;
  66765. }
  66766. }
  66767. declare module BABYLON {
  66768. /**
  66769. * Composed of a frame, and an action function
  66770. */
  66771. export class AnimationEvent {
  66772. /** The frame for which the event is triggered **/
  66773. frame: number;
  66774. /** The event to perform when triggered **/
  66775. action: (currentFrame: number) => void;
  66776. /** Specifies if the event should be triggered only once**/
  66777. onlyOnce?: boolean | undefined;
  66778. /**
  66779. * Specifies if the animation event is done
  66780. */
  66781. isDone: boolean;
  66782. /**
  66783. * Initializes the animation event
  66784. * @param frame The frame for which the event is triggered
  66785. * @param action The event to perform when triggered
  66786. * @param onlyOnce Specifies if the event should be triggered only once
  66787. */
  66788. constructor(
  66789. /** The frame for which the event is triggered **/
  66790. frame: number,
  66791. /** The event to perform when triggered **/
  66792. action: (currentFrame: number) => void,
  66793. /** Specifies if the event should be triggered only once**/
  66794. onlyOnce?: boolean | undefined);
  66795. /** @hidden */
  66796. _clone(): AnimationEvent;
  66797. }
  66798. }
  66799. declare module BABYLON {
  66800. /**
  66801. * Interface used to define a behavior
  66802. */
  66803. export interface Behavior<T> {
  66804. /** gets or sets behavior's name */
  66805. name: string;
  66806. /**
  66807. * Function called when the behavior needs to be initialized (after attaching it to a target)
  66808. */
  66809. init(): void;
  66810. /**
  66811. * Called when the behavior is attached to a target
  66812. * @param target defines the target where the behavior is attached to
  66813. */
  66814. attach(target: T): void;
  66815. /**
  66816. * Called when the behavior is detached from its target
  66817. */
  66818. detach(): void;
  66819. }
  66820. /**
  66821. * Interface implemented by classes supporting behaviors
  66822. */
  66823. export interface IBehaviorAware<T> {
  66824. /**
  66825. * Attach a behavior
  66826. * @param behavior defines the behavior to attach
  66827. * @returns the current host
  66828. */
  66829. addBehavior(behavior: Behavior<T>): T;
  66830. /**
  66831. * Remove a behavior from the current object
  66832. * @param behavior defines the behavior to detach
  66833. * @returns the current host
  66834. */
  66835. removeBehavior(behavior: Behavior<T>): T;
  66836. /**
  66837. * Gets a behavior using its name to search
  66838. * @param name defines the name to search
  66839. * @returns the behavior or null if not found
  66840. */
  66841. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  66842. }
  66843. }
  66844. declare module BABYLON {
  66845. /**
  66846. * @hidden
  66847. */
  66848. export class IntersectionInfo {
  66849. bu: Nullable<number>;
  66850. bv: Nullable<number>;
  66851. distance: number;
  66852. faceId: number;
  66853. subMeshId: number;
  66854. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  66855. }
  66856. }
  66857. declare module BABYLON {
  66858. /**
  66859. * Class used to store bounding sphere information
  66860. */
  66861. export class BoundingSphere {
  66862. /**
  66863. * Gets the center of the bounding sphere in local space
  66864. */
  66865. readonly center: Vector3;
  66866. /**
  66867. * Radius of the bounding sphere in local space
  66868. */
  66869. radius: number;
  66870. /**
  66871. * Gets the center of the bounding sphere in world space
  66872. */
  66873. readonly centerWorld: Vector3;
  66874. /**
  66875. * Radius of the bounding sphere in world space
  66876. */
  66877. radiusWorld: number;
  66878. /**
  66879. * Gets the minimum vector in local space
  66880. */
  66881. readonly minimum: Vector3;
  66882. /**
  66883. * Gets the maximum vector in local space
  66884. */
  66885. readonly maximum: Vector3;
  66886. private _worldMatrix;
  66887. private static readonly TmpVector3;
  66888. /**
  66889. * Creates a new bounding sphere
  66890. * @param min defines the minimum vector (in local space)
  66891. * @param max defines the maximum vector (in local space)
  66892. * @param worldMatrix defines the new world matrix
  66893. */
  66894. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  66895. /**
  66896. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  66897. * @param min defines the new minimum vector (in local space)
  66898. * @param max defines the new maximum vector (in local space)
  66899. * @param worldMatrix defines the new world matrix
  66900. */
  66901. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  66902. /**
  66903. * Scale the current bounding sphere by applying a scale factor
  66904. * @param factor defines the scale factor to apply
  66905. * @returns the current bounding box
  66906. */
  66907. scale(factor: number): BoundingSphere;
  66908. /**
  66909. * Gets the world matrix of the bounding box
  66910. * @returns a matrix
  66911. */
  66912. getWorldMatrix(): DeepImmutable<Matrix>;
  66913. /** @hidden */
  66914. _update(worldMatrix: DeepImmutable<Matrix>): void;
  66915. /**
  66916. * Tests if the bounding sphere is intersecting the frustum planes
  66917. * @param frustumPlanes defines the frustum planes to test
  66918. * @returns true if there is an intersection
  66919. */
  66920. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66921. /**
  66922. * Tests if the bounding sphere center is in between the frustum planes.
  66923. * Used for optimistic fast inclusion.
  66924. * @param frustumPlanes defines the frustum planes to test
  66925. * @returns true if the sphere center is in between the frustum planes
  66926. */
  66927. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66928. /**
  66929. * Tests if a point is inside the bounding sphere
  66930. * @param point defines the point to test
  66931. * @returns true if the point is inside the bounding sphere
  66932. */
  66933. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  66934. /**
  66935. * Checks if two sphere intersct
  66936. * @param sphere0 sphere 0
  66937. * @param sphere1 sphere 1
  66938. * @returns true if the speres intersect
  66939. */
  66940. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  66941. }
  66942. }
  66943. declare module BABYLON {
  66944. /**
  66945. * Class used to store bounding box information
  66946. */
  66947. export class BoundingBox implements ICullable {
  66948. /**
  66949. * Gets the 8 vectors representing the bounding box in local space
  66950. */
  66951. readonly vectors: Vector3[];
  66952. /**
  66953. * Gets the center of the bounding box in local space
  66954. */
  66955. readonly center: Vector3;
  66956. /**
  66957. * Gets the center of the bounding box in world space
  66958. */
  66959. readonly centerWorld: Vector3;
  66960. /**
  66961. * Gets the extend size in local space
  66962. */
  66963. readonly extendSize: Vector3;
  66964. /**
  66965. * Gets the extend size in world space
  66966. */
  66967. readonly extendSizeWorld: Vector3;
  66968. /**
  66969. * Gets the OBB (object bounding box) directions
  66970. */
  66971. readonly directions: Vector3[];
  66972. /**
  66973. * Gets the 8 vectors representing the bounding box in world space
  66974. */
  66975. readonly vectorsWorld: Vector3[];
  66976. /**
  66977. * Gets the minimum vector in world space
  66978. */
  66979. readonly minimumWorld: Vector3;
  66980. /**
  66981. * Gets the maximum vector in world space
  66982. */
  66983. readonly maximumWorld: Vector3;
  66984. /**
  66985. * Gets the minimum vector in local space
  66986. */
  66987. readonly minimum: Vector3;
  66988. /**
  66989. * Gets the maximum vector in local space
  66990. */
  66991. readonly maximum: Vector3;
  66992. private _worldMatrix;
  66993. private static readonly TmpVector3;
  66994. /**
  66995. * @hidden
  66996. */
  66997. _tag: number;
  66998. /**
  66999. * Creates a new bounding box
  67000. * @param min defines the minimum vector (in local space)
  67001. * @param max defines the maximum vector (in local space)
  67002. * @param worldMatrix defines the new world matrix
  67003. */
  67004. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  67005. /**
  67006. * Recreates the entire bounding box from scratch as if we call the constructor in place
  67007. * @param min defines the new minimum vector (in local space)
  67008. * @param max defines the new maximum vector (in local space)
  67009. * @param worldMatrix defines the new world matrix
  67010. */
  67011. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  67012. /**
  67013. * Scale the current bounding box by applying a scale factor
  67014. * @param factor defines the scale factor to apply
  67015. * @returns the current bounding box
  67016. */
  67017. scale(factor: number): BoundingBox;
  67018. /**
  67019. * Gets the world matrix of the bounding box
  67020. * @returns a matrix
  67021. */
  67022. getWorldMatrix(): DeepImmutable<Matrix>;
  67023. /** @hidden */
  67024. _update(world: DeepImmutable<Matrix>): void;
  67025. /**
  67026. * Tests if the bounding box is intersecting the frustum planes
  67027. * @param frustumPlanes defines the frustum planes to test
  67028. * @returns true if there is an intersection
  67029. */
  67030. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  67031. /**
  67032. * Tests if the bounding box is entirely inside the frustum planes
  67033. * @param frustumPlanes defines the frustum planes to test
  67034. * @returns true if there is an inclusion
  67035. */
  67036. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  67037. /**
  67038. * Tests if a point is inside the bounding box
  67039. * @param point defines the point to test
  67040. * @returns true if the point is inside the bounding box
  67041. */
  67042. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  67043. /**
  67044. * Tests if the bounding box intersects with a bounding sphere
  67045. * @param sphere defines the sphere to test
  67046. * @returns true if there is an intersection
  67047. */
  67048. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  67049. /**
  67050. * Tests if the bounding box intersects with a box defined by a min and max vectors
  67051. * @param min defines the min vector to use
  67052. * @param max defines the max vector to use
  67053. * @returns true if there is an intersection
  67054. */
  67055. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  67056. /**
  67057. * Tests if two bounding boxes are intersections
  67058. * @param box0 defines the first box to test
  67059. * @param box1 defines the second box to test
  67060. * @returns true if there is an intersection
  67061. */
  67062. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  67063. /**
  67064. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  67065. * @param minPoint defines the minimum vector of the bounding box
  67066. * @param maxPoint defines the maximum vector of the bounding box
  67067. * @param sphereCenter defines the sphere center
  67068. * @param sphereRadius defines the sphere radius
  67069. * @returns true if there is an intersection
  67070. */
  67071. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  67072. /**
  67073. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  67074. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  67075. * @param frustumPlanes defines the frustum planes to test
  67076. * @return true if there is an inclusion
  67077. */
  67078. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  67079. /**
  67080. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  67081. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  67082. * @param frustumPlanes defines the frustum planes to test
  67083. * @return true if there is an intersection
  67084. */
  67085. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  67086. }
  67087. }
  67088. declare module BABYLON {
  67089. /** @hidden */
  67090. export class Collider {
  67091. /** Define if a collision was found */
  67092. collisionFound: boolean;
  67093. /**
  67094. * Define last intersection point in local space
  67095. */
  67096. intersectionPoint: Vector3;
  67097. /**
  67098. * Define last collided mesh
  67099. */
  67100. collidedMesh: Nullable<AbstractMesh>;
  67101. private _collisionPoint;
  67102. private _planeIntersectionPoint;
  67103. private _tempVector;
  67104. private _tempVector2;
  67105. private _tempVector3;
  67106. private _tempVector4;
  67107. private _edge;
  67108. private _baseToVertex;
  67109. private _destinationPoint;
  67110. private _slidePlaneNormal;
  67111. private _displacementVector;
  67112. /** @hidden */
  67113. _radius: Vector3;
  67114. /** @hidden */
  67115. _retry: number;
  67116. private _velocity;
  67117. private _basePoint;
  67118. private _epsilon;
  67119. /** @hidden */
  67120. _velocityWorldLength: number;
  67121. /** @hidden */
  67122. _basePointWorld: Vector3;
  67123. private _velocityWorld;
  67124. private _normalizedVelocity;
  67125. /** @hidden */
  67126. _initialVelocity: Vector3;
  67127. /** @hidden */
  67128. _initialPosition: Vector3;
  67129. private _nearestDistance;
  67130. private _collisionMask;
  67131. collisionMask: number;
  67132. /**
  67133. * Gets the plane normal used to compute the sliding response (in local space)
  67134. */
  67135. readonly slidePlaneNormal: Vector3;
  67136. /** @hidden */
  67137. _initialize(source: Vector3, dir: Vector3, e: number): void;
  67138. /** @hidden */
  67139. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  67140. /** @hidden */
  67141. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  67142. /** @hidden */
  67143. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  67144. /** @hidden */
  67145. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  67146. /** @hidden */
  67147. _getResponse(pos: Vector3, vel: Vector3): void;
  67148. }
  67149. }
  67150. declare module BABYLON {
  67151. /**
  67152. * Interface for cullable objects
  67153. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  67154. */
  67155. export interface ICullable {
  67156. /**
  67157. * Checks if the object or part of the object is in the frustum
  67158. * @param frustumPlanes Camera near/planes
  67159. * @returns true if the object is in frustum otherwise false
  67160. */
  67161. isInFrustum(frustumPlanes: Plane[]): boolean;
  67162. /**
  67163. * Checks if a cullable object (mesh...) is in the camera frustum
  67164. * Unlike isInFrustum this cheks the full bounding box
  67165. * @param frustumPlanes Camera near/planes
  67166. * @returns true if the object is in frustum otherwise false
  67167. */
  67168. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  67169. }
  67170. /**
  67171. * Info for a bounding data of a mesh
  67172. */
  67173. export class BoundingInfo implements ICullable {
  67174. /**
  67175. * Bounding box for the mesh
  67176. */
  67177. readonly boundingBox: BoundingBox;
  67178. /**
  67179. * Bounding sphere for the mesh
  67180. */
  67181. readonly boundingSphere: BoundingSphere;
  67182. private _isLocked;
  67183. private static readonly TmpVector3;
  67184. /**
  67185. * Constructs bounding info
  67186. * @param minimum min vector of the bounding box/sphere
  67187. * @param maximum max vector of the bounding box/sphere
  67188. * @param worldMatrix defines the new world matrix
  67189. */
  67190. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  67191. /**
  67192. * Recreates the entire bounding info from scratch as if we call the constructor in place
  67193. * @param min defines the new minimum vector (in local space)
  67194. * @param max defines the new maximum vector (in local space)
  67195. * @param worldMatrix defines the new world matrix
  67196. */
  67197. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  67198. /**
  67199. * min vector of the bounding box/sphere
  67200. */
  67201. readonly minimum: Vector3;
  67202. /**
  67203. * max vector of the bounding box/sphere
  67204. */
  67205. readonly maximum: Vector3;
  67206. /**
  67207. * If the info is locked and won't be updated to avoid perf overhead
  67208. */
  67209. isLocked: boolean;
  67210. /**
  67211. * Updates the bounding sphere and box
  67212. * @param world world matrix to be used to update
  67213. */
  67214. update(world: DeepImmutable<Matrix>): void;
  67215. /**
  67216. * Recreate the bounding info to be centered around a specific point given a specific extend.
  67217. * @param center New center of the bounding info
  67218. * @param extend New extend of the bounding info
  67219. * @returns the current bounding info
  67220. */
  67221. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  67222. /**
  67223. * Scale the current bounding info by applying a scale factor
  67224. * @param factor defines the scale factor to apply
  67225. * @returns the current bounding info
  67226. */
  67227. scale(factor: number): BoundingInfo;
  67228. /**
  67229. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  67230. * @param frustumPlanes defines the frustum to test
  67231. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  67232. * @returns true if the bounding info is in the frustum planes
  67233. */
  67234. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  67235. /**
  67236. * Gets the world distance between the min and max points of the bounding box
  67237. */
  67238. readonly diagonalLength: number;
  67239. /**
  67240. * Checks if a cullable object (mesh...) is in the camera frustum
  67241. * Unlike isInFrustum this cheks the full bounding box
  67242. * @param frustumPlanes Camera near/planes
  67243. * @returns true if the object is in frustum otherwise false
  67244. */
  67245. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  67246. /** @hidden */
  67247. _checkCollision(collider: Collider): boolean;
  67248. /**
  67249. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  67250. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  67251. * @param point the point to check intersection with
  67252. * @returns if the point intersects
  67253. */
  67254. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  67255. /**
  67256. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  67257. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  67258. * @param boundingInfo the bounding info to check intersection with
  67259. * @param precise if the intersection should be done using OBB
  67260. * @returns if the bounding info intersects
  67261. */
  67262. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  67263. }
  67264. }
  67265. declare module BABYLON {
  67266. /**
  67267. * Defines an array and its length.
  67268. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  67269. */
  67270. export interface ISmartArrayLike<T> {
  67271. /**
  67272. * The data of the array.
  67273. */
  67274. data: Array<T>;
  67275. /**
  67276. * The active length of the array.
  67277. */
  67278. length: number;
  67279. }
  67280. /**
  67281. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  67282. */
  67283. export class SmartArray<T> implements ISmartArrayLike<T> {
  67284. /**
  67285. * The full set of data from the array.
  67286. */
  67287. data: Array<T>;
  67288. /**
  67289. * The active length of the array.
  67290. */
  67291. length: number;
  67292. protected _id: number;
  67293. /**
  67294. * Instantiates a Smart Array.
  67295. * @param capacity defines the default capacity of the array.
  67296. */
  67297. constructor(capacity: number);
  67298. /**
  67299. * Pushes a value at the end of the active data.
  67300. * @param value defines the object to push in the array.
  67301. */
  67302. push(value: T): void;
  67303. /**
  67304. * Iterates over the active data and apply the lambda to them.
  67305. * @param func defines the action to apply on each value.
  67306. */
  67307. forEach(func: (content: T) => void): void;
  67308. /**
  67309. * Sorts the full sets of data.
  67310. * @param compareFn defines the comparison function to apply.
  67311. */
  67312. sort(compareFn: (a: T, b: T) => number): void;
  67313. /**
  67314. * Resets the active data to an empty array.
  67315. */
  67316. reset(): void;
  67317. /**
  67318. * Releases all the data from the array as well as the array.
  67319. */
  67320. dispose(): void;
  67321. /**
  67322. * Concats the active data with a given array.
  67323. * @param array defines the data to concatenate with.
  67324. */
  67325. concat(array: any): void;
  67326. /**
  67327. * Returns the position of a value in the active data.
  67328. * @param value defines the value to find the index for
  67329. * @returns the index if found in the active data otherwise -1
  67330. */
  67331. indexOf(value: T): number;
  67332. /**
  67333. * Returns whether an element is part of the active data.
  67334. * @param value defines the value to look for
  67335. * @returns true if found in the active data otherwise false
  67336. */
  67337. contains(value: T): boolean;
  67338. private static _GlobalId;
  67339. }
  67340. /**
  67341. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  67342. * The data in this array can only be present once
  67343. */
  67344. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  67345. private _duplicateId;
  67346. /**
  67347. * Pushes a value at the end of the active data.
  67348. * THIS DOES NOT PREVENT DUPPLICATE DATA
  67349. * @param value defines the object to push in the array.
  67350. */
  67351. push(value: T): void;
  67352. /**
  67353. * Pushes a value at the end of the active data.
  67354. * If the data is already present, it won t be added again
  67355. * @param value defines the object to push in the array.
  67356. * @returns true if added false if it was already present
  67357. */
  67358. pushNoDuplicate(value: T): boolean;
  67359. /**
  67360. * Resets the active data to an empty array.
  67361. */
  67362. reset(): void;
  67363. /**
  67364. * Concats the active data with a given array.
  67365. * This ensures no dupplicate will be present in the result.
  67366. * @param array defines the data to concatenate with.
  67367. */
  67368. concatWithNoDuplicate(array: any): void;
  67369. }
  67370. }
  67371. declare module BABYLON {
  67372. /**
  67373. * A multi-material is used to apply different materials to different parts of the same object without the need of
  67374. * separate meshes. This can be use to improve performances.
  67375. * @see http://doc.babylonjs.com/how_to/multi_materials
  67376. */
  67377. export class MultiMaterial extends Material {
  67378. private _subMaterials;
  67379. /**
  67380. * Gets or Sets the list of Materials used within the multi material.
  67381. * They need to be ordered according to the submeshes order in the associated mesh
  67382. */
  67383. subMaterials: Nullable<Material>[];
  67384. /**
  67385. * Function used to align with Node.getChildren()
  67386. * @returns the list of Materials used within the multi material
  67387. */
  67388. getChildren(): Nullable<Material>[];
  67389. /**
  67390. * Instantiates a new Multi Material
  67391. * A multi-material is used to apply different materials to different parts of the same object without the need of
  67392. * separate meshes. This can be use to improve performances.
  67393. * @see http://doc.babylonjs.com/how_to/multi_materials
  67394. * @param name Define the name in the scene
  67395. * @param scene Define the scene the material belongs to
  67396. */
  67397. constructor(name: string, scene: Scene);
  67398. private _hookArray;
  67399. /**
  67400. * Get one of the submaterial by its index in the submaterials array
  67401. * @param index The index to look the sub material at
  67402. * @returns The Material if the index has been defined
  67403. */
  67404. getSubMaterial(index: number): Nullable<Material>;
  67405. /**
  67406. * Get the list of active textures for the whole sub materials list.
  67407. * @returns All the textures that will be used during the rendering
  67408. */
  67409. getActiveTextures(): BaseTexture[];
  67410. /**
  67411. * Gets the current class name of the material e.g. "MultiMaterial"
  67412. * Mainly use in serialization.
  67413. * @returns the class name
  67414. */
  67415. getClassName(): string;
  67416. /**
  67417. * Checks if the material is ready to render the requested sub mesh
  67418. * @param mesh Define the mesh the submesh belongs to
  67419. * @param subMesh Define the sub mesh to look readyness for
  67420. * @param useInstances Define whether or not the material is used with instances
  67421. * @returns true if ready, otherwise false
  67422. */
  67423. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  67424. /**
  67425. * Clones the current material and its related sub materials
  67426. * @param name Define the name of the newly cloned material
  67427. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  67428. * @returns the cloned material
  67429. */
  67430. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  67431. /**
  67432. * Serializes the materials into a JSON representation.
  67433. * @returns the JSON representation
  67434. */
  67435. serialize(): any;
  67436. /**
  67437. * Dispose the material and release its associated resources
  67438. * @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)
  67439. * @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)
  67440. * @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)
  67441. */
  67442. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  67443. /**
  67444. * Creates a MultiMaterial from parsed MultiMaterial data.
  67445. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  67446. * @param scene defines the hosting scene
  67447. * @returns a new MultiMaterial
  67448. */
  67449. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  67450. }
  67451. }
  67452. declare module BABYLON {
  67453. /**
  67454. * Class used to represent data loading progression
  67455. */
  67456. export class SceneLoaderFlags {
  67457. private static _ForceFullSceneLoadingForIncremental;
  67458. private static _ShowLoadingScreen;
  67459. private static _CleanBoneMatrixWeights;
  67460. private static _loggingLevel;
  67461. /**
  67462. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  67463. */
  67464. static ForceFullSceneLoadingForIncremental: boolean;
  67465. /**
  67466. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  67467. */
  67468. static ShowLoadingScreen: boolean;
  67469. /**
  67470. * Defines the current logging level (while loading the scene)
  67471. * @ignorenaming
  67472. */
  67473. static loggingLevel: number;
  67474. /**
  67475. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  67476. */
  67477. static CleanBoneMatrixWeights: boolean;
  67478. }
  67479. }
  67480. declare module BABYLON {
  67481. /**
  67482. * 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.
  67483. * @see https://doc.babylonjs.com/how_to/transformnode
  67484. */
  67485. export class TransformNode extends Node {
  67486. /**
  67487. * Object will not rotate to face the camera
  67488. */
  67489. static BILLBOARDMODE_NONE: number;
  67490. /**
  67491. * Object will rotate to face the camera but only on the x axis
  67492. */
  67493. static BILLBOARDMODE_X: number;
  67494. /**
  67495. * Object will rotate to face the camera but only on the y axis
  67496. */
  67497. static BILLBOARDMODE_Y: number;
  67498. /**
  67499. * Object will rotate to face the camera but only on the z axis
  67500. */
  67501. static BILLBOARDMODE_Z: number;
  67502. /**
  67503. * Object will rotate to face the camera
  67504. */
  67505. static BILLBOARDMODE_ALL: number;
  67506. private _forward;
  67507. private _forwardInverted;
  67508. private _up;
  67509. private _right;
  67510. private _rightInverted;
  67511. private _position;
  67512. private _rotation;
  67513. private _rotationQuaternion;
  67514. protected _scaling: Vector3;
  67515. protected _isDirty: boolean;
  67516. private _transformToBoneReferal;
  67517. private _billboardMode;
  67518. /**
  67519. * Gets or sets the billboard mode. Default is 0.
  67520. *
  67521. * | Value | Type | Description |
  67522. * | --- | --- | --- |
  67523. * | 0 | BILLBOARDMODE_NONE | |
  67524. * | 1 | BILLBOARDMODE_X | |
  67525. * | 2 | BILLBOARDMODE_Y | |
  67526. * | 4 | BILLBOARDMODE_Z | |
  67527. * | 7 | BILLBOARDMODE_ALL | |
  67528. *
  67529. */
  67530. billboardMode: number;
  67531. private _preserveParentRotationForBillboard;
  67532. /**
  67533. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  67534. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  67535. */
  67536. preserveParentRotationForBillboard: boolean;
  67537. /**
  67538. * 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
  67539. */
  67540. scalingDeterminant: number;
  67541. private _infiniteDistance;
  67542. /**
  67543. * Gets or sets the distance of the object to max, often used by skybox
  67544. */
  67545. infiniteDistance: boolean;
  67546. /**
  67547. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  67548. * By default the system will update normals to compensate
  67549. */
  67550. ignoreNonUniformScaling: boolean;
  67551. /**
  67552. * Gets or sets a boolean indicating that even if rotationQuaternion is defined, you can keep updating rotation property and Babylon.js will just mix both
  67553. */
  67554. reIntegrateRotationIntoRotationQuaternion: boolean;
  67555. /** @hidden */
  67556. _poseMatrix: Nullable<Matrix>;
  67557. /** @hidden */
  67558. _localMatrix: Matrix;
  67559. private _usePivotMatrix;
  67560. private _absolutePosition;
  67561. private _pivotMatrix;
  67562. private _pivotMatrixInverse;
  67563. protected _postMultiplyPivotMatrix: boolean;
  67564. protected _isWorldMatrixFrozen: boolean;
  67565. /** @hidden */
  67566. _indexInSceneTransformNodesArray: number;
  67567. /**
  67568. * An event triggered after the world matrix is updated
  67569. */
  67570. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  67571. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  67572. /**
  67573. * Gets a string identifying the name of the class
  67574. * @returns "TransformNode" string
  67575. */
  67576. getClassName(): string;
  67577. /**
  67578. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  67579. */
  67580. position: Vector3;
  67581. /**
  67582. * 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)).
  67583. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  67584. */
  67585. rotation: Vector3;
  67586. /**
  67587. * 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)).
  67588. */
  67589. scaling: Vector3;
  67590. /**
  67591. * 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).
  67592. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  67593. */
  67594. rotationQuaternion: Nullable<Quaternion>;
  67595. /**
  67596. * The forward direction of that transform in world space.
  67597. */
  67598. readonly forward: Vector3;
  67599. /**
  67600. * The up direction of that transform in world space.
  67601. */
  67602. readonly up: Vector3;
  67603. /**
  67604. * The right direction of that transform in world space.
  67605. */
  67606. readonly right: Vector3;
  67607. /**
  67608. * Copies the parameter passed Matrix into the mesh Pose matrix.
  67609. * @param matrix the matrix to copy the pose from
  67610. * @returns this TransformNode.
  67611. */
  67612. updatePoseMatrix(matrix: Matrix): TransformNode;
  67613. /**
  67614. * Returns the mesh Pose matrix.
  67615. * @returns the pose matrix
  67616. */
  67617. getPoseMatrix(): Matrix;
  67618. /** @hidden */
  67619. _isSynchronized(): boolean;
  67620. /** @hidden */
  67621. _initCache(): void;
  67622. /**
  67623. * Flag the transform node as dirty (Forcing it to update everything)
  67624. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  67625. * @returns this transform node
  67626. */
  67627. markAsDirty(property: string): TransformNode;
  67628. /**
  67629. * Returns the current mesh absolute position.
  67630. * Returns a Vector3.
  67631. */
  67632. readonly absolutePosition: Vector3;
  67633. /**
  67634. * Sets a new matrix to apply before all other transformation
  67635. * @param matrix defines the transform matrix
  67636. * @returns the current TransformNode
  67637. */
  67638. setPreTransformMatrix(matrix: Matrix): TransformNode;
  67639. /**
  67640. * Sets a new pivot matrix to the current node
  67641. * @param matrix defines the new pivot matrix to use
  67642. * @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
  67643. * @returns the current TransformNode
  67644. */
  67645. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  67646. /**
  67647. * Returns the mesh pivot matrix.
  67648. * Default : Identity.
  67649. * @returns the matrix
  67650. */
  67651. getPivotMatrix(): Matrix;
  67652. /**
  67653. * Prevents the World matrix to be computed any longer.
  67654. * @returns the TransformNode.
  67655. */
  67656. freezeWorldMatrix(): TransformNode;
  67657. /**
  67658. * Allows back the World matrix computation.
  67659. * @returns the TransformNode.
  67660. */
  67661. unfreezeWorldMatrix(): this;
  67662. /**
  67663. * True if the World matrix has been frozen.
  67664. */
  67665. readonly isWorldMatrixFrozen: boolean;
  67666. /**
  67667. * Retuns the mesh absolute position in the World.
  67668. * @returns a Vector3.
  67669. */
  67670. getAbsolutePosition(): Vector3;
  67671. /**
  67672. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  67673. * @param absolutePosition the absolute position to set
  67674. * @returns the TransformNode.
  67675. */
  67676. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  67677. /**
  67678. * Sets the mesh position in its local space.
  67679. * @param vector3 the position to set in localspace
  67680. * @returns the TransformNode.
  67681. */
  67682. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  67683. /**
  67684. * Returns the mesh position in the local space from the current World matrix values.
  67685. * @returns a new Vector3.
  67686. */
  67687. getPositionExpressedInLocalSpace(): Vector3;
  67688. /**
  67689. * Translates the mesh along the passed Vector3 in its local space.
  67690. * @param vector3 the distance to translate in localspace
  67691. * @returns the TransformNode.
  67692. */
  67693. locallyTranslate(vector3: Vector3): TransformNode;
  67694. private static _lookAtVectorCache;
  67695. /**
  67696. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  67697. * @param targetPoint the position (must be in same space as current mesh) to look at
  67698. * @param yawCor optional yaw (y-axis) correction in radians
  67699. * @param pitchCor optional pitch (x-axis) correction in radians
  67700. * @param rollCor optional roll (z-axis) correction in radians
  67701. * @param space the choosen space of the target
  67702. * @returns the TransformNode.
  67703. */
  67704. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  67705. /**
  67706. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  67707. * This Vector3 is expressed in the World space.
  67708. * @param localAxis axis to rotate
  67709. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  67710. */
  67711. getDirection(localAxis: Vector3): Vector3;
  67712. /**
  67713. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  67714. * localAxis is expressed in the mesh local space.
  67715. * result is computed in the Wordl space from the mesh World matrix.
  67716. * @param localAxis axis to rotate
  67717. * @param result the resulting transformnode
  67718. * @returns this TransformNode.
  67719. */
  67720. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  67721. /**
  67722. * Sets this transform node rotation to the given local axis.
  67723. * @param localAxis the axis in local space
  67724. * @param yawCor optional yaw (y-axis) correction in radians
  67725. * @param pitchCor optional pitch (x-axis) correction in radians
  67726. * @param rollCor optional roll (z-axis) correction in radians
  67727. * @returns this TransformNode
  67728. */
  67729. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  67730. /**
  67731. * Sets a new pivot point to the current node
  67732. * @param point defines the new pivot point to use
  67733. * @param space defines if the point is in world or local space (local by default)
  67734. * @returns the current TransformNode
  67735. */
  67736. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  67737. /**
  67738. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  67739. * @returns the pivot point
  67740. */
  67741. getPivotPoint(): Vector3;
  67742. /**
  67743. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  67744. * @param result the vector3 to store the result
  67745. * @returns this TransformNode.
  67746. */
  67747. getPivotPointToRef(result: Vector3): TransformNode;
  67748. /**
  67749. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  67750. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  67751. */
  67752. getAbsolutePivotPoint(): Vector3;
  67753. /**
  67754. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  67755. * @param result vector3 to store the result
  67756. * @returns this TransformNode.
  67757. */
  67758. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  67759. /**
  67760. * Defines the passed node as the parent of the current node.
  67761. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  67762. * @see https://doc.babylonjs.com/how_to/parenting
  67763. * @param node the node ot set as the parent
  67764. * @returns this TransformNode.
  67765. */
  67766. setParent(node: Nullable<Node>): TransformNode;
  67767. private _nonUniformScaling;
  67768. /**
  67769. * True if the scaling property of this object is non uniform eg. (1,2,1)
  67770. */
  67771. readonly nonUniformScaling: boolean;
  67772. /** @hidden */
  67773. _updateNonUniformScalingState(value: boolean): boolean;
  67774. /**
  67775. * Attach the current TransformNode to another TransformNode associated with a bone
  67776. * @param bone Bone affecting the TransformNode
  67777. * @param affectedTransformNode TransformNode associated with the bone
  67778. * @returns this object
  67779. */
  67780. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  67781. /**
  67782. * Detach the transform node if its associated with a bone
  67783. * @returns this object
  67784. */
  67785. detachFromBone(): TransformNode;
  67786. private static _rotationAxisCache;
  67787. /**
  67788. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  67789. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  67790. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  67791. * The passed axis is also normalized.
  67792. * @param axis the axis to rotate around
  67793. * @param amount the amount to rotate in radians
  67794. * @param space Space to rotate in (Default: local)
  67795. * @returns the TransformNode.
  67796. */
  67797. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  67798. /**
  67799. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  67800. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  67801. * The passed axis is also normalized. .
  67802. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  67803. * @param point the point to rotate around
  67804. * @param axis the axis to rotate around
  67805. * @param amount the amount to rotate in radians
  67806. * @returns the TransformNode
  67807. */
  67808. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  67809. /**
  67810. * Translates the mesh along the axis vector for the passed distance in the given space.
  67811. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  67812. * @param axis the axis to translate in
  67813. * @param distance the distance to translate
  67814. * @param space Space to rotate in (Default: local)
  67815. * @returns the TransformNode.
  67816. */
  67817. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  67818. /**
  67819. * Adds a rotation step to the mesh current rotation.
  67820. * x, y, z are Euler angles expressed in radians.
  67821. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  67822. * This means this rotation is made in the mesh local space only.
  67823. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  67824. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  67825. * ```javascript
  67826. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  67827. * ```
  67828. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  67829. * 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.
  67830. * @param x Rotation to add
  67831. * @param y Rotation to add
  67832. * @param z Rotation to add
  67833. * @returns the TransformNode.
  67834. */
  67835. addRotation(x: number, y: number, z: number): TransformNode;
  67836. /**
  67837. * @hidden
  67838. */
  67839. protected _getEffectiveParent(): Nullable<Node>;
  67840. /**
  67841. * Computes the world matrix of the node
  67842. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  67843. * @returns the world matrix
  67844. */
  67845. computeWorldMatrix(force?: boolean): Matrix;
  67846. protected _afterComputeWorldMatrix(): void;
  67847. /**
  67848. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  67849. * @param func callback function to add
  67850. *
  67851. * @returns the TransformNode.
  67852. */
  67853. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  67854. /**
  67855. * Removes a registered callback function.
  67856. * @param func callback function to remove
  67857. * @returns the TransformNode.
  67858. */
  67859. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  67860. /**
  67861. * Gets the position of the current mesh in camera space
  67862. * @param camera defines the camera to use
  67863. * @returns a position
  67864. */
  67865. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  67866. /**
  67867. * Returns the distance from the mesh to the active camera
  67868. * @param camera defines the camera to use
  67869. * @returns the distance
  67870. */
  67871. getDistanceToCamera(camera?: Nullable<Camera>): number;
  67872. /**
  67873. * Clone the current transform node
  67874. * @param name Name of the new clone
  67875. * @param newParent New parent for the clone
  67876. * @param doNotCloneChildren Do not clone children hierarchy
  67877. * @returns the new transform node
  67878. */
  67879. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  67880. /**
  67881. * Serializes the objects information.
  67882. * @param currentSerializationObject defines the object to serialize in
  67883. * @returns the serialized object
  67884. */
  67885. serialize(currentSerializationObject?: any): any;
  67886. /**
  67887. * Returns a new TransformNode object parsed from the source provided.
  67888. * @param parsedTransformNode is the source.
  67889. * @param scene the scne the object belongs to
  67890. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  67891. * @returns a new TransformNode object parsed from the source provided.
  67892. */
  67893. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  67894. /**
  67895. * Get all child-transformNodes of this node
  67896. * @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
  67897. * @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
  67898. * @returns an array of TransformNode
  67899. */
  67900. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  67901. /**
  67902. * Releases resources associated with this transform node.
  67903. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  67904. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  67905. */
  67906. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  67907. }
  67908. }
  67909. declare module BABYLON {
  67910. /**
  67911. * Class used to override all child animations of a given target
  67912. */
  67913. export class AnimationPropertiesOverride {
  67914. /**
  67915. * Gets or sets a value indicating if animation blending must be used
  67916. */
  67917. enableBlending: boolean;
  67918. /**
  67919. * Gets or sets the blending speed to use when enableBlending is true
  67920. */
  67921. blendingSpeed: number;
  67922. /**
  67923. * Gets or sets the default loop mode to use
  67924. */
  67925. loopMode: number;
  67926. }
  67927. }
  67928. declare module BABYLON {
  67929. /**
  67930. * Class used to store bone information
  67931. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  67932. */
  67933. export class Bone extends Node {
  67934. /**
  67935. * defines the bone name
  67936. */
  67937. name: string;
  67938. private static _tmpVecs;
  67939. private static _tmpQuat;
  67940. private static _tmpMats;
  67941. /**
  67942. * Gets the list of child bones
  67943. */
  67944. children: Bone[];
  67945. /** Gets the animations associated with this bone */
  67946. animations: Animation[];
  67947. /**
  67948. * Gets or sets bone length
  67949. */
  67950. length: number;
  67951. /**
  67952. * @hidden Internal only
  67953. * Set this value to map this bone to a different index in the transform matrices
  67954. * Set this value to -1 to exclude the bone from the transform matrices
  67955. */
  67956. _index: Nullable<number>;
  67957. private _skeleton;
  67958. private _localMatrix;
  67959. private _restPose;
  67960. private _baseMatrix;
  67961. private _absoluteTransform;
  67962. private _invertedAbsoluteTransform;
  67963. private _parent;
  67964. private _scalingDeterminant;
  67965. private _worldTransform;
  67966. private _localScaling;
  67967. private _localRotation;
  67968. private _localPosition;
  67969. private _needToDecompose;
  67970. private _needToCompose;
  67971. /** @hidden */
  67972. _linkedTransformNode: Nullable<TransformNode>;
  67973. /** @hidden */
  67974. _waitingTransformNodeId: Nullable<string>;
  67975. /** @hidden */
  67976. /** @hidden */
  67977. _matrix: Matrix;
  67978. /**
  67979. * Create a new bone
  67980. * @param name defines the bone name
  67981. * @param skeleton defines the parent skeleton
  67982. * @param parentBone defines the parent (can be null if the bone is the root)
  67983. * @param localMatrix defines the local matrix
  67984. * @param restPose defines the rest pose matrix
  67985. * @param baseMatrix defines the base matrix
  67986. * @param index defines index of the bone in the hiearchy
  67987. */
  67988. constructor(
  67989. /**
  67990. * defines the bone name
  67991. */
  67992. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  67993. /**
  67994. * Gets the current object class name.
  67995. * @return the class name
  67996. */
  67997. getClassName(): string;
  67998. /**
  67999. * Gets the parent skeleton
  68000. * @returns a skeleton
  68001. */
  68002. getSkeleton(): Skeleton;
  68003. /**
  68004. * Gets parent bone
  68005. * @returns a bone or null if the bone is the root of the bone hierarchy
  68006. */
  68007. getParent(): Nullable<Bone>;
  68008. /**
  68009. * Returns an array containing the root bones
  68010. * @returns an array containing the root bones
  68011. */
  68012. getChildren(): Array<Bone>;
  68013. /**
  68014. * Sets the parent bone
  68015. * @param parent defines the parent (can be null if the bone is the root)
  68016. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  68017. */
  68018. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  68019. /**
  68020. * Gets the local matrix
  68021. * @returns a matrix
  68022. */
  68023. getLocalMatrix(): Matrix;
  68024. /**
  68025. * Gets the base matrix (initial matrix which remains unchanged)
  68026. * @returns a matrix
  68027. */
  68028. getBaseMatrix(): Matrix;
  68029. /**
  68030. * Gets the rest pose matrix
  68031. * @returns a matrix
  68032. */
  68033. getRestPose(): Matrix;
  68034. /**
  68035. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  68036. */
  68037. getWorldMatrix(): Matrix;
  68038. /**
  68039. * Sets the local matrix to rest pose matrix
  68040. */
  68041. returnToRest(): void;
  68042. /**
  68043. * Gets the inverse of the absolute transform matrix.
  68044. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  68045. * @returns a matrix
  68046. */
  68047. getInvertedAbsoluteTransform(): Matrix;
  68048. /**
  68049. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  68050. * @returns a matrix
  68051. */
  68052. getAbsoluteTransform(): Matrix;
  68053. /**
  68054. * Links with the given transform node.
  68055. * The local matrix of this bone is copied from the transform node every frame.
  68056. * @param transformNode defines the transform node to link to
  68057. */
  68058. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  68059. /** Gets or sets current position (in local space) */
  68060. position: Vector3;
  68061. /** Gets or sets current rotation (in local space) */
  68062. rotation: Vector3;
  68063. /** Gets or sets current rotation quaternion (in local space) */
  68064. rotationQuaternion: Quaternion;
  68065. /** Gets or sets current scaling (in local space) */
  68066. scaling: Vector3;
  68067. /**
  68068. * Gets the animation properties override
  68069. */
  68070. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  68071. private _decompose;
  68072. private _compose;
  68073. /**
  68074. * Update the base and local matrices
  68075. * @param matrix defines the new base or local matrix
  68076. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  68077. * @param updateLocalMatrix defines if the local matrix should be updated
  68078. */
  68079. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  68080. /** @hidden */
  68081. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  68082. /**
  68083. * Flag the bone as dirty (Forcing it to update everything)
  68084. */
  68085. markAsDirty(): void;
  68086. private _markAsDirtyAndCompose;
  68087. private _markAsDirtyAndDecompose;
  68088. /**
  68089. * Translate the bone in local or world space
  68090. * @param vec The amount to translate the bone
  68091. * @param space The space that the translation is in
  68092. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68093. */
  68094. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  68095. /**
  68096. * Set the postion of the bone in local or world space
  68097. * @param position The position to set the bone
  68098. * @param space The space that the position is in
  68099. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68100. */
  68101. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  68102. /**
  68103. * Set the absolute position of the bone (world space)
  68104. * @param position The position to set the bone
  68105. * @param mesh The mesh that this bone is attached to
  68106. */
  68107. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  68108. /**
  68109. * Scale the bone on the x, y and z axes (in local space)
  68110. * @param x The amount to scale the bone on the x axis
  68111. * @param y The amount to scale the bone on the y axis
  68112. * @param z The amount to scale the bone on the z axis
  68113. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  68114. */
  68115. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  68116. /**
  68117. * Set the bone scaling in local space
  68118. * @param scale defines the scaling vector
  68119. */
  68120. setScale(scale: Vector3): void;
  68121. /**
  68122. * Gets the current scaling in local space
  68123. * @returns the current scaling vector
  68124. */
  68125. getScale(): Vector3;
  68126. /**
  68127. * Gets the current scaling in local space and stores it in a target vector
  68128. * @param result defines the target vector
  68129. */
  68130. getScaleToRef(result: Vector3): void;
  68131. /**
  68132. * Set the yaw, pitch, and roll of the bone in local or world space
  68133. * @param yaw The rotation of the bone on the y axis
  68134. * @param pitch The rotation of the bone on the x axis
  68135. * @param roll The rotation of the bone on the z axis
  68136. * @param space The space that the axes of rotation are in
  68137. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68138. */
  68139. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  68140. /**
  68141. * Add a rotation to the bone on an axis in local or world space
  68142. * @param axis The axis to rotate the bone on
  68143. * @param amount The amount to rotate the bone
  68144. * @param space The space that the axis is in
  68145. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68146. */
  68147. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  68148. /**
  68149. * Set the rotation of the bone to a particular axis angle in local or world space
  68150. * @param axis The axis to rotate the bone on
  68151. * @param angle The angle that the bone should be rotated to
  68152. * @param space The space that the axis is in
  68153. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68154. */
  68155. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  68156. /**
  68157. * Set the euler rotation of the bone in local of world space
  68158. * @param rotation The euler rotation that the bone should be set to
  68159. * @param space The space that the rotation is in
  68160. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68161. */
  68162. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  68163. /**
  68164. * Set the quaternion rotation of the bone in local of world space
  68165. * @param quat The quaternion rotation that the bone should be set to
  68166. * @param space The space that the rotation is in
  68167. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68168. */
  68169. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  68170. /**
  68171. * Set the rotation matrix of the bone in local of world space
  68172. * @param rotMat The rotation matrix that the bone should be set to
  68173. * @param space The space that the rotation is in
  68174. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68175. */
  68176. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  68177. private _rotateWithMatrix;
  68178. private _getNegativeRotationToRef;
  68179. /**
  68180. * Get the position of the bone in local or world space
  68181. * @param space The space that the returned position is in
  68182. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68183. * @returns The position of the bone
  68184. */
  68185. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  68186. /**
  68187. * Copy the position of the bone to a vector3 in local or world space
  68188. * @param space The space that the returned position is in
  68189. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68190. * @param result The vector3 to copy the position to
  68191. */
  68192. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  68193. /**
  68194. * Get the absolute position of the bone (world space)
  68195. * @param mesh The mesh that this bone is attached to
  68196. * @returns The absolute position of the bone
  68197. */
  68198. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  68199. /**
  68200. * Copy the absolute position of the bone (world space) to the result param
  68201. * @param mesh The mesh that this bone is attached to
  68202. * @param result The vector3 to copy the absolute position to
  68203. */
  68204. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  68205. /**
  68206. * Compute the absolute transforms of this bone and its children
  68207. */
  68208. computeAbsoluteTransforms(): void;
  68209. /**
  68210. * Get the world direction from an axis that is in the local space of the bone
  68211. * @param localAxis The local direction that is used to compute the world direction
  68212. * @param mesh The mesh that this bone is attached to
  68213. * @returns The world direction
  68214. */
  68215. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  68216. /**
  68217. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  68218. * @param localAxis The local direction that is used to compute the world direction
  68219. * @param mesh The mesh that this bone is attached to
  68220. * @param result The vector3 that the world direction will be copied to
  68221. */
  68222. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  68223. /**
  68224. * Get the euler rotation of the bone in local or world space
  68225. * @param space The space that the rotation should be in
  68226. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68227. * @returns The euler rotation
  68228. */
  68229. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  68230. /**
  68231. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  68232. * @param space The space that the rotation should be in
  68233. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68234. * @param result The vector3 that the rotation should be copied to
  68235. */
  68236. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  68237. /**
  68238. * Get the quaternion rotation of the bone in either local or world space
  68239. * @param space The space that the rotation should be in
  68240. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68241. * @returns The quaternion rotation
  68242. */
  68243. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  68244. /**
  68245. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  68246. * @param space The space that the rotation should be in
  68247. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68248. * @param result The quaternion that the rotation should be copied to
  68249. */
  68250. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  68251. /**
  68252. * Get the rotation matrix of the bone in local or world space
  68253. * @param space The space that the rotation should be in
  68254. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68255. * @returns The rotation matrix
  68256. */
  68257. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  68258. /**
  68259. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  68260. * @param space The space that the rotation should be in
  68261. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68262. * @param result The quaternion that the rotation should be copied to
  68263. */
  68264. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  68265. /**
  68266. * Get the world position of a point that is in the local space of the bone
  68267. * @param position The local position
  68268. * @param mesh The mesh that this bone is attached to
  68269. * @returns The world position
  68270. */
  68271. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  68272. /**
  68273. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  68274. * @param position The local position
  68275. * @param mesh The mesh that this bone is attached to
  68276. * @param result The vector3 that the world position should be copied to
  68277. */
  68278. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  68279. /**
  68280. * Get the local position of a point that is in world space
  68281. * @param position The world position
  68282. * @param mesh The mesh that this bone is attached to
  68283. * @returns The local position
  68284. */
  68285. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  68286. /**
  68287. * Get the local position of a point that is in world space and copy it to the result param
  68288. * @param position The world position
  68289. * @param mesh The mesh that this bone is attached to
  68290. * @param result The vector3 that the local position should be copied to
  68291. */
  68292. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  68293. }
  68294. }
  68295. declare module BABYLON {
  68296. /**
  68297. * Enum that determines the text-wrapping mode to use.
  68298. */
  68299. export enum InspectableType {
  68300. /**
  68301. * Checkbox for booleans
  68302. */
  68303. Checkbox = 0,
  68304. /**
  68305. * Sliders for numbers
  68306. */
  68307. Slider = 1,
  68308. /**
  68309. * Vector3
  68310. */
  68311. Vector3 = 2,
  68312. /**
  68313. * Quaternions
  68314. */
  68315. Quaternion = 3,
  68316. /**
  68317. * Color3
  68318. */
  68319. Color3 = 4
  68320. }
  68321. /**
  68322. * Interface used to define custom inspectable properties.
  68323. * This interface is used by the inspector to display custom property grids
  68324. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  68325. */
  68326. export interface IInspectable {
  68327. /**
  68328. * Gets the label to display
  68329. */
  68330. label: string;
  68331. /**
  68332. * Gets the name of the property to edit
  68333. */
  68334. propertyName: string;
  68335. /**
  68336. * Gets the type of the editor to use
  68337. */
  68338. type: InspectableType;
  68339. /**
  68340. * Gets the minimum value of the property when using in "slider" mode
  68341. */
  68342. min?: number;
  68343. /**
  68344. * Gets the maximum value of the property when using in "slider" mode
  68345. */
  68346. max?: number;
  68347. /**
  68348. * Gets the setp to use when using in "slider" mode
  68349. */
  68350. step?: number;
  68351. }
  68352. }
  68353. declare module BABYLON {
  68354. /**
  68355. * This represents the required contract to create a new type of texture loader.
  68356. */
  68357. export interface IInternalTextureLoader {
  68358. /**
  68359. * Defines wether the loader supports cascade loading the different faces.
  68360. */
  68361. supportCascades: boolean;
  68362. /**
  68363. * This returns if the loader support the current file information.
  68364. * @param extension defines the file extension of the file being loaded
  68365. * @param textureFormatInUse defines the current compressed format in use iun the engine
  68366. * @param fallback defines the fallback internal texture if any
  68367. * @param isBase64 defines whether the texture is encoded as a base64
  68368. * @param isBuffer defines whether the texture data are stored as a buffer
  68369. * @returns true if the loader can load the specified file
  68370. */
  68371. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  68372. /**
  68373. * Transform the url before loading if required.
  68374. * @param rootUrl the url of the texture
  68375. * @param textureFormatInUse defines the current compressed format in use iun the engine
  68376. * @returns the transformed texture
  68377. */
  68378. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  68379. /**
  68380. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  68381. * @param rootUrl the url of the texture
  68382. * @param textureFormatInUse defines the current compressed format in use iun the engine
  68383. * @returns the fallback texture
  68384. */
  68385. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  68386. /**
  68387. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  68388. * @param data contains the texture data
  68389. * @param texture defines the BabylonJS internal texture
  68390. * @param createPolynomials will be true if polynomials have been requested
  68391. * @param onLoad defines the callback to trigger once the texture is ready
  68392. * @param onError defines the callback to trigger in case of error
  68393. */
  68394. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  68395. /**
  68396. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  68397. * @param data contains the texture data
  68398. * @param texture defines the BabylonJS internal texture
  68399. * @param callback defines the method to call once ready to upload
  68400. */
  68401. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  68402. }
  68403. }
  68404. declare module BABYLON {
  68405. interface Engine {
  68406. /**
  68407. * Creates a depth stencil cube texture.
  68408. * This is only available in WebGL 2.
  68409. * @param size The size of face edge in the cube texture.
  68410. * @param options The options defining the cube texture.
  68411. * @returns The cube texture
  68412. */
  68413. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  68414. /**
  68415. * Creates a cube texture
  68416. * @param rootUrl defines the url where the files to load is located
  68417. * @param scene defines the current scene
  68418. * @param files defines the list of files to load (1 per face)
  68419. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  68420. * @param onLoad defines an optional callback raised when the texture is loaded
  68421. * @param onError defines an optional callback raised if there is an issue to load the texture
  68422. * @param format defines the format of the data
  68423. * @param forcedExtension defines the extension to use to pick the right loader
  68424. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  68425. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  68426. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  68427. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  68428. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  68429. * @returns the cube texture as an InternalTexture
  68430. */
  68431. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>, excludeLoaders: Array<IInternalTextureLoader>): InternalTexture;
  68432. /**
  68433. * Creates a cube texture
  68434. * @param rootUrl defines the url where the files to load is located
  68435. * @param scene defines the current scene
  68436. * @param files defines the list of files to load (1 per face)
  68437. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  68438. * @param onLoad defines an optional callback raised when the texture is loaded
  68439. * @param onError defines an optional callback raised if there is an issue to load the texture
  68440. * @param format defines the format of the data
  68441. * @param forcedExtension defines the extension to use to pick the right loader
  68442. * @returns the cube texture as an InternalTexture
  68443. */
  68444. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any): InternalTexture;
  68445. /**
  68446. * Creates a cube texture
  68447. * @param rootUrl defines the url where the files to load is located
  68448. * @param scene defines the current scene
  68449. * @param files defines the list of files to load (1 per face)
  68450. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  68451. * @param onLoad defines an optional callback raised when the texture is loaded
  68452. * @param onError defines an optional callback raised if there is an issue to load the texture
  68453. * @param format defines the format of the data
  68454. * @param forcedExtension defines the extension to use to pick the right loader
  68455. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  68456. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  68457. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  68458. * @returns the cube texture as an InternalTexture
  68459. */
  68460. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  68461. /** @hidden */
  68462. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  68463. /** @hidden */
  68464. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  68465. /** @hidden */
  68466. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  68467. /** @hidden */
  68468. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  68469. }
  68470. }
  68471. declare module BABYLON {
  68472. /**
  68473. * Class for creating a cube texture
  68474. */
  68475. export class CubeTexture extends BaseTexture {
  68476. private _delayedOnLoad;
  68477. /**
  68478. * The url of the texture
  68479. */
  68480. url: string;
  68481. /**
  68482. * Gets or sets the center of the bounding box associated with the cube texture.
  68483. * It must define where the camera used to render the texture was set
  68484. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  68485. */
  68486. boundingBoxPosition: Vector3;
  68487. private _boundingBoxSize;
  68488. /**
  68489. * Gets or sets the size of the bounding box associated with the cube texture
  68490. * When defined, the cubemap will switch to local mode
  68491. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  68492. * @example https://www.babylonjs-playground.com/#RNASML
  68493. */
  68494. /**
  68495. * Returns the bounding box size
  68496. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  68497. */
  68498. boundingBoxSize: Vector3;
  68499. protected _rotationY: number;
  68500. /**
  68501. * Sets texture matrix rotation angle around Y axis in radians.
  68502. */
  68503. /**
  68504. * Gets texture matrix rotation angle around Y axis radians.
  68505. */
  68506. rotationY: number;
  68507. /**
  68508. * Are mip maps generated for this texture or not.
  68509. */
  68510. readonly noMipmap: boolean;
  68511. private _noMipmap;
  68512. private _files;
  68513. private _extensions;
  68514. private _textureMatrix;
  68515. private _format;
  68516. private _createPolynomials;
  68517. /** @hidden */
  68518. _prefiltered: boolean;
  68519. /**
  68520. * Creates a cube texture from an array of image urls
  68521. * @param files defines an array of image urls
  68522. * @param scene defines the hosting scene
  68523. * @param noMipmap specifies if mip maps are not used
  68524. * @returns a cube texture
  68525. */
  68526. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  68527. /**
  68528. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  68529. * @param url defines the url of the prefiltered texture
  68530. * @param scene defines the scene the texture is attached to
  68531. * @param forcedExtension defines the extension of the file if different from the url
  68532. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  68533. * @return the prefiltered texture
  68534. */
  68535. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  68536. /**
  68537. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  68538. * as prefiltered data.
  68539. * @param rootUrl defines the url of the texture or the root name of the six images
  68540. * @param scene defines the scene the texture is attached to
  68541. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  68542. * @param noMipmap defines if mipmaps should be created or not
  68543. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  68544. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  68545. * @param onError defines a callback triggered in case of error during load
  68546. * @param format defines the internal format to use for the texture once loaded
  68547. * @param prefiltered defines whether or not the texture is created from prefiltered data
  68548. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  68549. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  68550. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  68551. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  68552. * @return the cube texture
  68553. */
  68554. 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);
  68555. /**
  68556. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  68557. */
  68558. readonly isPrefiltered: boolean;
  68559. /**
  68560. * Get the current class name of the texture useful for serialization or dynamic coding.
  68561. * @returns "CubeTexture"
  68562. */
  68563. getClassName(): string;
  68564. /**
  68565. * Update the url (and optional buffer) of this texture if url was null during construction.
  68566. * @param url the url of the texture
  68567. * @param forcedExtension defines the extension to use
  68568. * @param onLoad callback called when the texture is loaded (defaults to null)
  68569. */
  68570. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  68571. /**
  68572. * Delays loading of the cube texture
  68573. * @param forcedExtension defines the extension to use
  68574. */
  68575. delayLoad(forcedExtension?: string): void;
  68576. /**
  68577. * Returns the reflection texture matrix
  68578. * @returns the reflection texture matrix
  68579. */
  68580. getReflectionTextureMatrix(): Matrix;
  68581. /**
  68582. * Sets the reflection texture matrix
  68583. * @param value Reflection texture matrix
  68584. */
  68585. setReflectionTextureMatrix(value: Matrix): void;
  68586. /**
  68587. * Parses text to create a cube texture
  68588. * @param parsedTexture define the serialized text to read from
  68589. * @param scene defines the hosting scene
  68590. * @param rootUrl defines the root url of the cube texture
  68591. * @returns a cube texture
  68592. */
  68593. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  68594. /**
  68595. * Makes a clone, or deep copy, of the cube texture
  68596. * @returns a new cube texture
  68597. */
  68598. clone(): CubeTexture;
  68599. }
  68600. }
  68601. declare module BABYLON {
  68602. /** @hidden */
  68603. export var postprocessVertexShader: {
  68604. name: string;
  68605. shader: string;
  68606. };
  68607. }
  68608. declare module BABYLON {
  68609. /**
  68610. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  68611. * This is the base of the follow, arc rotate cameras and Free camera
  68612. * @see http://doc.babylonjs.com/features/cameras
  68613. */
  68614. export class TargetCamera extends Camera {
  68615. private static _RigCamTransformMatrix;
  68616. private static _TargetTransformMatrix;
  68617. private static _TargetFocalPoint;
  68618. /**
  68619. * Define the current direction the camera is moving to
  68620. */
  68621. cameraDirection: Vector3;
  68622. /**
  68623. * Define the current rotation the camera is rotating to
  68624. */
  68625. cameraRotation: Vector2;
  68626. /**
  68627. * When set, the up vector of the camera will be updated by the rotation of the camera
  68628. */
  68629. updateUpVectorFromRotation: boolean;
  68630. private _tmpQuaternion;
  68631. /**
  68632. * Define the current rotation of the camera
  68633. */
  68634. rotation: Vector3;
  68635. /**
  68636. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  68637. */
  68638. rotationQuaternion: Quaternion;
  68639. /**
  68640. * Define the current speed of the camera
  68641. */
  68642. speed: number;
  68643. /**
  68644. * Add cconstraint to the camera to prevent it to move freely in all directions and
  68645. * around all axis.
  68646. */
  68647. noRotationConstraint: boolean;
  68648. /**
  68649. * Define the current target of the camera as an object or a position.
  68650. */
  68651. lockedTarget: any;
  68652. /** @hidden */
  68653. _currentTarget: Vector3;
  68654. /** @hidden */
  68655. _initialFocalDistance: number;
  68656. /** @hidden */
  68657. _viewMatrix: Matrix;
  68658. /** @hidden */
  68659. _camMatrix: Matrix;
  68660. /** @hidden */
  68661. _cameraTransformMatrix: Matrix;
  68662. /** @hidden */
  68663. _cameraRotationMatrix: Matrix;
  68664. /** @hidden */
  68665. _referencePoint: Vector3;
  68666. /** @hidden */
  68667. _transformedReferencePoint: Vector3;
  68668. protected _globalCurrentTarget: Vector3;
  68669. protected _globalCurrentUpVector: Vector3;
  68670. /** @hidden */
  68671. _reset: () => void;
  68672. private _defaultUp;
  68673. /**
  68674. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  68675. * This is the base of the follow, arc rotate cameras and Free camera
  68676. * @see http://doc.babylonjs.com/features/cameras
  68677. * @param name Defines the name of the camera in the scene
  68678. * @param position Defines the start position of the camera in the scene
  68679. * @param scene Defines the scene the camera belongs to
  68680. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  68681. */
  68682. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  68683. /**
  68684. * Gets the position in front of the camera at a given distance.
  68685. * @param distance The distance from the camera we want the position to be
  68686. * @returns the position
  68687. */
  68688. getFrontPosition(distance: number): Vector3;
  68689. /** @hidden */
  68690. _getLockedTargetPosition(): Nullable<Vector3>;
  68691. private _storedPosition;
  68692. private _storedRotation;
  68693. private _storedRotationQuaternion;
  68694. /**
  68695. * Store current camera state of the camera (fov, position, rotation, etc..)
  68696. * @returns the camera
  68697. */
  68698. storeState(): Camera;
  68699. /**
  68700. * Restored camera state. You must call storeState() first
  68701. * @returns whether it was successful or not
  68702. * @hidden
  68703. */
  68704. _restoreStateValues(): boolean;
  68705. /** @hidden */
  68706. _initCache(): void;
  68707. /** @hidden */
  68708. _updateCache(ignoreParentClass?: boolean): void;
  68709. /** @hidden */
  68710. _isSynchronizedViewMatrix(): boolean;
  68711. /** @hidden */
  68712. _computeLocalCameraSpeed(): number;
  68713. /**
  68714. * Defines the target the camera should look at.
  68715. * This will automatically adapt alpha beta and radius to fit within the new target.
  68716. * @param target Defines the new target as a Vector or a mesh
  68717. */
  68718. setTarget(target: Vector3): void;
  68719. /**
  68720. * Return the current target position of the camera. This value is expressed in local space.
  68721. * @returns the target position
  68722. */
  68723. getTarget(): Vector3;
  68724. /** @hidden */
  68725. _decideIfNeedsToMove(): boolean;
  68726. /** @hidden */
  68727. _updatePosition(): void;
  68728. /** @hidden */
  68729. _checkInputs(): void;
  68730. protected _updateCameraRotationMatrix(): void;
  68731. /**
  68732. * 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)
  68733. * @returns the current camera
  68734. */
  68735. private _rotateUpVectorWithCameraRotationMatrix;
  68736. private _cachedRotationZ;
  68737. private _cachedQuaternionRotationZ;
  68738. /** @hidden */
  68739. _getViewMatrix(): Matrix;
  68740. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  68741. /**
  68742. * @hidden
  68743. */
  68744. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  68745. /**
  68746. * @hidden
  68747. */
  68748. _updateRigCameras(): void;
  68749. private _getRigCamPositionAndTarget;
  68750. /**
  68751. * Gets the current object class name.
  68752. * @return the class name
  68753. */
  68754. getClassName(): string;
  68755. }
  68756. }
  68757. declare module BABYLON {
  68758. /**
  68759. * @ignore
  68760. * This is a list of all the different input types that are available in the application.
  68761. * Fo instance: ArcRotateCameraGamepadInput...
  68762. */
  68763. export var CameraInputTypes: {};
  68764. /**
  68765. * This is the contract to implement in order to create a new input class.
  68766. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  68767. */
  68768. export interface ICameraInput<TCamera extends Camera> {
  68769. /**
  68770. * Defines the camera the input is attached to.
  68771. */
  68772. camera: Nullable<TCamera>;
  68773. /**
  68774. * Gets the class name of the current intput.
  68775. * @returns the class name
  68776. */
  68777. getClassName(): string;
  68778. /**
  68779. * Get the friendly name associated with the input class.
  68780. * @returns the input friendly name
  68781. */
  68782. getSimpleName(): string;
  68783. /**
  68784. * Attach the input controls to a specific dom element to get the input from.
  68785. * @param element Defines the element the controls should be listened from
  68786. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  68787. */
  68788. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  68789. /**
  68790. * Detach the current controls from the specified dom element.
  68791. * @param element Defines the element to stop listening the inputs from
  68792. */
  68793. detachControl(element: Nullable<HTMLElement>): void;
  68794. /**
  68795. * Update the current camera state depending on the inputs that have been used this frame.
  68796. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  68797. */
  68798. checkInputs?: () => void;
  68799. }
  68800. /**
  68801. * Represents a map of input types to input instance or input index to input instance.
  68802. */
  68803. export interface CameraInputsMap<TCamera extends Camera> {
  68804. /**
  68805. * Accessor to the input by input type.
  68806. */
  68807. [name: string]: ICameraInput<TCamera>;
  68808. /**
  68809. * Accessor to the input by input index.
  68810. */
  68811. [idx: number]: ICameraInput<TCamera>;
  68812. }
  68813. /**
  68814. * This represents the input manager used within a camera.
  68815. * It helps dealing with all the different kind of input attached to a camera.
  68816. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  68817. */
  68818. export class CameraInputsManager<TCamera extends Camera> {
  68819. /**
  68820. * Defines the list of inputs attahed to the camera.
  68821. */
  68822. attached: CameraInputsMap<TCamera>;
  68823. /**
  68824. * Defines the dom element the camera is collecting inputs from.
  68825. * This is null if the controls have not been attached.
  68826. */
  68827. attachedElement: Nullable<HTMLElement>;
  68828. /**
  68829. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  68830. */
  68831. noPreventDefault: boolean;
  68832. /**
  68833. * Defined the camera the input manager belongs to.
  68834. */
  68835. camera: TCamera;
  68836. /**
  68837. * Update the current camera state depending on the inputs that have been used this frame.
  68838. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  68839. */
  68840. checkInputs: () => void;
  68841. /**
  68842. * Instantiate a new Camera Input Manager.
  68843. * @param camera Defines the camera the input manager blongs to
  68844. */
  68845. constructor(camera: TCamera);
  68846. /**
  68847. * Add an input method to a camera
  68848. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  68849. * @param input camera input method
  68850. */
  68851. add(input: ICameraInput<TCamera>): void;
  68852. /**
  68853. * Remove a specific input method from a camera
  68854. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  68855. * @param inputToRemove camera input method
  68856. */
  68857. remove(inputToRemove: ICameraInput<TCamera>): void;
  68858. /**
  68859. * Remove a specific input type from a camera
  68860. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  68861. * @param inputType the type of the input to remove
  68862. */
  68863. removeByType(inputType: string): void;
  68864. private _addCheckInputs;
  68865. /**
  68866. * Attach the input controls to the currently attached dom element to listen the events from.
  68867. * @param input Defines the input to attach
  68868. */
  68869. attachInput(input: ICameraInput<TCamera>): void;
  68870. /**
  68871. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  68872. * @param element Defines the dom element to collect the events from
  68873. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  68874. */
  68875. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  68876. /**
  68877. * Detach the current manager inputs controls from a specific dom element.
  68878. * @param element Defines the dom element to collect the events from
  68879. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  68880. */
  68881. detachElement(element: HTMLElement, disconnect?: boolean): void;
  68882. /**
  68883. * Rebuild the dynamic inputCheck function from the current list of
  68884. * defined inputs in the manager.
  68885. */
  68886. rebuildInputCheck(): void;
  68887. /**
  68888. * Remove all attached input methods from a camera
  68889. */
  68890. clear(): void;
  68891. /**
  68892. * Serialize the current input manager attached to a camera.
  68893. * This ensures than once parsed,
  68894. * the input associated to the camera will be identical to the current ones
  68895. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  68896. */
  68897. serialize(serializedCamera: any): void;
  68898. /**
  68899. * Parses an input manager serialized JSON to restore the previous list of inputs
  68900. * and states associated to a camera.
  68901. * @param parsedCamera Defines the JSON to parse
  68902. */
  68903. parse(parsedCamera: any): void;
  68904. }
  68905. }
  68906. declare module BABYLON {
  68907. /**
  68908. * Gather the list of keyboard event types as constants.
  68909. */
  68910. export class KeyboardEventTypes {
  68911. /**
  68912. * The keydown event is fired when a key becomes active (pressed).
  68913. */
  68914. static readonly KEYDOWN: number;
  68915. /**
  68916. * The keyup event is fired when a key has been released.
  68917. */
  68918. static readonly KEYUP: number;
  68919. }
  68920. /**
  68921. * This class is used to store keyboard related info for the onKeyboardObservable event.
  68922. */
  68923. export class KeyboardInfo {
  68924. /**
  68925. * Defines the type of event (KeyboardEventTypes)
  68926. */
  68927. type: number;
  68928. /**
  68929. * Defines the related dom event
  68930. */
  68931. event: KeyboardEvent;
  68932. /**
  68933. * Instantiates a new keyboard info.
  68934. * This class is used to store keyboard related info for the onKeyboardObservable event.
  68935. * @param type Defines the type of event (KeyboardEventTypes)
  68936. * @param event Defines the related dom event
  68937. */
  68938. constructor(
  68939. /**
  68940. * Defines the type of event (KeyboardEventTypes)
  68941. */
  68942. type: number,
  68943. /**
  68944. * Defines the related dom event
  68945. */
  68946. event: KeyboardEvent);
  68947. }
  68948. /**
  68949. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  68950. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  68951. */
  68952. export class KeyboardInfoPre extends KeyboardInfo {
  68953. /**
  68954. * Defines the type of event (KeyboardEventTypes)
  68955. */
  68956. type: number;
  68957. /**
  68958. * Defines the related dom event
  68959. */
  68960. event: KeyboardEvent;
  68961. /**
  68962. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  68963. */
  68964. skipOnPointerObservable: boolean;
  68965. /**
  68966. * Instantiates a new keyboard pre info.
  68967. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  68968. * @param type Defines the type of event (KeyboardEventTypes)
  68969. * @param event Defines the related dom event
  68970. */
  68971. constructor(
  68972. /**
  68973. * Defines the type of event (KeyboardEventTypes)
  68974. */
  68975. type: number,
  68976. /**
  68977. * Defines the related dom event
  68978. */
  68979. event: KeyboardEvent);
  68980. }
  68981. }
  68982. declare module BABYLON {
  68983. /**
  68984. * Manage the keyboard inputs to control the movement of a free camera.
  68985. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  68986. */
  68987. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  68988. /**
  68989. * Defines the camera the input is attached to.
  68990. */
  68991. camera: FreeCamera;
  68992. /**
  68993. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  68994. */
  68995. keysUp: number[];
  68996. /**
  68997. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  68998. */
  68999. keysDown: number[];
  69000. /**
  69001. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  69002. */
  69003. keysLeft: number[];
  69004. /**
  69005. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  69006. */
  69007. keysRight: number[];
  69008. private _keys;
  69009. private _onCanvasBlurObserver;
  69010. private _onKeyboardObserver;
  69011. private _engine;
  69012. private _scene;
  69013. /**
  69014. * Attach the input controls to a specific dom element to get the input from.
  69015. * @param element Defines the element the controls should be listened from
  69016. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  69017. */
  69018. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  69019. /**
  69020. * Detach the current controls from the specified dom element.
  69021. * @param element Defines the element to stop listening the inputs from
  69022. */
  69023. detachControl(element: Nullable<HTMLElement>): void;
  69024. /**
  69025. * Update the current camera state depending on the inputs that have been used this frame.
  69026. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  69027. */
  69028. checkInputs(): void;
  69029. /**
  69030. * Gets the class name of the current intput.
  69031. * @returns the class name
  69032. */
  69033. getClassName(): string;
  69034. /** @hidden */
  69035. _onLostFocus(): void;
  69036. /**
  69037. * Get the friendly name associated with the input class.
  69038. * @returns the input friendly name
  69039. */
  69040. getSimpleName(): string;
  69041. }
  69042. }
  69043. declare module BABYLON {
  69044. /**
  69045. * Interface describing all the common properties and methods a shadow light needs to implement.
  69046. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  69047. * as well as binding the different shadow properties to the effects.
  69048. */
  69049. export interface IShadowLight extends Light {
  69050. /**
  69051. * The light id in the scene (used in scene.findLighById for instance)
  69052. */
  69053. id: string;
  69054. /**
  69055. * The position the shdow will be casted from.
  69056. */
  69057. position: Vector3;
  69058. /**
  69059. * In 2d mode (needCube being false), the direction used to cast the shadow.
  69060. */
  69061. direction: Vector3;
  69062. /**
  69063. * The transformed position. Position of the light in world space taking parenting in account.
  69064. */
  69065. transformedPosition: Vector3;
  69066. /**
  69067. * The transformed direction. Direction of the light in world space taking parenting in account.
  69068. */
  69069. transformedDirection: Vector3;
  69070. /**
  69071. * The friendly name of the light in the scene.
  69072. */
  69073. name: string;
  69074. /**
  69075. * Defines the shadow projection clipping minimum z value.
  69076. */
  69077. shadowMinZ: number;
  69078. /**
  69079. * Defines the shadow projection clipping maximum z value.
  69080. */
  69081. shadowMaxZ: number;
  69082. /**
  69083. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  69084. * @returns true if the information has been computed, false if it does not need to (no parenting)
  69085. */
  69086. computeTransformedInformation(): boolean;
  69087. /**
  69088. * Gets the scene the light belongs to.
  69089. * @returns The scene
  69090. */
  69091. getScene(): Scene;
  69092. /**
  69093. * Callback defining a custom Projection Matrix Builder.
  69094. * This can be used to override the default projection matrix computation.
  69095. */
  69096. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  69097. /**
  69098. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  69099. * @param matrix The materix to updated with the projection information
  69100. * @param viewMatrix The transform matrix of the light
  69101. * @param renderList The list of mesh to render in the map
  69102. * @returns The current light
  69103. */
  69104. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  69105. /**
  69106. * Gets the current depth scale used in ESM.
  69107. * @returns The scale
  69108. */
  69109. getDepthScale(): number;
  69110. /**
  69111. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  69112. * @returns true if a cube texture needs to be use
  69113. */
  69114. needCube(): boolean;
  69115. /**
  69116. * Detects if the projection matrix requires to be recomputed this frame.
  69117. * @returns true if it requires to be recomputed otherwise, false.
  69118. */
  69119. needProjectionMatrixCompute(): boolean;
  69120. /**
  69121. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  69122. */
  69123. forceProjectionMatrixCompute(): void;
  69124. /**
  69125. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  69126. * @param faceIndex The index of the face we are computed the direction to generate shadow
  69127. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  69128. */
  69129. getShadowDirection(faceIndex?: number): Vector3;
  69130. /**
  69131. * Gets the minZ used for shadow according to both the scene and the light.
  69132. * @param activeCamera The camera we are returning the min for
  69133. * @returns the depth min z
  69134. */
  69135. getDepthMinZ(activeCamera: Camera): number;
  69136. /**
  69137. * Gets the maxZ used for shadow according to both the scene and the light.
  69138. * @param activeCamera The camera we are returning the max for
  69139. * @returns the depth max z
  69140. */
  69141. getDepthMaxZ(activeCamera: Camera): number;
  69142. }
  69143. /**
  69144. * Base implementation IShadowLight
  69145. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  69146. */
  69147. export abstract class ShadowLight extends Light implements IShadowLight {
  69148. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  69149. protected _position: Vector3;
  69150. protected _setPosition(value: Vector3): void;
  69151. /**
  69152. * Sets the position the shadow will be casted from. Also use as the light position for both
  69153. * point and spot lights.
  69154. */
  69155. /**
  69156. * Sets the position the shadow will be casted from. Also use as the light position for both
  69157. * point and spot lights.
  69158. */
  69159. position: Vector3;
  69160. protected _direction: Vector3;
  69161. protected _setDirection(value: Vector3): void;
  69162. /**
  69163. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  69164. * Also use as the light direction on spot and directional lights.
  69165. */
  69166. /**
  69167. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  69168. * Also use as the light direction on spot and directional lights.
  69169. */
  69170. direction: Vector3;
  69171. private _shadowMinZ;
  69172. /**
  69173. * Gets the shadow projection clipping minimum z value.
  69174. */
  69175. /**
  69176. * Sets the shadow projection clipping minimum z value.
  69177. */
  69178. shadowMinZ: number;
  69179. private _shadowMaxZ;
  69180. /**
  69181. * Sets the shadow projection clipping maximum z value.
  69182. */
  69183. /**
  69184. * Gets the shadow projection clipping maximum z value.
  69185. */
  69186. shadowMaxZ: number;
  69187. /**
  69188. * Callback defining a custom Projection Matrix Builder.
  69189. * This can be used to override the default projection matrix computation.
  69190. */
  69191. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  69192. /**
  69193. * The transformed position. Position of the light in world space taking parenting in account.
  69194. */
  69195. transformedPosition: Vector3;
  69196. /**
  69197. * The transformed direction. Direction of the light in world space taking parenting in account.
  69198. */
  69199. transformedDirection: Vector3;
  69200. private _needProjectionMatrixCompute;
  69201. /**
  69202. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  69203. * @returns true if the information has been computed, false if it does not need to (no parenting)
  69204. */
  69205. computeTransformedInformation(): boolean;
  69206. /**
  69207. * Return the depth scale used for the shadow map.
  69208. * @returns the depth scale.
  69209. */
  69210. getDepthScale(): number;
  69211. /**
  69212. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  69213. * @param faceIndex The index of the face we are computed the direction to generate shadow
  69214. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  69215. */
  69216. getShadowDirection(faceIndex?: number): Vector3;
  69217. /**
  69218. * Returns the ShadowLight absolute position in the World.
  69219. * @returns the position vector in world space
  69220. */
  69221. getAbsolutePosition(): Vector3;
  69222. /**
  69223. * Sets the ShadowLight direction toward the passed target.
  69224. * @param target The point to target in local space
  69225. * @returns the updated ShadowLight direction
  69226. */
  69227. setDirectionToTarget(target: Vector3): Vector3;
  69228. /**
  69229. * Returns the light rotation in euler definition.
  69230. * @returns the x y z rotation in local space.
  69231. */
  69232. getRotation(): Vector3;
  69233. /**
  69234. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  69235. * @returns true if a cube texture needs to be use
  69236. */
  69237. needCube(): boolean;
  69238. /**
  69239. * Detects if the projection matrix requires to be recomputed this frame.
  69240. * @returns true if it requires to be recomputed otherwise, false.
  69241. */
  69242. needProjectionMatrixCompute(): boolean;
  69243. /**
  69244. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  69245. */
  69246. forceProjectionMatrixCompute(): void;
  69247. /** @hidden */
  69248. _initCache(): void;
  69249. /** @hidden */
  69250. _isSynchronized(): boolean;
  69251. /**
  69252. * Computes the world matrix of the node
  69253. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  69254. * @returns the world matrix
  69255. */
  69256. computeWorldMatrix(force?: boolean): Matrix;
  69257. /**
  69258. * Gets the minZ used for shadow according to both the scene and the light.
  69259. * @param activeCamera The camera we are returning the min for
  69260. * @returns the depth min z
  69261. */
  69262. getDepthMinZ(activeCamera: Camera): number;
  69263. /**
  69264. * Gets the maxZ used for shadow according to both the scene and the light.
  69265. * @param activeCamera The camera we are returning the max for
  69266. * @returns the depth max z
  69267. */
  69268. getDepthMaxZ(activeCamera: Camera): number;
  69269. /**
  69270. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  69271. * @param matrix The materix to updated with the projection information
  69272. * @param viewMatrix The transform matrix of the light
  69273. * @param renderList The list of mesh to render in the map
  69274. * @returns The current light
  69275. */
  69276. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  69277. }
  69278. }
  69279. declare module BABYLON {
  69280. /**
  69281. * "Static Class" containing the most commonly used helper while dealing with material for
  69282. * rendering purpose.
  69283. *
  69284. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  69285. *
  69286. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  69287. */
  69288. export class MaterialHelper {
  69289. /**
  69290. * Bind the current view position to an effect.
  69291. * @param effect The effect to be bound
  69292. * @param scene The scene the eyes position is used from
  69293. */
  69294. static BindEyePosition(effect: Effect, scene: Scene): void;
  69295. /**
  69296. * Helps preparing the defines values about the UVs in used in the effect.
  69297. * UVs are shared as much as we can accross channels in the shaders.
  69298. * @param texture The texture we are preparing the UVs for
  69299. * @param defines The defines to update
  69300. * @param key The channel key "diffuse", "specular"... used in the shader
  69301. */
  69302. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  69303. /**
  69304. * Binds a texture matrix value to its corrsponding uniform
  69305. * @param texture The texture to bind the matrix for
  69306. * @param uniformBuffer The uniform buffer receivin the data
  69307. * @param key The channel key "diffuse", "specular"... used in the shader
  69308. */
  69309. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  69310. /**
  69311. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  69312. * @param mesh defines the current mesh
  69313. * @param scene defines the current scene
  69314. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  69315. * @param pointsCloud defines if point cloud rendering has to be turned on
  69316. * @param fogEnabled defines if fog has to be turned on
  69317. * @param alphaTest defines if alpha testing has to be turned on
  69318. * @param defines defines the current list of defines
  69319. */
  69320. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  69321. /**
  69322. * Helper used to prepare the list of defines associated with frame values for shader compilation
  69323. * @param scene defines the current scene
  69324. * @param engine defines the current engine
  69325. * @param defines specifies the list of active defines
  69326. * @param useInstances defines if instances have to be turned on
  69327. * @param useClipPlane defines if clip plane have to be turned on
  69328. */
  69329. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  69330. /**
  69331. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  69332. * @param mesh The mesh containing the geometry data we will draw
  69333. * @param defines The defines to update
  69334. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  69335. * @param useBones Precise whether bones should be used or not (override mesh info)
  69336. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  69337. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  69338. * @returns false if defines are considered not dirty and have not been checked
  69339. */
  69340. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  69341. /**
  69342. * Prepares the defines related to multiview
  69343. * @param scene The scene we are intending to draw
  69344. * @param defines The defines to update
  69345. */
  69346. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  69347. /**
  69348. * Prepares the defines related to the light information passed in parameter
  69349. * @param scene The scene we are intending to draw
  69350. * @param mesh The mesh the effect is compiling for
  69351. * @param defines The defines to update
  69352. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  69353. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  69354. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  69355. * @returns true if normals will be required for the rest of the effect
  69356. */
  69357. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  69358. /**
  69359. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  69360. * that won t be acctive due to defines being turned off.
  69361. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  69362. * @param samplersList The samplers list
  69363. * @param defines The defines helping in the list generation
  69364. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  69365. */
  69366. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  69367. /**
  69368. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  69369. * @param defines The defines to update while falling back
  69370. * @param fallbacks The authorized effect fallbacks
  69371. * @param maxSimultaneousLights The maximum number of lights allowed
  69372. * @param rank the current rank of the Effect
  69373. * @returns The newly affected rank
  69374. */
  69375. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  69376. /**
  69377. * Prepares the list of attributes required for morph targets according to the effect defines.
  69378. * @param attribs The current list of supported attribs
  69379. * @param mesh The mesh to prepare the morph targets attributes for
  69380. * @param defines The current Defines of the effect
  69381. */
  69382. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  69383. /**
  69384. * Prepares the list of attributes required for bones according to the effect defines.
  69385. * @param attribs The current list of supported attribs
  69386. * @param mesh The mesh to prepare the bones attributes for
  69387. * @param defines The current Defines of the effect
  69388. * @param fallbacks The current efffect fallback strategy
  69389. */
  69390. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  69391. /**
  69392. * Prepares the list of attributes required for instances according to the effect defines.
  69393. * @param attribs The current list of supported attribs
  69394. * @param defines The current Defines of the effect
  69395. */
  69396. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  69397. /**
  69398. * Binds the light shadow information to the effect for the given mesh.
  69399. * @param light The light containing the generator
  69400. * @param scene The scene the lights belongs to
  69401. * @param mesh The mesh we are binding the information to render
  69402. * @param lightIndex The light index in the effect used to render the mesh
  69403. * @param effect The effect we are binding the data to
  69404. */
  69405. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  69406. /**
  69407. * Binds the light information to the effect.
  69408. * @param light The light containing the generator
  69409. * @param effect The effect we are binding the data to
  69410. * @param lightIndex The light index in the effect used to render
  69411. */
  69412. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  69413. /**
  69414. * Binds the lights information from the scene to the effect for the given mesh.
  69415. * @param scene The scene the lights belongs to
  69416. * @param mesh The mesh we are binding the information to render
  69417. * @param effect The effect we are binding the data to
  69418. * @param defines The generated defines for the effect
  69419. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  69420. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  69421. */
  69422. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  69423. private static _tempFogColor;
  69424. /**
  69425. * Binds the fog information from the scene to the effect for the given mesh.
  69426. * @param scene The scene the lights belongs to
  69427. * @param mesh The mesh we are binding the information to render
  69428. * @param effect The effect we are binding the data to
  69429. * @param linearSpace Defines if the fog effect is applied in linear space
  69430. */
  69431. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  69432. /**
  69433. * Binds the bones information from the mesh to the effect.
  69434. * @param mesh The mesh we are binding the information to render
  69435. * @param effect The effect we are binding the data to
  69436. */
  69437. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  69438. /**
  69439. * Binds the morph targets information from the mesh to the effect.
  69440. * @param abstractMesh The mesh we are binding the information to render
  69441. * @param effect The effect we are binding the data to
  69442. */
  69443. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  69444. /**
  69445. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  69446. * @param defines The generated defines used in the effect
  69447. * @param effect The effect we are binding the data to
  69448. * @param scene The scene we are willing to render with logarithmic scale for
  69449. */
  69450. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  69451. /**
  69452. * Binds the clip plane information from the scene to the effect.
  69453. * @param scene The scene the clip plane information are extracted from
  69454. * @param effect The effect we are binding the data to
  69455. */
  69456. static BindClipPlane(effect: Effect, scene: Scene): void;
  69457. }
  69458. }
  69459. declare module BABYLON {
  69460. /** @hidden */
  69461. export var kernelBlurVaryingDeclaration: {
  69462. name: string;
  69463. shader: string;
  69464. };
  69465. }
  69466. declare module BABYLON {
  69467. /** @hidden */
  69468. export var kernelBlurFragment: {
  69469. name: string;
  69470. shader: string;
  69471. };
  69472. }
  69473. declare module BABYLON {
  69474. /** @hidden */
  69475. export var kernelBlurFragment2: {
  69476. name: string;
  69477. shader: string;
  69478. };
  69479. }
  69480. declare module BABYLON {
  69481. /** @hidden */
  69482. export var kernelBlurPixelShader: {
  69483. name: string;
  69484. shader: string;
  69485. };
  69486. }
  69487. declare module BABYLON {
  69488. /** @hidden */
  69489. export var kernelBlurVertex: {
  69490. name: string;
  69491. shader: string;
  69492. };
  69493. }
  69494. declare module BABYLON {
  69495. /** @hidden */
  69496. export var kernelBlurVertexShader: {
  69497. name: string;
  69498. shader: string;
  69499. };
  69500. }
  69501. declare module BABYLON {
  69502. /**
  69503. * The Blur Post Process which blurs an image based on a kernel and direction.
  69504. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  69505. */
  69506. export class BlurPostProcess extends PostProcess {
  69507. /** The direction in which to blur the image. */
  69508. direction: Vector2;
  69509. private blockCompilation;
  69510. protected _kernel: number;
  69511. protected _idealKernel: number;
  69512. protected _packedFloat: boolean;
  69513. private _staticDefines;
  69514. /**
  69515. * Sets the length in pixels of the blur sample region
  69516. */
  69517. /**
  69518. * Gets the length in pixels of the blur sample region
  69519. */
  69520. kernel: number;
  69521. /**
  69522. * Sets wether or not the blur needs to unpack/repack floats
  69523. */
  69524. /**
  69525. * Gets wether or not the blur is unpacking/repacking floats
  69526. */
  69527. packedFloat: boolean;
  69528. /**
  69529. * Creates a new instance BlurPostProcess
  69530. * @param name The name of the effect.
  69531. * @param direction The direction in which to blur the image.
  69532. * @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.
  69533. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  69534. * @param camera The camera to apply the render pass to.
  69535. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69536. * @param engine The engine which the post process will be applied. (default: current engine)
  69537. * @param reusable If the post process can be reused on the same frame. (default: false)
  69538. * @param textureType Type of textures used when performing the post process. (default: 0)
  69539. * @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)
  69540. */
  69541. constructor(name: string,
  69542. /** The direction in which to blur the image. */
  69543. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  69544. /**
  69545. * Updates the effect with the current post process compile time values and recompiles the shader.
  69546. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  69547. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  69548. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  69549. * @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
  69550. * @param onCompiled Called when the shader has been compiled.
  69551. * @param onError Called if there is an error when compiling a shader.
  69552. */
  69553. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  69554. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  69555. /**
  69556. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  69557. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  69558. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  69559. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  69560. * The gaps between physical kernels are compensated for in the weighting of the samples
  69561. * @param idealKernel Ideal blur kernel.
  69562. * @return Nearest best kernel.
  69563. */
  69564. protected _nearestBestKernel(idealKernel: number): number;
  69565. /**
  69566. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  69567. * @param x The point on the Gaussian distribution to sample.
  69568. * @return the value of the Gaussian function at x.
  69569. */
  69570. protected _gaussianWeight(x: number): number;
  69571. /**
  69572. * Generates a string that can be used as a floating point number in GLSL.
  69573. * @param x Value to print.
  69574. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  69575. * @return GLSL float string.
  69576. */
  69577. protected _glslFloat(x: number, decimalFigures?: number): string;
  69578. }
  69579. }
  69580. declare module BABYLON {
  69581. /** @hidden */
  69582. export var shadowMapPixelShader: {
  69583. name: string;
  69584. shader: string;
  69585. };
  69586. }
  69587. declare module BABYLON {
  69588. /** @hidden */
  69589. export var bonesDeclaration: {
  69590. name: string;
  69591. shader: string;
  69592. };
  69593. }
  69594. declare module BABYLON {
  69595. /** @hidden */
  69596. export var morphTargetsVertexGlobalDeclaration: {
  69597. name: string;
  69598. shader: string;
  69599. };
  69600. }
  69601. declare module BABYLON {
  69602. /** @hidden */
  69603. export var morphTargetsVertexDeclaration: {
  69604. name: string;
  69605. shader: string;
  69606. };
  69607. }
  69608. declare module BABYLON {
  69609. /** @hidden */
  69610. export var instancesDeclaration: {
  69611. name: string;
  69612. shader: string;
  69613. };
  69614. }
  69615. declare module BABYLON {
  69616. /** @hidden */
  69617. export var helperFunctions: {
  69618. name: string;
  69619. shader: string;
  69620. };
  69621. }
  69622. declare module BABYLON {
  69623. /** @hidden */
  69624. export var morphTargetsVertex: {
  69625. name: string;
  69626. shader: string;
  69627. };
  69628. }
  69629. declare module BABYLON {
  69630. /** @hidden */
  69631. export var instancesVertex: {
  69632. name: string;
  69633. shader: string;
  69634. };
  69635. }
  69636. declare module BABYLON {
  69637. /** @hidden */
  69638. export var bonesVertex: {
  69639. name: string;
  69640. shader: string;
  69641. };
  69642. }
  69643. declare module BABYLON {
  69644. /** @hidden */
  69645. export var shadowMapVertexShader: {
  69646. name: string;
  69647. shader: string;
  69648. };
  69649. }
  69650. declare module BABYLON {
  69651. /** @hidden */
  69652. export var depthBoxBlurPixelShader: {
  69653. name: string;
  69654. shader: string;
  69655. };
  69656. }
  69657. declare module BABYLON {
  69658. /**
  69659. * Defines the options associated with the creation of a custom shader for a shadow generator.
  69660. */
  69661. export interface ICustomShaderOptions {
  69662. /**
  69663. * Gets or sets the custom shader name to use
  69664. */
  69665. shaderName: string;
  69666. /**
  69667. * The list of attribute names used in the shader
  69668. */
  69669. attributes?: string[];
  69670. /**
  69671. * The list of unifrom names used in the shader
  69672. */
  69673. uniforms?: string[];
  69674. /**
  69675. * The list of sampler names used in the shader
  69676. */
  69677. samplers?: string[];
  69678. /**
  69679. * The list of defines used in the shader
  69680. */
  69681. defines?: string[];
  69682. }
  69683. /**
  69684. * Interface to implement to create a shadow generator compatible with BJS.
  69685. */
  69686. export interface IShadowGenerator {
  69687. /**
  69688. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  69689. * @returns The render target texture if present otherwise, null
  69690. */
  69691. getShadowMap(): Nullable<RenderTargetTexture>;
  69692. /**
  69693. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  69694. * @returns The render target texture if the shadow map is present otherwise, null
  69695. */
  69696. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  69697. /**
  69698. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  69699. * @param subMesh The submesh we want to render in the shadow map
  69700. * @param useInstances Defines wether will draw in the map using instances
  69701. * @returns true if ready otherwise, false
  69702. */
  69703. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  69704. /**
  69705. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  69706. * @param defines Defines of the material we want to update
  69707. * @param lightIndex Index of the light in the enabled light list of the material
  69708. */
  69709. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  69710. /**
  69711. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  69712. * defined in the generator but impacting the effect).
  69713. * It implies the unifroms available on the materials are the standard BJS ones.
  69714. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  69715. * @param effect The effect we are binfing the information for
  69716. */
  69717. bindShadowLight(lightIndex: string, effect: Effect): void;
  69718. /**
  69719. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  69720. * (eq to shadow prjection matrix * light transform matrix)
  69721. * @returns The transform matrix used to create the shadow map
  69722. */
  69723. getTransformMatrix(): Matrix;
  69724. /**
  69725. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  69726. * Cube and 2D textures for instance.
  69727. */
  69728. recreateShadowMap(): void;
  69729. /**
  69730. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  69731. * @param onCompiled Callback triggered at the and of the effects compilation
  69732. * @param options Sets of optional options forcing the compilation with different modes
  69733. */
  69734. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  69735. useInstances: boolean;
  69736. }>): void;
  69737. /**
  69738. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  69739. * @param options Sets of optional options forcing the compilation with different modes
  69740. * @returns A promise that resolves when the compilation completes
  69741. */
  69742. forceCompilationAsync(options?: Partial<{
  69743. useInstances: boolean;
  69744. }>): Promise<void>;
  69745. /**
  69746. * Serializes the shadow generator setup to a json object.
  69747. * @returns The serialized JSON object
  69748. */
  69749. serialize(): any;
  69750. /**
  69751. * Disposes the Shadow map and related Textures and effects.
  69752. */
  69753. dispose(): void;
  69754. }
  69755. /**
  69756. * Default implementation IShadowGenerator.
  69757. * This is the main object responsible of generating shadows in the framework.
  69758. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  69759. */
  69760. export class ShadowGenerator implements IShadowGenerator {
  69761. /**
  69762. * Shadow generator mode None: no filtering applied.
  69763. */
  69764. static readonly FILTER_NONE: number;
  69765. /**
  69766. * Shadow generator mode ESM: Exponential Shadow Mapping.
  69767. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  69768. */
  69769. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  69770. /**
  69771. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  69772. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  69773. */
  69774. static readonly FILTER_POISSONSAMPLING: number;
  69775. /**
  69776. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  69777. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  69778. */
  69779. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  69780. /**
  69781. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  69782. * edge artifacts on steep falloff.
  69783. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  69784. */
  69785. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  69786. /**
  69787. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  69788. * edge artifacts on steep falloff.
  69789. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  69790. */
  69791. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  69792. /**
  69793. * Shadow generator mode PCF: Percentage Closer Filtering
  69794. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  69795. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  69796. */
  69797. static readonly FILTER_PCF: number;
  69798. /**
  69799. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  69800. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  69801. * Contact Hardening
  69802. */
  69803. static readonly FILTER_PCSS: number;
  69804. /**
  69805. * Reserved for PCF and PCSS
  69806. * Highest Quality.
  69807. *
  69808. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  69809. *
  69810. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  69811. */
  69812. static readonly QUALITY_HIGH: number;
  69813. /**
  69814. * Reserved for PCF and PCSS
  69815. * Good tradeoff for quality/perf cross devices
  69816. *
  69817. * Execute PCF on a 3*3 kernel.
  69818. *
  69819. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  69820. */
  69821. static readonly QUALITY_MEDIUM: number;
  69822. /**
  69823. * Reserved for PCF and PCSS
  69824. * The lowest quality but the fastest.
  69825. *
  69826. * Execute PCF on a 1*1 kernel.
  69827. *
  69828. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  69829. */
  69830. static readonly QUALITY_LOW: number;
  69831. /** Gets or sets the custom shader name to use */
  69832. customShaderOptions: ICustomShaderOptions;
  69833. /**
  69834. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  69835. */
  69836. onBeforeShadowMapRenderObservable: Observable<Effect>;
  69837. /**
  69838. * Observable triggered before a mesh is rendered in the shadow map.
  69839. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  69840. */
  69841. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  69842. private _bias;
  69843. /**
  69844. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  69845. */
  69846. /**
  69847. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  69848. */
  69849. bias: number;
  69850. private _normalBias;
  69851. /**
  69852. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  69853. */
  69854. /**
  69855. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  69856. */
  69857. normalBias: number;
  69858. private _blurBoxOffset;
  69859. /**
  69860. * Gets the blur box offset: offset applied during the blur pass.
  69861. * Only useful if useKernelBlur = false
  69862. */
  69863. /**
  69864. * Sets the blur box offset: offset applied during the blur pass.
  69865. * Only useful if useKernelBlur = false
  69866. */
  69867. blurBoxOffset: number;
  69868. private _blurScale;
  69869. /**
  69870. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  69871. * 2 means half of the size.
  69872. */
  69873. /**
  69874. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  69875. * 2 means half of the size.
  69876. */
  69877. blurScale: number;
  69878. private _blurKernel;
  69879. /**
  69880. * Gets the blur kernel: kernel size of the blur pass.
  69881. * Only useful if useKernelBlur = true
  69882. */
  69883. /**
  69884. * Sets the blur kernel: kernel size of the blur pass.
  69885. * Only useful if useKernelBlur = true
  69886. */
  69887. blurKernel: number;
  69888. private _useKernelBlur;
  69889. /**
  69890. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  69891. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  69892. */
  69893. /**
  69894. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  69895. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  69896. */
  69897. useKernelBlur: boolean;
  69898. private _depthScale;
  69899. /**
  69900. * Gets the depth scale used in ESM mode.
  69901. */
  69902. /**
  69903. * Sets the depth scale used in ESM mode.
  69904. * This can override the scale stored on the light.
  69905. */
  69906. depthScale: number;
  69907. private _filter;
  69908. /**
  69909. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  69910. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  69911. */
  69912. /**
  69913. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  69914. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  69915. */
  69916. filter: number;
  69917. /**
  69918. * Gets if the current filter is set to Poisson Sampling.
  69919. */
  69920. /**
  69921. * Sets the current filter to Poisson Sampling.
  69922. */
  69923. usePoissonSampling: boolean;
  69924. /**
  69925. * Gets if the current filter is set to ESM.
  69926. */
  69927. /**
  69928. * Sets the current filter is to ESM.
  69929. */
  69930. useExponentialShadowMap: boolean;
  69931. /**
  69932. * Gets if the current filter is set to filtered ESM.
  69933. */
  69934. /**
  69935. * Gets if the current filter is set to filtered ESM.
  69936. */
  69937. useBlurExponentialShadowMap: boolean;
  69938. /**
  69939. * Gets if the current filter is set to "close ESM" (using the inverse of the
  69940. * exponential to prevent steep falloff artifacts).
  69941. */
  69942. /**
  69943. * Sets the current filter to "close ESM" (using the inverse of the
  69944. * exponential to prevent steep falloff artifacts).
  69945. */
  69946. useCloseExponentialShadowMap: boolean;
  69947. /**
  69948. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  69949. * exponential to prevent steep falloff artifacts).
  69950. */
  69951. /**
  69952. * Sets the current filter to filtered "close ESM" (using the inverse of the
  69953. * exponential to prevent steep falloff artifacts).
  69954. */
  69955. useBlurCloseExponentialShadowMap: boolean;
  69956. /**
  69957. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  69958. */
  69959. /**
  69960. * Sets the current filter to "PCF" (percentage closer filtering).
  69961. */
  69962. usePercentageCloserFiltering: boolean;
  69963. private _filteringQuality;
  69964. /**
  69965. * Gets the PCF or PCSS Quality.
  69966. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  69967. */
  69968. /**
  69969. * Sets the PCF or PCSS Quality.
  69970. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  69971. */
  69972. filteringQuality: number;
  69973. /**
  69974. * Gets if the current filter is set to "PCSS" (contact hardening).
  69975. */
  69976. /**
  69977. * Sets the current filter to "PCSS" (contact hardening).
  69978. */
  69979. useContactHardeningShadow: boolean;
  69980. private _contactHardeningLightSizeUVRatio;
  69981. /**
  69982. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  69983. * Using a ratio helps keeping shape stability independently of the map size.
  69984. *
  69985. * It does not account for the light projection as it was having too much
  69986. * instability during the light setup or during light position changes.
  69987. *
  69988. * Only valid if useContactHardeningShadow is true.
  69989. */
  69990. /**
  69991. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  69992. * Using a ratio helps keeping shape stability independently of the map size.
  69993. *
  69994. * It does not account for the light projection as it was having too much
  69995. * instability during the light setup or during light position changes.
  69996. *
  69997. * Only valid if useContactHardeningShadow is true.
  69998. */
  69999. contactHardeningLightSizeUVRatio: number;
  70000. private _darkness;
  70001. /**
  70002. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  70003. * 0 means strongest and 1 would means no shadow.
  70004. * @returns the darkness.
  70005. */
  70006. getDarkness(): number;
  70007. /**
  70008. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  70009. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  70010. * @returns the shadow generator allowing fluent coding.
  70011. */
  70012. setDarkness(darkness: number): ShadowGenerator;
  70013. private _transparencyShadow;
  70014. /**
  70015. * Sets the ability to have transparent shadow (boolean).
  70016. * @param transparent True if transparent else False
  70017. * @returns the shadow generator allowing fluent coding
  70018. */
  70019. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  70020. private _shadowMap;
  70021. private _shadowMap2;
  70022. /**
  70023. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  70024. * @returns The render target texture if present otherwise, null
  70025. */
  70026. getShadowMap(): Nullable<RenderTargetTexture>;
  70027. /**
  70028. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  70029. * @returns The render target texture if the shadow map is present otherwise, null
  70030. */
  70031. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  70032. /**
  70033. * Helper function to add a mesh and its descendants to the list of shadow casters.
  70034. * @param mesh Mesh to add
  70035. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  70036. * @returns the Shadow Generator itself
  70037. */
  70038. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  70039. /**
  70040. * Helper function to remove a mesh and its descendants from the list of shadow casters
  70041. * @param mesh Mesh to remove
  70042. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  70043. * @returns the Shadow Generator itself
  70044. */
  70045. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  70046. /**
  70047. * Controls the extent to which the shadows fade out at the edge of the frustum
  70048. * Used only by directionals and spots
  70049. */
  70050. frustumEdgeFalloff: number;
  70051. private _light;
  70052. /**
  70053. * Returns the associated light object.
  70054. * @returns the light generating the shadow
  70055. */
  70056. getLight(): IShadowLight;
  70057. /**
  70058. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  70059. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  70060. * It might on the other hand introduce peter panning.
  70061. */
  70062. forceBackFacesOnly: boolean;
  70063. private _scene;
  70064. private _lightDirection;
  70065. private _effect;
  70066. private _viewMatrix;
  70067. private _projectionMatrix;
  70068. private _transformMatrix;
  70069. private _cachedPosition;
  70070. private _cachedDirection;
  70071. private _cachedDefines;
  70072. private _currentRenderID;
  70073. private _boxBlurPostprocess;
  70074. private _kernelBlurXPostprocess;
  70075. private _kernelBlurYPostprocess;
  70076. private _blurPostProcesses;
  70077. private _mapSize;
  70078. private _currentFaceIndex;
  70079. private _currentFaceIndexCache;
  70080. private _textureType;
  70081. private _defaultTextureMatrix;
  70082. /** @hidden */
  70083. static _SceneComponentInitialization: (scene: Scene) => void;
  70084. /**
  70085. * Creates a ShadowGenerator object.
  70086. * A ShadowGenerator is the required tool to use the shadows.
  70087. * Each light casting shadows needs to use its own ShadowGenerator.
  70088. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  70089. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  70090. * @param light The light object generating the shadows.
  70091. * @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.
  70092. */
  70093. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  70094. private _initializeGenerator;
  70095. private _initializeShadowMap;
  70096. private _initializeBlurRTTAndPostProcesses;
  70097. private _renderForShadowMap;
  70098. private _renderSubMeshForShadowMap;
  70099. private _applyFilterValues;
  70100. /**
  70101. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  70102. * @param onCompiled Callback triggered at the and of the effects compilation
  70103. * @param options Sets of optional options forcing the compilation with different modes
  70104. */
  70105. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  70106. useInstances: boolean;
  70107. }>): void;
  70108. /**
  70109. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  70110. * @param options Sets of optional options forcing the compilation with different modes
  70111. * @returns A promise that resolves when the compilation completes
  70112. */
  70113. forceCompilationAsync(options?: Partial<{
  70114. useInstances: boolean;
  70115. }>): Promise<void>;
  70116. /**
  70117. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  70118. * @param subMesh The submesh we want to render in the shadow map
  70119. * @param useInstances Defines wether will draw in the map using instances
  70120. * @returns true if ready otherwise, false
  70121. */
  70122. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  70123. /**
  70124. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  70125. * @param defines Defines of the material we want to update
  70126. * @param lightIndex Index of the light in the enabled light list of the material
  70127. */
  70128. prepareDefines(defines: any, lightIndex: number): void;
  70129. /**
  70130. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  70131. * defined in the generator but impacting the effect).
  70132. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  70133. * @param effect The effect we are binfing the information for
  70134. */
  70135. bindShadowLight(lightIndex: string, effect: Effect): void;
  70136. /**
  70137. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  70138. * (eq to shadow prjection matrix * light transform matrix)
  70139. * @returns The transform matrix used to create the shadow map
  70140. */
  70141. getTransformMatrix(): Matrix;
  70142. /**
  70143. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  70144. * Cube and 2D textures for instance.
  70145. */
  70146. recreateShadowMap(): void;
  70147. private _disposeBlurPostProcesses;
  70148. private _disposeRTTandPostProcesses;
  70149. /**
  70150. * Disposes the ShadowGenerator.
  70151. * Returns nothing.
  70152. */
  70153. dispose(): void;
  70154. /**
  70155. * Serializes the shadow generator setup to a json object.
  70156. * @returns The serialized JSON object
  70157. */
  70158. serialize(): any;
  70159. /**
  70160. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  70161. * @param parsedShadowGenerator The JSON object to parse
  70162. * @param scene The scene to create the shadow map for
  70163. * @returns The parsed shadow generator
  70164. */
  70165. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  70166. }
  70167. }
  70168. declare module BABYLON {
  70169. /**
  70170. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  70171. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  70172. * 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.
  70173. */
  70174. export abstract class Light extends Node {
  70175. /**
  70176. * Falloff Default: light is falling off following the material specification:
  70177. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  70178. */
  70179. static readonly FALLOFF_DEFAULT: number;
  70180. /**
  70181. * Falloff Physical: light is falling off following the inverse squared distance law.
  70182. */
  70183. static readonly FALLOFF_PHYSICAL: number;
  70184. /**
  70185. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  70186. * to enhance interoperability with other engines.
  70187. */
  70188. static readonly FALLOFF_GLTF: number;
  70189. /**
  70190. * Falloff Standard: light is falling off like in the standard material
  70191. * to enhance interoperability with other materials.
  70192. */
  70193. static readonly FALLOFF_STANDARD: number;
  70194. /**
  70195. * If every light affecting the material is in this lightmapMode,
  70196. * material.lightmapTexture adds or multiplies
  70197. * (depends on material.useLightmapAsShadowmap)
  70198. * after every other light calculations.
  70199. */
  70200. static readonly LIGHTMAP_DEFAULT: number;
  70201. /**
  70202. * material.lightmapTexture as only diffuse lighting from this light
  70203. * adds only specular lighting from this light
  70204. * adds dynamic shadows
  70205. */
  70206. static readonly LIGHTMAP_SPECULAR: number;
  70207. /**
  70208. * material.lightmapTexture as only lighting
  70209. * no light calculation from this light
  70210. * only adds dynamic shadows from this light
  70211. */
  70212. static readonly LIGHTMAP_SHADOWSONLY: number;
  70213. /**
  70214. * Each light type uses the default quantity according to its type:
  70215. * point/spot lights use luminous intensity
  70216. * directional lights use illuminance
  70217. */
  70218. static readonly INTENSITYMODE_AUTOMATIC: number;
  70219. /**
  70220. * lumen (lm)
  70221. */
  70222. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  70223. /**
  70224. * candela (lm/sr)
  70225. */
  70226. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  70227. /**
  70228. * lux (lm/m^2)
  70229. */
  70230. static readonly INTENSITYMODE_ILLUMINANCE: number;
  70231. /**
  70232. * nit (cd/m^2)
  70233. */
  70234. static readonly INTENSITYMODE_LUMINANCE: number;
  70235. /**
  70236. * Light type const id of the point light.
  70237. */
  70238. static readonly LIGHTTYPEID_POINTLIGHT: number;
  70239. /**
  70240. * Light type const id of the directional light.
  70241. */
  70242. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  70243. /**
  70244. * Light type const id of the spot light.
  70245. */
  70246. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  70247. /**
  70248. * Light type const id of the hemispheric light.
  70249. */
  70250. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  70251. /**
  70252. * Diffuse gives the basic color to an object.
  70253. */
  70254. diffuse: Color3;
  70255. /**
  70256. * Specular produces a highlight color on an object.
  70257. * Note: This is note affecting PBR materials.
  70258. */
  70259. specular: Color3;
  70260. /**
  70261. * Defines the falloff type for this light. This lets overrriding how punctual light are
  70262. * falling off base on range or angle.
  70263. * This can be set to any values in Light.FALLOFF_x.
  70264. *
  70265. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  70266. * other types of materials.
  70267. */
  70268. falloffType: number;
  70269. /**
  70270. * Strength of the light.
  70271. * Note: By default it is define in the framework own unit.
  70272. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  70273. */
  70274. intensity: number;
  70275. private _range;
  70276. protected _inverseSquaredRange: number;
  70277. /**
  70278. * Defines how far from the source the light is impacting in scene units.
  70279. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  70280. */
  70281. /**
  70282. * Defines how far from the source the light is impacting in scene units.
  70283. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  70284. */
  70285. range: number;
  70286. /**
  70287. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  70288. * of light.
  70289. */
  70290. private _photometricScale;
  70291. private _intensityMode;
  70292. /**
  70293. * Gets the photometric scale used to interpret the intensity.
  70294. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  70295. */
  70296. /**
  70297. * Sets the photometric scale used to interpret the intensity.
  70298. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  70299. */
  70300. intensityMode: number;
  70301. private _radius;
  70302. /**
  70303. * Gets the light radius used by PBR Materials to simulate soft area lights.
  70304. */
  70305. /**
  70306. * sets the light radius used by PBR Materials to simulate soft area lights.
  70307. */
  70308. radius: number;
  70309. private _renderPriority;
  70310. /**
  70311. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  70312. * exceeding the number allowed of the materials.
  70313. */
  70314. renderPriority: number;
  70315. private _shadowEnabled;
  70316. /**
  70317. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  70318. * the current shadow generator.
  70319. */
  70320. /**
  70321. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  70322. * the current shadow generator.
  70323. */
  70324. shadowEnabled: boolean;
  70325. private _includedOnlyMeshes;
  70326. /**
  70327. * Gets the only meshes impacted by this light.
  70328. */
  70329. /**
  70330. * Sets the only meshes impacted by this light.
  70331. */
  70332. includedOnlyMeshes: AbstractMesh[];
  70333. private _excludedMeshes;
  70334. /**
  70335. * Gets the meshes not impacted by this light.
  70336. */
  70337. /**
  70338. * Sets the meshes not impacted by this light.
  70339. */
  70340. excludedMeshes: AbstractMesh[];
  70341. private _excludeWithLayerMask;
  70342. /**
  70343. * Gets the layer id use to find what meshes are not impacted by the light.
  70344. * Inactive if 0
  70345. */
  70346. /**
  70347. * Sets the layer id use to find what meshes are not impacted by the light.
  70348. * Inactive if 0
  70349. */
  70350. excludeWithLayerMask: number;
  70351. private _includeOnlyWithLayerMask;
  70352. /**
  70353. * Gets the layer id use to find what meshes are impacted by the light.
  70354. * Inactive if 0
  70355. */
  70356. /**
  70357. * Sets the layer id use to find what meshes are impacted by the light.
  70358. * Inactive if 0
  70359. */
  70360. includeOnlyWithLayerMask: number;
  70361. private _lightmapMode;
  70362. /**
  70363. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  70364. */
  70365. /**
  70366. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  70367. */
  70368. lightmapMode: number;
  70369. /**
  70370. * Shadow generator associted to the light.
  70371. * @hidden Internal use only.
  70372. */
  70373. _shadowGenerator: Nullable<IShadowGenerator>;
  70374. /**
  70375. * @hidden Internal use only.
  70376. */
  70377. _excludedMeshesIds: string[];
  70378. /**
  70379. * @hidden Internal use only.
  70380. */
  70381. _includedOnlyMeshesIds: string[];
  70382. /**
  70383. * The current light unifom buffer.
  70384. * @hidden Internal use only.
  70385. */
  70386. _uniformBuffer: UniformBuffer;
  70387. /**
  70388. * Creates a Light object in the scene.
  70389. * Documentation : https://doc.babylonjs.com/babylon101/lights
  70390. * @param name The firendly name of the light
  70391. * @param scene The scene the light belongs too
  70392. */
  70393. constructor(name: string, scene: Scene);
  70394. protected abstract _buildUniformLayout(): void;
  70395. /**
  70396. * Sets the passed Effect "effect" with the Light information.
  70397. * @param effect The effect to update
  70398. * @param lightIndex The index of the light in the effect to update
  70399. * @returns The light
  70400. */
  70401. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  70402. /**
  70403. * Returns the string "Light".
  70404. * @returns the class name
  70405. */
  70406. getClassName(): string;
  70407. /** @hidden */
  70408. readonly _isLight: boolean;
  70409. /**
  70410. * Converts the light information to a readable string for debug purpose.
  70411. * @param fullDetails Supports for multiple levels of logging within scene loading
  70412. * @returns the human readable light info
  70413. */
  70414. toString(fullDetails?: boolean): string;
  70415. /** @hidden */
  70416. protected _syncParentEnabledState(): void;
  70417. /**
  70418. * Set the enabled state of this node.
  70419. * @param value - the new enabled state
  70420. */
  70421. setEnabled(value: boolean): void;
  70422. /**
  70423. * Returns the Light associated shadow generator if any.
  70424. * @return the associated shadow generator.
  70425. */
  70426. getShadowGenerator(): Nullable<IShadowGenerator>;
  70427. /**
  70428. * Returns a Vector3, the absolute light position in the World.
  70429. * @returns the world space position of the light
  70430. */
  70431. getAbsolutePosition(): Vector3;
  70432. /**
  70433. * Specifies if the light will affect the passed mesh.
  70434. * @param mesh The mesh to test against the light
  70435. * @return true the mesh is affected otherwise, false.
  70436. */
  70437. canAffectMesh(mesh: AbstractMesh): boolean;
  70438. /**
  70439. * Sort function to order lights for rendering.
  70440. * @param a First Light object to compare to second.
  70441. * @param b Second Light object to compare first.
  70442. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  70443. */
  70444. static CompareLightsPriority(a: Light, b: Light): number;
  70445. /**
  70446. * Releases resources associated with this node.
  70447. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  70448. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  70449. */
  70450. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  70451. /**
  70452. * Returns the light type ID (integer).
  70453. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  70454. */
  70455. getTypeID(): number;
  70456. /**
  70457. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  70458. * @returns the scaled intensity in intensity mode unit
  70459. */
  70460. getScaledIntensity(): number;
  70461. /**
  70462. * Returns a new Light object, named "name", from the current one.
  70463. * @param name The name of the cloned light
  70464. * @returns the new created light
  70465. */
  70466. clone(name: string): Nullable<Light>;
  70467. /**
  70468. * Serializes the current light into a Serialization object.
  70469. * @returns the serialized object.
  70470. */
  70471. serialize(): any;
  70472. /**
  70473. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  70474. * This new light is named "name" and added to the passed scene.
  70475. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  70476. * @param name The friendly name of the light
  70477. * @param scene The scene the new light will belong to
  70478. * @returns the constructor function
  70479. */
  70480. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  70481. /**
  70482. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  70483. * @param parsedLight The JSON representation of the light
  70484. * @param scene The scene to create the parsed light in
  70485. * @returns the created light after parsing
  70486. */
  70487. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  70488. private _hookArrayForExcluded;
  70489. private _hookArrayForIncludedOnly;
  70490. private _resyncMeshes;
  70491. /**
  70492. * Forces the meshes to update their light related information in their rendering used effects
  70493. * @hidden Internal Use Only
  70494. */
  70495. _markMeshesAsLightDirty(): void;
  70496. /**
  70497. * Recomputes the cached photometric scale if needed.
  70498. */
  70499. private _computePhotometricScale;
  70500. /**
  70501. * Returns the Photometric Scale according to the light type and intensity mode.
  70502. */
  70503. private _getPhotometricScale;
  70504. /**
  70505. * Reorder the light in the scene according to their defined priority.
  70506. * @hidden Internal Use Only
  70507. */
  70508. _reorderLightsInScene(): void;
  70509. /**
  70510. * Prepares the list of defines specific to the light type.
  70511. * @param defines the list of defines
  70512. * @param lightIndex defines the index of the light for the effect
  70513. */
  70514. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  70515. }
  70516. }
  70517. declare module BABYLON {
  70518. /**
  70519. * Interface used to define Action
  70520. */
  70521. export interface IAction {
  70522. /**
  70523. * Trigger for the action
  70524. */
  70525. trigger: number;
  70526. /** Options of the trigger */
  70527. triggerOptions: any;
  70528. /**
  70529. * Gets the trigger parameters
  70530. * @returns the trigger parameters
  70531. */
  70532. getTriggerParameter(): any;
  70533. /**
  70534. * Internal only - executes current action event
  70535. * @hidden
  70536. */
  70537. _executeCurrent(evt?: ActionEvent): void;
  70538. /**
  70539. * Serialize placeholder for child classes
  70540. * @param parent of child
  70541. * @returns the serialized object
  70542. */
  70543. serialize(parent: any): any;
  70544. /**
  70545. * Internal only
  70546. * @hidden
  70547. */
  70548. _prepare(): void;
  70549. /**
  70550. * Internal only - manager for action
  70551. * @hidden
  70552. */
  70553. _actionManager: AbstractActionManager;
  70554. }
  70555. /**
  70556. * The action to be carried out following a trigger
  70557. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  70558. */
  70559. export class Action implements IAction {
  70560. /** the trigger, with or without parameters, for the action */
  70561. triggerOptions: any;
  70562. /**
  70563. * Trigger for the action
  70564. */
  70565. trigger: number;
  70566. /**
  70567. * Internal only - manager for action
  70568. * @hidden
  70569. */
  70570. _actionManager: ActionManager;
  70571. private _nextActiveAction;
  70572. private _child;
  70573. private _condition?;
  70574. private _triggerParameter;
  70575. /**
  70576. * An event triggered prior to action being executed.
  70577. */
  70578. onBeforeExecuteObservable: Observable<Action>;
  70579. /**
  70580. * Creates a new Action
  70581. * @param triggerOptions the trigger, with or without parameters, for the action
  70582. * @param condition an optional determinant of action
  70583. */
  70584. constructor(
  70585. /** the trigger, with or without parameters, for the action */
  70586. triggerOptions: any, condition?: Condition);
  70587. /**
  70588. * Internal only
  70589. * @hidden
  70590. */
  70591. _prepare(): void;
  70592. /**
  70593. * Gets the trigger parameters
  70594. * @returns the trigger parameters
  70595. */
  70596. getTriggerParameter(): any;
  70597. /**
  70598. * Internal only - executes current action event
  70599. * @hidden
  70600. */
  70601. _executeCurrent(evt?: ActionEvent): void;
  70602. /**
  70603. * Execute placeholder for child classes
  70604. * @param evt optional action event
  70605. */
  70606. execute(evt?: ActionEvent): void;
  70607. /**
  70608. * Skips to next active action
  70609. */
  70610. skipToNextActiveAction(): void;
  70611. /**
  70612. * Adds action to chain of actions, may be a DoNothingAction
  70613. * @param action defines the next action to execute
  70614. * @returns The action passed in
  70615. * @see https://www.babylonjs-playground.com/#1T30HR#0
  70616. */
  70617. then(action: Action): Action;
  70618. /**
  70619. * Internal only
  70620. * @hidden
  70621. */
  70622. _getProperty(propertyPath: string): string;
  70623. /**
  70624. * Internal only
  70625. * @hidden
  70626. */
  70627. _getEffectiveTarget(target: any, propertyPath: string): any;
  70628. /**
  70629. * Serialize placeholder for child classes
  70630. * @param parent of child
  70631. * @returns the serialized object
  70632. */
  70633. serialize(parent: any): any;
  70634. /**
  70635. * Internal only called by serialize
  70636. * @hidden
  70637. */
  70638. protected _serialize(serializedAction: any, parent?: any): any;
  70639. /**
  70640. * Internal only
  70641. * @hidden
  70642. */
  70643. static _SerializeValueAsString: (value: any) => string;
  70644. /**
  70645. * Internal only
  70646. * @hidden
  70647. */
  70648. static _GetTargetProperty: (target: Scene | Node) => {
  70649. name: string;
  70650. targetType: string;
  70651. value: string;
  70652. };
  70653. }
  70654. }
  70655. declare module BABYLON {
  70656. /**
  70657. * A Condition applied to an Action
  70658. */
  70659. export class Condition {
  70660. /**
  70661. * Internal only - manager for action
  70662. * @hidden
  70663. */
  70664. _actionManager: ActionManager;
  70665. /**
  70666. * Internal only
  70667. * @hidden
  70668. */
  70669. _evaluationId: number;
  70670. /**
  70671. * Internal only
  70672. * @hidden
  70673. */
  70674. _currentResult: boolean;
  70675. /**
  70676. * Creates a new Condition
  70677. * @param actionManager the manager of the action the condition is applied to
  70678. */
  70679. constructor(actionManager: ActionManager);
  70680. /**
  70681. * Check if the current condition is valid
  70682. * @returns a boolean
  70683. */
  70684. isValid(): boolean;
  70685. /**
  70686. * Internal only
  70687. * @hidden
  70688. */
  70689. _getProperty(propertyPath: string): string;
  70690. /**
  70691. * Internal only
  70692. * @hidden
  70693. */
  70694. _getEffectiveTarget(target: any, propertyPath: string): any;
  70695. /**
  70696. * Serialize placeholder for child classes
  70697. * @returns the serialized object
  70698. */
  70699. serialize(): any;
  70700. /**
  70701. * Internal only
  70702. * @hidden
  70703. */
  70704. protected _serialize(serializedCondition: any): any;
  70705. }
  70706. /**
  70707. * Defines specific conditional operators as extensions of Condition
  70708. */
  70709. export class ValueCondition extends Condition {
  70710. /** path to specify the property of the target the conditional operator uses */
  70711. propertyPath: string;
  70712. /** the value compared by the conditional operator against the current value of the property */
  70713. value: any;
  70714. /** the conditional operator, default ValueCondition.IsEqual */
  70715. operator: number;
  70716. /**
  70717. * Internal only
  70718. * @hidden
  70719. */
  70720. private static _IsEqual;
  70721. /**
  70722. * Internal only
  70723. * @hidden
  70724. */
  70725. private static _IsDifferent;
  70726. /**
  70727. * Internal only
  70728. * @hidden
  70729. */
  70730. private static _IsGreater;
  70731. /**
  70732. * Internal only
  70733. * @hidden
  70734. */
  70735. private static _IsLesser;
  70736. /**
  70737. * returns the number for IsEqual
  70738. */
  70739. static readonly IsEqual: number;
  70740. /**
  70741. * Returns the number for IsDifferent
  70742. */
  70743. static readonly IsDifferent: number;
  70744. /**
  70745. * Returns the number for IsGreater
  70746. */
  70747. static readonly IsGreater: number;
  70748. /**
  70749. * Returns the number for IsLesser
  70750. */
  70751. static readonly IsLesser: number;
  70752. /**
  70753. * Internal only The action manager for the condition
  70754. * @hidden
  70755. */
  70756. _actionManager: ActionManager;
  70757. /**
  70758. * Internal only
  70759. * @hidden
  70760. */
  70761. private _target;
  70762. /**
  70763. * Internal only
  70764. * @hidden
  70765. */
  70766. private _effectiveTarget;
  70767. /**
  70768. * Internal only
  70769. * @hidden
  70770. */
  70771. private _property;
  70772. /**
  70773. * Creates a new ValueCondition
  70774. * @param actionManager manager for the action the condition applies to
  70775. * @param target for the action
  70776. * @param propertyPath path to specify the property of the target the conditional operator uses
  70777. * @param value the value compared by the conditional operator against the current value of the property
  70778. * @param operator the conditional operator, default ValueCondition.IsEqual
  70779. */
  70780. constructor(actionManager: ActionManager, target: any,
  70781. /** path to specify the property of the target the conditional operator uses */
  70782. propertyPath: string,
  70783. /** the value compared by the conditional operator against the current value of the property */
  70784. value: any,
  70785. /** the conditional operator, default ValueCondition.IsEqual */
  70786. operator?: number);
  70787. /**
  70788. * Compares the given value with the property value for the specified conditional operator
  70789. * @returns the result of the comparison
  70790. */
  70791. isValid(): boolean;
  70792. /**
  70793. * Serialize the ValueCondition into a JSON compatible object
  70794. * @returns serialization object
  70795. */
  70796. serialize(): any;
  70797. /**
  70798. * Gets the name of the conditional operator for the ValueCondition
  70799. * @param operator the conditional operator
  70800. * @returns the name
  70801. */
  70802. static GetOperatorName(operator: number): string;
  70803. }
  70804. /**
  70805. * Defines a predicate condition as an extension of Condition
  70806. */
  70807. export class PredicateCondition extends Condition {
  70808. /** defines the predicate function used to validate the condition */
  70809. predicate: () => boolean;
  70810. /**
  70811. * Internal only - manager for action
  70812. * @hidden
  70813. */
  70814. _actionManager: ActionManager;
  70815. /**
  70816. * Creates a new PredicateCondition
  70817. * @param actionManager manager for the action the condition applies to
  70818. * @param predicate defines the predicate function used to validate the condition
  70819. */
  70820. constructor(actionManager: ActionManager,
  70821. /** defines the predicate function used to validate the condition */
  70822. predicate: () => boolean);
  70823. /**
  70824. * @returns the validity of the predicate condition
  70825. */
  70826. isValid(): boolean;
  70827. }
  70828. /**
  70829. * Defines a state condition as an extension of Condition
  70830. */
  70831. export class StateCondition extends Condition {
  70832. /** Value to compare with target state */
  70833. value: string;
  70834. /**
  70835. * Internal only - manager for action
  70836. * @hidden
  70837. */
  70838. _actionManager: ActionManager;
  70839. /**
  70840. * Internal only
  70841. * @hidden
  70842. */
  70843. private _target;
  70844. /**
  70845. * Creates a new StateCondition
  70846. * @param actionManager manager for the action the condition applies to
  70847. * @param target of the condition
  70848. * @param value to compare with target state
  70849. */
  70850. constructor(actionManager: ActionManager, target: any,
  70851. /** Value to compare with target state */
  70852. value: string);
  70853. /**
  70854. * Gets a boolean indicating if the current condition is met
  70855. * @returns the validity of the state
  70856. */
  70857. isValid(): boolean;
  70858. /**
  70859. * Serialize the StateCondition into a JSON compatible object
  70860. * @returns serialization object
  70861. */
  70862. serialize(): any;
  70863. }
  70864. }
  70865. declare module BABYLON {
  70866. /**
  70867. * This defines an action responsible to toggle a boolean once triggered.
  70868. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70869. */
  70870. export class SwitchBooleanAction extends Action {
  70871. /**
  70872. * The path to the boolean property in the target object
  70873. */
  70874. propertyPath: string;
  70875. private _target;
  70876. private _effectiveTarget;
  70877. private _property;
  70878. /**
  70879. * Instantiate the action
  70880. * @param triggerOptions defines the trigger options
  70881. * @param target defines the object containing the boolean
  70882. * @param propertyPath defines the path to the boolean property in the target object
  70883. * @param condition defines the trigger related conditions
  70884. */
  70885. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  70886. /** @hidden */
  70887. _prepare(): void;
  70888. /**
  70889. * Execute the action toggle the boolean value.
  70890. */
  70891. execute(): void;
  70892. /**
  70893. * Serializes the actions and its related information.
  70894. * @param parent defines the object to serialize in
  70895. * @returns the serialized object
  70896. */
  70897. serialize(parent: any): any;
  70898. }
  70899. /**
  70900. * This defines an action responsible to set a the state field of the target
  70901. * to a desired value once triggered.
  70902. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70903. */
  70904. export class SetStateAction extends Action {
  70905. /**
  70906. * The value to store in the state field.
  70907. */
  70908. value: string;
  70909. private _target;
  70910. /**
  70911. * Instantiate the action
  70912. * @param triggerOptions defines the trigger options
  70913. * @param target defines the object containing the state property
  70914. * @param value defines the value to store in the state field
  70915. * @param condition defines the trigger related conditions
  70916. */
  70917. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  70918. /**
  70919. * Execute the action and store the value on the target state property.
  70920. */
  70921. execute(): void;
  70922. /**
  70923. * Serializes the actions and its related information.
  70924. * @param parent defines the object to serialize in
  70925. * @returns the serialized object
  70926. */
  70927. serialize(parent: any): any;
  70928. }
  70929. /**
  70930. * This defines an action responsible to set a property of the target
  70931. * to a desired value once triggered.
  70932. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70933. */
  70934. export class SetValueAction extends Action {
  70935. /**
  70936. * The path of the property to set in the target.
  70937. */
  70938. propertyPath: string;
  70939. /**
  70940. * The value to set in the property
  70941. */
  70942. value: any;
  70943. private _target;
  70944. private _effectiveTarget;
  70945. private _property;
  70946. /**
  70947. * Instantiate the action
  70948. * @param triggerOptions defines the trigger options
  70949. * @param target defines the object containing the property
  70950. * @param propertyPath defines the path of the property to set in the target
  70951. * @param value defines the value to set in the property
  70952. * @param condition defines the trigger related conditions
  70953. */
  70954. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  70955. /** @hidden */
  70956. _prepare(): void;
  70957. /**
  70958. * Execute the action and set the targetted property to the desired value.
  70959. */
  70960. execute(): void;
  70961. /**
  70962. * Serializes the actions and its related information.
  70963. * @param parent defines the object to serialize in
  70964. * @returns the serialized object
  70965. */
  70966. serialize(parent: any): any;
  70967. }
  70968. /**
  70969. * This defines an action responsible to increment the target value
  70970. * to a desired value once triggered.
  70971. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70972. */
  70973. export class IncrementValueAction extends Action {
  70974. /**
  70975. * The path of the property to increment in the target.
  70976. */
  70977. propertyPath: string;
  70978. /**
  70979. * The value we should increment the property by.
  70980. */
  70981. value: any;
  70982. private _target;
  70983. private _effectiveTarget;
  70984. private _property;
  70985. /**
  70986. * Instantiate the action
  70987. * @param triggerOptions defines the trigger options
  70988. * @param target defines the object containing the property
  70989. * @param propertyPath defines the path of the property to increment in the target
  70990. * @param value defines the value value we should increment the property by
  70991. * @param condition defines the trigger related conditions
  70992. */
  70993. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  70994. /** @hidden */
  70995. _prepare(): void;
  70996. /**
  70997. * Execute the action and increment the target of the value amount.
  70998. */
  70999. execute(): void;
  71000. /**
  71001. * Serializes the actions and its related information.
  71002. * @param parent defines the object to serialize in
  71003. * @returns the serialized object
  71004. */
  71005. serialize(parent: any): any;
  71006. }
  71007. /**
  71008. * This defines an action responsible to start an animation once triggered.
  71009. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  71010. */
  71011. export class PlayAnimationAction extends Action {
  71012. /**
  71013. * Where the animation should start (animation frame)
  71014. */
  71015. from: number;
  71016. /**
  71017. * Where the animation should stop (animation frame)
  71018. */
  71019. to: number;
  71020. /**
  71021. * Define if the animation should loop or stop after the first play.
  71022. */
  71023. loop?: boolean;
  71024. private _target;
  71025. /**
  71026. * Instantiate the action
  71027. * @param triggerOptions defines the trigger options
  71028. * @param target defines the target animation or animation name
  71029. * @param from defines from where the animation should start (animation frame)
  71030. * @param end defines where the animation should stop (animation frame)
  71031. * @param loop defines if the animation should loop or stop after the first play
  71032. * @param condition defines the trigger related conditions
  71033. */
  71034. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  71035. /** @hidden */
  71036. _prepare(): void;
  71037. /**
  71038. * Execute the action and play the animation.
  71039. */
  71040. execute(): void;
  71041. /**
  71042. * Serializes the actions and its related information.
  71043. * @param parent defines the object to serialize in
  71044. * @returns the serialized object
  71045. */
  71046. serialize(parent: any): any;
  71047. }
  71048. /**
  71049. * This defines an action responsible to stop an animation once triggered.
  71050. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  71051. */
  71052. export class StopAnimationAction extends Action {
  71053. private _target;
  71054. /**
  71055. * Instantiate the action
  71056. * @param triggerOptions defines the trigger options
  71057. * @param target defines the target animation or animation name
  71058. * @param condition defines the trigger related conditions
  71059. */
  71060. constructor(triggerOptions: any, target: any, condition?: Condition);
  71061. /** @hidden */
  71062. _prepare(): void;
  71063. /**
  71064. * Execute the action and stop the animation.
  71065. */
  71066. execute(): void;
  71067. /**
  71068. * Serializes the actions and its related information.
  71069. * @param parent defines the object to serialize in
  71070. * @returns the serialized object
  71071. */
  71072. serialize(parent: any): any;
  71073. }
  71074. /**
  71075. * This defines an action responsible that does nothing once triggered.
  71076. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  71077. */
  71078. export class DoNothingAction extends Action {
  71079. /**
  71080. * Instantiate the action
  71081. * @param triggerOptions defines the trigger options
  71082. * @param condition defines the trigger related conditions
  71083. */
  71084. constructor(triggerOptions?: any, condition?: Condition);
  71085. /**
  71086. * Execute the action and do nothing.
  71087. */
  71088. execute(): void;
  71089. /**
  71090. * Serializes the actions and its related information.
  71091. * @param parent defines the object to serialize in
  71092. * @returns the serialized object
  71093. */
  71094. serialize(parent: any): any;
  71095. }
  71096. /**
  71097. * This defines an action responsible to trigger several actions once triggered.
  71098. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  71099. */
  71100. export class CombineAction extends Action {
  71101. /**
  71102. * The list of aggregated animations to run.
  71103. */
  71104. children: Action[];
  71105. /**
  71106. * Instantiate the action
  71107. * @param triggerOptions defines the trigger options
  71108. * @param children defines the list of aggregated animations to run
  71109. * @param condition defines the trigger related conditions
  71110. */
  71111. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  71112. /** @hidden */
  71113. _prepare(): void;
  71114. /**
  71115. * Execute the action and executes all the aggregated actions.
  71116. */
  71117. execute(evt: ActionEvent): void;
  71118. /**
  71119. * Serializes the actions and its related information.
  71120. * @param parent defines the object to serialize in
  71121. * @returns the serialized object
  71122. */
  71123. serialize(parent: any): any;
  71124. }
  71125. /**
  71126. * This defines an action responsible to run code (external event) once triggered.
  71127. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  71128. */
  71129. export class ExecuteCodeAction extends Action {
  71130. /**
  71131. * The callback function to run.
  71132. */
  71133. func: (evt: ActionEvent) => void;
  71134. /**
  71135. * Instantiate the action
  71136. * @param triggerOptions defines the trigger options
  71137. * @param func defines the callback function to run
  71138. * @param condition defines the trigger related conditions
  71139. */
  71140. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  71141. /**
  71142. * Execute the action and run the attached code.
  71143. */
  71144. execute(evt: ActionEvent): void;
  71145. }
  71146. /**
  71147. * This defines an action responsible to set the parent property of the target once triggered.
  71148. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  71149. */
  71150. export class SetParentAction extends Action {
  71151. private _parent;
  71152. private _target;
  71153. /**
  71154. * Instantiate the action
  71155. * @param triggerOptions defines the trigger options
  71156. * @param target defines the target containing the parent property
  71157. * @param parent defines from where the animation should start (animation frame)
  71158. * @param condition defines the trigger related conditions
  71159. */
  71160. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  71161. /** @hidden */
  71162. _prepare(): void;
  71163. /**
  71164. * Execute the action and set the parent property.
  71165. */
  71166. execute(): void;
  71167. /**
  71168. * Serializes the actions and its related information.
  71169. * @param parent defines the object to serialize in
  71170. * @returns the serialized object
  71171. */
  71172. serialize(parent: any): any;
  71173. }
  71174. }
  71175. declare module BABYLON {
  71176. /**
  71177. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  71178. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  71179. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  71180. */
  71181. export class ActionManager extends AbstractActionManager {
  71182. /**
  71183. * Nothing
  71184. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71185. */
  71186. static readonly NothingTrigger: number;
  71187. /**
  71188. * On pick
  71189. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71190. */
  71191. static readonly OnPickTrigger: number;
  71192. /**
  71193. * On left pick
  71194. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71195. */
  71196. static readonly OnLeftPickTrigger: number;
  71197. /**
  71198. * On right pick
  71199. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71200. */
  71201. static readonly OnRightPickTrigger: number;
  71202. /**
  71203. * On center pick
  71204. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71205. */
  71206. static readonly OnCenterPickTrigger: number;
  71207. /**
  71208. * On pick down
  71209. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71210. */
  71211. static readonly OnPickDownTrigger: number;
  71212. /**
  71213. * On double pick
  71214. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71215. */
  71216. static readonly OnDoublePickTrigger: number;
  71217. /**
  71218. * On pick up
  71219. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71220. */
  71221. static readonly OnPickUpTrigger: number;
  71222. /**
  71223. * On pick out.
  71224. * This trigger will only be raised if you also declared a OnPickDown
  71225. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71226. */
  71227. static readonly OnPickOutTrigger: number;
  71228. /**
  71229. * On long press
  71230. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71231. */
  71232. static readonly OnLongPressTrigger: number;
  71233. /**
  71234. * On pointer over
  71235. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71236. */
  71237. static readonly OnPointerOverTrigger: number;
  71238. /**
  71239. * On pointer out
  71240. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71241. */
  71242. static readonly OnPointerOutTrigger: number;
  71243. /**
  71244. * On every frame
  71245. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71246. */
  71247. static readonly OnEveryFrameTrigger: number;
  71248. /**
  71249. * On intersection enter
  71250. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71251. */
  71252. static readonly OnIntersectionEnterTrigger: number;
  71253. /**
  71254. * On intersection exit
  71255. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71256. */
  71257. static readonly OnIntersectionExitTrigger: number;
  71258. /**
  71259. * On key down
  71260. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71261. */
  71262. static readonly OnKeyDownTrigger: number;
  71263. /**
  71264. * On key up
  71265. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71266. */
  71267. static readonly OnKeyUpTrigger: number;
  71268. private _scene;
  71269. /**
  71270. * Creates a new action manager
  71271. * @param scene defines the hosting scene
  71272. */
  71273. constructor(scene: Scene);
  71274. /**
  71275. * Releases all associated resources
  71276. */
  71277. dispose(): void;
  71278. /**
  71279. * Gets hosting scene
  71280. * @returns the hosting scene
  71281. */
  71282. getScene(): Scene;
  71283. /**
  71284. * Does this action manager handles actions of any of the given triggers
  71285. * @param triggers defines the triggers to be tested
  71286. * @return a boolean indicating whether one (or more) of the triggers is handled
  71287. */
  71288. hasSpecificTriggers(triggers: number[]): boolean;
  71289. /**
  71290. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  71291. * speed.
  71292. * @param triggerA defines the trigger to be tested
  71293. * @param triggerB defines the trigger to be tested
  71294. * @return a boolean indicating whether one (or more) of the triggers is handled
  71295. */
  71296. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  71297. /**
  71298. * Does this action manager handles actions of a given trigger
  71299. * @param trigger defines the trigger to be tested
  71300. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  71301. * @return whether the trigger is handled
  71302. */
  71303. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  71304. /**
  71305. * Does this action manager has pointer triggers
  71306. */
  71307. readonly hasPointerTriggers: boolean;
  71308. /**
  71309. * Does this action manager has pick triggers
  71310. */
  71311. readonly hasPickTriggers: boolean;
  71312. /**
  71313. * Registers an action to this action manager
  71314. * @param action defines the action to be registered
  71315. * @return the action amended (prepared) after registration
  71316. */
  71317. registerAction(action: IAction): Nullable<IAction>;
  71318. /**
  71319. * Unregisters an action to this action manager
  71320. * @param action defines the action to be unregistered
  71321. * @return a boolean indicating whether the action has been unregistered
  71322. */
  71323. unregisterAction(action: IAction): Boolean;
  71324. /**
  71325. * Process a specific trigger
  71326. * @param trigger defines the trigger to process
  71327. * @param evt defines the event details to be processed
  71328. */
  71329. processTrigger(trigger: number, evt?: IActionEvent): void;
  71330. /** @hidden */
  71331. _getEffectiveTarget(target: any, propertyPath: string): any;
  71332. /** @hidden */
  71333. _getProperty(propertyPath: string): string;
  71334. /**
  71335. * Serialize this manager to a JSON object
  71336. * @param name defines the property name to store this manager
  71337. * @returns a JSON representation of this manager
  71338. */
  71339. serialize(name: string): any;
  71340. /**
  71341. * Creates a new ActionManager from a JSON data
  71342. * @param parsedActions defines the JSON data to read from
  71343. * @param object defines the hosting mesh
  71344. * @param scene defines the hosting scene
  71345. */
  71346. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  71347. /**
  71348. * Get a trigger name by index
  71349. * @param trigger defines the trigger index
  71350. * @returns a trigger name
  71351. */
  71352. static GetTriggerName(trigger: number): string;
  71353. }
  71354. }
  71355. declare module BABYLON {
  71356. /**
  71357. * Class representing a ray with position and direction
  71358. */
  71359. export class Ray {
  71360. /** origin point */
  71361. origin: Vector3;
  71362. /** direction */
  71363. direction: Vector3;
  71364. /** length of the ray */
  71365. length: number;
  71366. private static readonly TmpVector3;
  71367. private _tmpRay;
  71368. /**
  71369. * Creates a new ray
  71370. * @param origin origin point
  71371. * @param direction direction
  71372. * @param length length of the ray
  71373. */
  71374. constructor(
  71375. /** origin point */
  71376. origin: Vector3,
  71377. /** direction */
  71378. direction: Vector3,
  71379. /** length of the ray */
  71380. length?: number);
  71381. /**
  71382. * Checks if the ray intersects a box
  71383. * @param minimum bound of the box
  71384. * @param maximum bound of the box
  71385. * @param intersectionTreshold extra extend to be added to the box in all direction
  71386. * @returns if the box was hit
  71387. */
  71388. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  71389. /**
  71390. * Checks if the ray intersects a box
  71391. * @param box the bounding box to check
  71392. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  71393. * @returns if the box was hit
  71394. */
  71395. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  71396. /**
  71397. * If the ray hits a sphere
  71398. * @param sphere the bounding sphere to check
  71399. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  71400. * @returns true if it hits the sphere
  71401. */
  71402. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  71403. /**
  71404. * If the ray hits a triange
  71405. * @param vertex0 triangle vertex
  71406. * @param vertex1 triangle vertex
  71407. * @param vertex2 triangle vertex
  71408. * @returns intersection information if hit
  71409. */
  71410. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  71411. /**
  71412. * Checks if ray intersects a plane
  71413. * @param plane the plane to check
  71414. * @returns the distance away it was hit
  71415. */
  71416. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  71417. /**
  71418. * Checks if ray intersects a mesh
  71419. * @param mesh the mesh to check
  71420. * @param fastCheck if only the bounding box should checked
  71421. * @returns picking info of the intersecton
  71422. */
  71423. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  71424. /**
  71425. * Checks if ray intersects a mesh
  71426. * @param meshes the meshes to check
  71427. * @param fastCheck if only the bounding box should checked
  71428. * @param results array to store result in
  71429. * @returns Array of picking infos
  71430. */
  71431. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  71432. private _comparePickingInfo;
  71433. private static smallnum;
  71434. private static rayl;
  71435. /**
  71436. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  71437. * @param sega the first point of the segment to test the intersection against
  71438. * @param segb the second point of the segment to test the intersection against
  71439. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  71440. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  71441. */
  71442. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  71443. /**
  71444. * Update the ray from viewport position
  71445. * @param x position
  71446. * @param y y position
  71447. * @param viewportWidth viewport width
  71448. * @param viewportHeight viewport height
  71449. * @param world world matrix
  71450. * @param view view matrix
  71451. * @param projection projection matrix
  71452. * @returns this ray updated
  71453. */
  71454. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  71455. /**
  71456. * Creates a ray with origin and direction of 0,0,0
  71457. * @returns the new ray
  71458. */
  71459. static Zero(): Ray;
  71460. /**
  71461. * Creates a new ray from screen space and viewport
  71462. * @param x position
  71463. * @param y y position
  71464. * @param viewportWidth viewport width
  71465. * @param viewportHeight viewport height
  71466. * @param world world matrix
  71467. * @param view view matrix
  71468. * @param projection projection matrix
  71469. * @returns new ray
  71470. */
  71471. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  71472. /**
  71473. * 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
  71474. * transformed to the given world matrix.
  71475. * @param origin The origin point
  71476. * @param end The end point
  71477. * @param world a matrix to transform the ray to. Default is the identity matrix.
  71478. * @returns the new ray
  71479. */
  71480. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  71481. /**
  71482. * Transforms a ray by a matrix
  71483. * @param ray ray to transform
  71484. * @param matrix matrix to apply
  71485. * @returns the resulting new ray
  71486. */
  71487. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  71488. /**
  71489. * Transforms a ray by a matrix
  71490. * @param ray ray to transform
  71491. * @param matrix matrix to apply
  71492. * @param result ray to store result in
  71493. */
  71494. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  71495. /**
  71496. * Unproject a ray from screen space to object space
  71497. * @param sourceX defines the screen space x coordinate to use
  71498. * @param sourceY defines the screen space y coordinate to use
  71499. * @param viewportWidth defines the current width of the viewport
  71500. * @param viewportHeight defines the current height of the viewport
  71501. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  71502. * @param view defines the view matrix to use
  71503. * @param projection defines the projection matrix to use
  71504. */
  71505. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  71506. }
  71507. /**
  71508. * Type used to define predicate used to select faces when a mesh intersection is detected
  71509. */
  71510. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  71511. interface Scene {
  71512. /** @hidden */
  71513. _tempPickingRay: Nullable<Ray>;
  71514. /** @hidden */
  71515. _cachedRayForTransform: Ray;
  71516. /** @hidden */
  71517. _pickWithRayInverseMatrix: Matrix;
  71518. /** @hidden */
  71519. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  71520. /** @hidden */
  71521. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  71522. }
  71523. }
  71524. declare module BABYLON {
  71525. /**
  71526. * Groups all the scene component constants in one place to ease maintenance.
  71527. * @hidden
  71528. */
  71529. export class SceneComponentConstants {
  71530. static readonly NAME_EFFECTLAYER: string;
  71531. static readonly NAME_LAYER: string;
  71532. static readonly NAME_LENSFLARESYSTEM: string;
  71533. static readonly NAME_BOUNDINGBOXRENDERER: string;
  71534. static readonly NAME_PARTICLESYSTEM: string;
  71535. static readonly NAME_GAMEPAD: string;
  71536. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  71537. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  71538. static readonly NAME_DEPTHRENDERER: string;
  71539. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  71540. static readonly NAME_SPRITE: string;
  71541. static readonly NAME_OUTLINERENDERER: string;
  71542. static readonly NAME_PROCEDURALTEXTURE: string;
  71543. static readonly NAME_SHADOWGENERATOR: string;
  71544. static readonly NAME_OCTREE: string;
  71545. static readonly NAME_PHYSICSENGINE: string;
  71546. static readonly NAME_AUDIO: string;
  71547. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  71548. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  71549. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  71550. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  71551. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  71552. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  71553. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  71554. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  71555. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  71556. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  71557. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  71558. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  71559. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  71560. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  71561. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  71562. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  71563. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  71564. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  71565. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  71566. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  71567. static readonly STEP_AFTERRENDER_AUDIO: number;
  71568. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  71569. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  71570. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  71571. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  71572. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  71573. static readonly STEP_POINTERMOVE_SPRITE: number;
  71574. static readonly STEP_POINTERDOWN_SPRITE: number;
  71575. static readonly STEP_POINTERUP_SPRITE: number;
  71576. }
  71577. /**
  71578. * This represents a scene component.
  71579. *
  71580. * This is used to decouple the dependency the scene is having on the different workloads like
  71581. * layers, post processes...
  71582. */
  71583. export interface ISceneComponent {
  71584. /**
  71585. * The name of the component. Each component must have a unique name.
  71586. */
  71587. name: string;
  71588. /**
  71589. * The scene the component belongs to.
  71590. */
  71591. scene: Scene;
  71592. /**
  71593. * Register the component to one instance of a scene.
  71594. */
  71595. register(): void;
  71596. /**
  71597. * Rebuilds the elements related to this component in case of
  71598. * context lost for instance.
  71599. */
  71600. rebuild(): void;
  71601. /**
  71602. * Disposes the component and the associated ressources.
  71603. */
  71604. dispose(): void;
  71605. }
  71606. /**
  71607. * This represents a SERIALIZABLE scene component.
  71608. *
  71609. * This extends Scene Component to add Serialization methods on top.
  71610. */
  71611. export interface ISceneSerializableComponent extends ISceneComponent {
  71612. /**
  71613. * Adds all the element from the container to the scene
  71614. * @param container the container holding the elements
  71615. */
  71616. addFromContainer(container: AbstractScene): void;
  71617. /**
  71618. * Removes all the elements in the container from the scene
  71619. * @param container contains the elements to remove
  71620. * @param dispose if the removed element should be disposed (default: false)
  71621. */
  71622. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  71623. /**
  71624. * Serializes the component data to the specified json object
  71625. * @param serializationObject The object to serialize to
  71626. */
  71627. serialize(serializationObject: any): void;
  71628. }
  71629. /**
  71630. * Strong typing of a Mesh related stage step action
  71631. */
  71632. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  71633. /**
  71634. * Strong typing of a Evaluate Sub Mesh related stage step action
  71635. */
  71636. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  71637. /**
  71638. * Strong typing of a Active Mesh related stage step action
  71639. */
  71640. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  71641. /**
  71642. * Strong typing of a Camera related stage step action
  71643. */
  71644. export type CameraStageAction = (camera: Camera) => void;
  71645. /**
  71646. * Strong typing of a Camera Frame buffer related stage step action
  71647. */
  71648. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  71649. /**
  71650. * Strong typing of a Render Target related stage step action
  71651. */
  71652. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  71653. /**
  71654. * Strong typing of a RenderingGroup related stage step action
  71655. */
  71656. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  71657. /**
  71658. * Strong typing of a Mesh Render related stage step action
  71659. */
  71660. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  71661. /**
  71662. * Strong typing of a simple stage step action
  71663. */
  71664. export type SimpleStageAction = () => void;
  71665. /**
  71666. * Strong typing of a render target action.
  71667. */
  71668. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  71669. /**
  71670. * Strong typing of a pointer move action.
  71671. */
  71672. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  71673. /**
  71674. * Strong typing of a pointer up/down action.
  71675. */
  71676. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  71677. /**
  71678. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  71679. * @hidden
  71680. */
  71681. export class Stage<T extends Function> extends Array<{
  71682. index: number;
  71683. component: ISceneComponent;
  71684. action: T;
  71685. }> {
  71686. /**
  71687. * Hide ctor from the rest of the world.
  71688. * @param items The items to add.
  71689. */
  71690. private constructor();
  71691. /**
  71692. * Creates a new Stage.
  71693. * @returns A new instance of a Stage
  71694. */
  71695. static Create<T extends Function>(): Stage<T>;
  71696. /**
  71697. * Registers a step in an ordered way in the targeted stage.
  71698. * @param index Defines the position to register the step in
  71699. * @param component Defines the component attached to the step
  71700. * @param action Defines the action to launch during the step
  71701. */
  71702. registerStep(index: number, component: ISceneComponent, action: T): void;
  71703. /**
  71704. * Clears all the steps from the stage.
  71705. */
  71706. clear(): void;
  71707. }
  71708. }
  71709. declare module BABYLON {
  71710. interface Scene {
  71711. /** @hidden */
  71712. _pointerOverSprite: Nullable<Sprite>;
  71713. /** @hidden */
  71714. _pickedDownSprite: Nullable<Sprite>;
  71715. /** @hidden */
  71716. _tempSpritePickingRay: Nullable<Ray>;
  71717. /**
  71718. * All of the sprite managers added to this scene
  71719. * @see http://doc.babylonjs.com/babylon101/sprites
  71720. */
  71721. spriteManagers: Array<ISpriteManager>;
  71722. /**
  71723. * An event triggered when sprites rendering is about to start
  71724. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  71725. */
  71726. onBeforeSpritesRenderingObservable: Observable<Scene>;
  71727. /**
  71728. * An event triggered when sprites rendering is done
  71729. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  71730. */
  71731. onAfterSpritesRenderingObservable: Observable<Scene>;
  71732. /** @hidden */
  71733. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  71734. /** Launch a ray to try to pick a sprite in the scene
  71735. * @param x position on screen
  71736. * @param y position on screen
  71737. * @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
  71738. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  71739. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  71740. * @returns a PickingInfo
  71741. */
  71742. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  71743. /** Use the given ray to pick a sprite in the scene
  71744. * @param ray The ray (in world space) to use to pick meshes
  71745. * @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
  71746. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  71747. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  71748. * @returns a PickingInfo
  71749. */
  71750. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  71751. /**
  71752. * Force the sprite under the pointer
  71753. * @param sprite defines the sprite to use
  71754. */
  71755. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  71756. /**
  71757. * Gets the sprite under the pointer
  71758. * @returns a Sprite or null if no sprite is under the pointer
  71759. */
  71760. getPointerOverSprite(): Nullable<Sprite>;
  71761. }
  71762. /**
  71763. * Defines the sprite scene component responsible to manage sprites
  71764. * in a given scene.
  71765. */
  71766. export class SpriteSceneComponent implements ISceneComponent {
  71767. /**
  71768. * The component name helpfull to identify the component in the list of scene components.
  71769. */
  71770. readonly name: string;
  71771. /**
  71772. * The scene the component belongs to.
  71773. */
  71774. scene: Scene;
  71775. /** @hidden */
  71776. private _spritePredicate;
  71777. /**
  71778. * Creates a new instance of the component for the given scene
  71779. * @param scene Defines the scene to register the component in
  71780. */
  71781. constructor(scene: Scene);
  71782. /**
  71783. * Registers the component in a given scene
  71784. */
  71785. register(): void;
  71786. /**
  71787. * Rebuilds the elements related to this component in case of
  71788. * context lost for instance.
  71789. */
  71790. rebuild(): void;
  71791. /**
  71792. * Disposes the component and the associated ressources.
  71793. */
  71794. dispose(): void;
  71795. private _pickSpriteButKeepRay;
  71796. private _pointerMove;
  71797. private _pointerDown;
  71798. private _pointerUp;
  71799. }
  71800. }
  71801. declare module BABYLON {
  71802. /** @hidden */
  71803. export var fogFragmentDeclaration: {
  71804. name: string;
  71805. shader: string;
  71806. };
  71807. }
  71808. declare module BABYLON {
  71809. /** @hidden */
  71810. export var fogFragment: {
  71811. name: string;
  71812. shader: string;
  71813. };
  71814. }
  71815. declare module BABYLON {
  71816. /** @hidden */
  71817. export var spritesPixelShader: {
  71818. name: string;
  71819. shader: string;
  71820. };
  71821. }
  71822. declare module BABYLON {
  71823. /** @hidden */
  71824. export var fogVertexDeclaration: {
  71825. name: string;
  71826. shader: string;
  71827. };
  71828. }
  71829. declare module BABYLON {
  71830. /** @hidden */
  71831. export var spritesVertexShader: {
  71832. name: string;
  71833. shader: string;
  71834. };
  71835. }
  71836. declare module BABYLON {
  71837. /**
  71838. * Defines the minimum interface to fullfil in order to be a sprite manager.
  71839. */
  71840. export interface ISpriteManager extends IDisposable {
  71841. /**
  71842. * Restricts the camera to viewing objects with the same layerMask.
  71843. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  71844. */
  71845. layerMask: number;
  71846. /**
  71847. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  71848. */
  71849. isPickable: boolean;
  71850. /**
  71851. * Specifies the rendering group id for this mesh (0 by default)
  71852. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  71853. */
  71854. renderingGroupId: number;
  71855. /**
  71856. * Defines the list of sprites managed by the manager.
  71857. */
  71858. sprites: Array<Sprite>;
  71859. /**
  71860. * Tests the intersection of a sprite with a specific ray.
  71861. * @param ray The ray we are sending to test the collision
  71862. * @param camera The camera space we are sending rays in
  71863. * @param predicate A predicate allowing excluding sprites from the list of object to test
  71864. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  71865. * @returns picking info or null.
  71866. */
  71867. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  71868. /**
  71869. * Renders the list of sprites on screen.
  71870. */
  71871. render(): void;
  71872. }
  71873. /**
  71874. * Class used to manage multiple sprites on the same spritesheet
  71875. * @see http://doc.babylonjs.com/babylon101/sprites
  71876. */
  71877. export class SpriteManager implements ISpriteManager {
  71878. /** defines the manager's name */
  71879. name: string;
  71880. /** Gets the list of sprites */
  71881. sprites: Sprite[];
  71882. /** Gets or sets the rendering group id (0 by default) */
  71883. renderingGroupId: number;
  71884. /** Gets or sets camera layer mask */
  71885. layerMask: number;
  71886. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  71887. fogEnabled: boolean;
  71888. /** Gets or sets a boolean indicating if the sprites are pickable */
  71889. isPickable: boolean;
  71890. /** Defines the default width of a cell in the spritesheet */
  71891. cellWidth: number;
  71892. /** Defines the default height of a cell in the spritesheet */
  71893. cellHeight: number;
  71894. /**
  71895. * An event triggered when the manager is disposed.
  71896. */
  71897. onDisposeObservable: Observable<SpriteManager>;
  71898. private _onDisposeObserver;
  71899. /**
  71900. * Callback called when the manager is disposed
  71901. */
  71902. onDispose: () => void;
  71903. private _capacity;
  71904. private _spriteTexture;
  71905. private _epsilon;
  71906. private _scene;
  71907. private _vertexData;
  71908. private _buffer;
  71909. private _vertexBuffers;
  71910. private _indexBuffer;
  71911. private _effectBase;
  71912. private _effectFog;
  71913. /**
  71914. * Gets or sets the spritesheet texture
  71915. */
  71916. texture: Texture;
  71917. /**
  71918. * Creates a new sprite manager
  71919. * @param name defines the manager's name
  71920. * @param imgUrl defines the sprite sheet url
  71921. * @param capacity defines the maximum allowed number of sprites
  71922. * @param cellSize defines the size of a sprite cell
  71923. * @param scene defines the hosting scene
  71924. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  71925. * @param samplingMode defines the smapling mode to use with spritesheet
  71926. */
  71927. constructor(
  71928. /** defines the manager's name */
  71929. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  71930. private _appendSpriteVertex;
  71931. /**
  71932. * Intersects the sprites with a ray
  71933. * @param ray defines the ray to intersect with
  71934. * @param camera defines the current active camera
  71935. * @param predicate defines a predicate used to select candidate sprites
  71936. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  71937. * @returns null if no hit or a PickingInfo
  71938. */
  71939. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  71940. /**
  71941. * Render all child sprites
  71942. */
  71943. render(): void;
  71944. /**
  71945. * Release associated resources
  71946. */
  71947. dispose(): void;
  71948. }
  71949. }
  71950. declare module BABYLON {
  71951. /**
  71952. * Class used to represent a sprite
  71953. * @see http://doc.babylonjs.com/babylon101/sprites
  71954. */
  71955. export class Sprite {
  71956. /** defines the name */
  71957. name: string;
  71958. /** Gets or sets the current world position */
  71959. position: Vector3;
  71960. /** Gets or sets the main color */
  71961. color: Color4;
  71962. /** Gets or sets the width */
  71963. width: number;
  71964. /** Gets or sets the height */
  71965. height: number;
  71966. /** Gets or sets rotation angle */
  71967. angle: number;
  71968. /** Gets or sets the cell index in the sprite sheet */
  71969. cellIndex: number;
  71970. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  71971. invertU: number;
  71972. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  71973. invertV: number;
  71974. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  71975. disposeWhenFinishedAnimating: boolean;
  71976. /** Gets the list of attached animations */
  71977. animations: Animation[];
  71978. /** Gets or sets a boolean indicating if the sprite can be picked */
  71979. isPickable: boolean;
  71980. /**
  71981. * Gets or sets the associated action manager
  71982. */
  71983. actionManager: Nullable<ActionManager>;
  71984. private _animationStarted;
  71985. private _loopAnimation;
  71986. private _fromIndex;
  71987. private _toIndex;
  71988. private _delay;
  71989. private _direction;
  71990. private _manager;
  71991. private _time;
  71992. private _onAnimationEnd;
  71993. /**
  71994. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  71995. */
  71996. isVisible: boolean;
  71997. /**
  71998. * Gets or sets the sprite size
  71999. */
  72000. size: number;
  72001. /**
  72002. * Creates a new Sprite
  72003. * @param name defines the name
  72004. * @param manager defines the manager
  72005. */
  72006. constructor(
  72007. /** defines the name */
  72008. name: string, manager: ISpriteManager);
  72009. /**
  72010. * Starts an animation
  72011. * @param from defines the initial key
  72012. * @param to defines the end key
  72013. * @param loop defines if the animation must loop
  72014. * @param delay defines the start delay (in ms)
  72015. * @param onAnimationEnd defines a callback to call when animation ends
  72016. */
  72017. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  72018. /** Stops current animation (if any) */
  72019. stopAnimation(): void;
  72020. /** @hidden */
  72021. _animate(deltaTime: number): void;
  72022. /** Release associated resources */
  72023. dispose(): void;
  72024. }
  72025. }
  72026. declare module BABYLON {
  72027. /**
  72028. * Information about the result of picking within a scene
  72029. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  72030. */
  72031. export class PickingInfo {
  72032. /** @hidden */
  72033. _pickingUnavailable: boolean;
  72034. /**
  72035. * If the pick collided with an object
  72036. */
  72037. hit: boolean;
  72038. /**
  72039. * Distance away where the pick collided
  72040. */
  72041. distance: number;
  72042. /**
  72043. * The location of pick collision
  72044. */
  72045. pickedPoint: Nullable<Vector3>;
  72046. /**
  72047. * The mesh corresponding the the pick collision
  72048. */
  72049. pickedMesh: Nullable<AbstractMesh>;
  72050. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  72051. bu: number;
  72052. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  72053. bv: number;
  72054. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  72055. faceId: number;
  72056. /** Id of the the submesh that was picked */
  72057. subMeshId: number;
  72058. /** If a sprite was picked, this will be the sprite the pick collided with */
  72059. pickedSprite: Nullable<Sprite>;
  72060. /**
  72061. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  72062. */
  72063. originMesh: Nullable<AbstractMesh>;
  72064. /**
  72065. * The ray that was used to perform the picking.
  72066. */
  72067. ray: Nullable<Ray>;
  72068. /**
  72069. * Gets the normal correspodning to the face the pick collided with
  72070. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  72071. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  72072. * @returns The normal correspodning to the face the pick collided with
  72073. */
  72074. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  72075. /**
  72076. * Gets the texture coordinates of where the pick occured
  72077. * @returns the vector containing the coordnates of the texture
  72078. */
  72079. getTextureCoordinates(): Nullable<Vector2>;
  72080. }
  72081. }
  72082. declare module BABYLON {
  72083. /**
  72084. * Gather the list of pointer event types as constants.
  72085. */
  72086. export class PointerEventTypes {
  72087. /**
  72088. * 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.
  72089. */
  72090. static readonly POINTERDOWN: number;
  72091. /**
  72092. * The pointerup event is fired when a pointer is no longer active.
  72093. */
  72094. static readonly POINTERUP: number;
  72095. /**
  72096. * The pointermove event is fired when a pointer changes coordinates.
  72097. */
  72098. static readonly POINTERMOVE: number;
  72099. /**
  72100. * The pointerwheel event is fired when a mouse wheel has been rotated.
  72101. */
  72102. static readonly POINTERWHEEL: number;
  72103. /**
  72104. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  72105. */
  72106. static readonly POINTERPICK: number;
  72107. /**
  72108. * The pointertap event is fired when a the object has been touched and released without drag.
  72109. */
  72110. static readonly POINTERTAP: number;
  72111. /**
  72112. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  72113. */
  72114. static readonly POINTERDOUBLETAP: number;
  72115. }
  72116. /**
  72117. * Base class of pointer info types.
  72118. */
  72119. export class PointerInfoBase {
  72120. /**
  72121. * Defines the type of event (PointerEventTypes)
  72122. */
  72123. type: number;
  72124. /**
  72125. * Defines the related dom event
  72126. */
  72127. event: PointerEvent | MouseWheelEvent;
  72128. /**
  72129. * Instantiates the base class of pointers info.
  72130. * @param type Defines the type of event (PointerEventTypes)
  72131. * @param event Defines the related dom event
  72132. */
  72133. constructor(
  72134. /**
  72135. * Defines the type of event (PointerEventTypes)
  72136. */
  72137. type: number,
  72138. /**
  72139. * Defines the related dom event
  72140. */
  72141. event: PointerEvent | MouseWheelEvent);
  72142. }
  72143. /**
  72144. * This class is used to store pointer related info for the onPrePointerObservable event.
  72145. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  72146. */
  72147. export class PointerInfoPre extends PointerInfoBase {
  72148. /**
  72149. * Ray from a pointer if availible (eg. 6dof controller)
  72150. */
  72151. ray: Nullable<Ray>;
  72152. /**
  72153. * Defines the local position of the pointer on the canvas.
  72154. */
  72155. localPosition: Vector2;
  72156. /**
  72157. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  72158. */
  72159. skipOnPointerObservable: boolean;
  72160. /**
  72161. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  72162. * @param type Defines the type of event (PointerEventTypes)
  72163. * @param event Defines the related dom event
  72164. * @param localX Defines the local x coordinates of the pointer when the event occured
  72165. * @param localY Defines the local y coordinates of the pointer when the event occured
  72166. */
  72167. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  72168. }
  72169. /**
  72170. * This type contains all the data related to a pointer event in Babylon.js.
  72171. * 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.
  72172. */
  72173. export class PointerInfo extends PointerInfoBase {
  72174. /**
  72175. * Defines the picking info associated to the info (if any)\
  72176. */
  72177. pickInfo: Nullable<PickingInfo>;
  72178. /**
  72179. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  72180. * @param type Defines the type of event (PointerEventTypes)
  72181. * @param event Defines the related dom event
  72182. * @param pickInfo Defines the picking info associated to the info (if any)\
  72183. */
  72184. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  72185. /**
  72186. * Defines the picking info associated to the info (if any)\
  72187. */
  72188. pickInfo: Nullable<PickingInfo>);
  72189. }
  72190. /**
  72191. * Data relating to a touch event on the screen.
  72192. */
  72193. export interface PointerTouch {
  72194. /**
  72195. * X coordinate of touch.
  72196. */
  72197. x: number;
  72198. /**
  72199. * Y coordinate of touch.
  72200. */
  72201. y: number;
  72202. /**
  72203. * Id of touch. Unique for each finger.
  72204. */
  72205. pointerId: number;
  72206. /**
  72207. * Event type passed from DOM.
  72208. */
  72209. type: any;
  72210. }
  72211. }
  72212. declare module BABYLON {
  72213. /**
  72214. * Manage the mouse inputs to control the movement of a free camera.
  72215. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  72216. */
  72217. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  72218. /**
  72219. * Define if touch is enabled in the mouse input
  72220. */
  72221. touchEnabled: boolean;
  72222. /**
  72223. * Defines the camera the input is attached to.
  72224. */
  72225. camera: FreeCamera;
  72226. /**
  72227. * Defines the buttons associated with the input to handle camera move.
  72228. */
  72229. buttons: number[];
  72230. /**
  72231. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  72232. */
  72233. angularSensibility: number;
  72234. private _pointerInput;
  72235. private _onMouseMove;
  72236. private _observer;
  72237. private previousPosition;
  72238. /**
  72239. * Observable for when a pointer move event occurs containing the move offset
  72240. */
  72241. onPointerMovedObservable: Observable<{
  72242. offsetX: number;
  72243. offsetY: number;
  72244. }>;
  72245. /**
  72246. * @hidden
  72247. * If the camera should be rotated automatically based on pointer movement
  72248. */
  72249. _allowCameraRotation: boolean;
  72250. /**
  72251. * Manage the mouse inputs to control the movement of a free camera.
  72252. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  72253. * @param touchEnabled Defines if touch is enabled or not
  72254. */
  72255. constructor(
  72256. /**
  72257. * Define if touch is enabled in the mouse input
  72258. */
  72259. touchEnabled?: boolean);
  72260. /**
  72261. * Attach the input controls to a specific dom element to get the input from.
  72262. * @param element Defines the element the controls should be listened from
  72263. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72264. */
  72265. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  72266. /**
  72267. * Called on JS contextmenu event.
  72268. * Override this method to provide functionality.
  72269. */
  72270. protected onContextMenu(evt: PointerEvent): void;
  72271. /**
  72272. * Detach the current controls from the specified dom element.
  72273. * @param element Defines the element to stop listening the inputs from
  72274. */
  72275. detachControl(element: Nullable<HTMLElement>): void;
  72276. /**
  72277. * Gets the class name of the current intput.
  72278. * @returns the class name
  72279. */
  72280. getClassName(): string;
  72281. /**
  72282. * Get the friendly name associated with the input class.
  72283. * @returns the input friendly name
  72284. */
  72285. getSimpleName(): string;
  72286. }
  72287. }
  72288. declare module BABYLON {
  72289. /**
  72290. * Manage the touch inputs to control the movement of a free camera.
  72291. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  72292. */
  72293. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  72294. /**
  72295. * Defines the camera the input is attached to.
  72296. */
  72297. camera: FreeCamera;
  72298. /**
  72299. * Defines the touch sensibility for rotation.
  72300. * The higher the faster.
  72301. */
  72302. touchAngularSensibility: number;
  72303. /**
  72304. * Defines the touch sensibility for move.
  72305. * The higher the faster.
  72306. */
  72307. touchMoveSensibility: number;
  72308. private _offsetX;
  72309. private _offsetY;
  72310. private _pointerPressed;
  72311. private _pointerInput;
  72312. private _observer;
  72313. private _onLostFocus;
  72314. /**
  72315. * Attach the input controls to a specific dom element to get the input from.
  72316. * @param element Defines the element the controls should be listened from
  72317. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72318. */
  72319. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  72320. /**
  72321. * Detach the current controls from the specified dom element.
  72322. * @param element Defines the element to stop listening the inputs from
  72323. */
  72324. detachControl(element: Nullable<HTMLElement>): void;
  72325. /**
  72326. * Update the current camera state depending on the inputs that have been used this frame.
  72327. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  72328. */
  72329. checkInputs(): void;
  72330. /**
  72331. * Gets the class name of the current intput.
  72332. * @returns the class name
  72333. */
  72334. getClassName(): string;
  72335. /**
  72336. * Get the friendly name associated with the input class.
  72337. * @returns the input friendly name
  72338. */
  72339. getSimpleName(): string;
  72340. }
  72341. }
  72342. declare module BABYLON {
  72343. /**
  72344. * Default Inputs manager for the FreeCamera.
  72345. * It groups all the default supported inputs for ease of use.
  72346. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  72347. */
  72348. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  72349. /**
  72350. * @hidden
  72351. */
  72352. _mouseInput: Nullable<FreeCameraMouseInput>;
  72353. /**
  72354. * Instantiates a new FreeCameraInputsManager.
  72355. * @param camera Defines the camera the inputs belong to
  72356. */
  72357. constructor(camera: FreeCamera);
  72358. /**
  72359. * Add keyboard input support to the input manager.
  72360. * @returns the current input manager
  72361. */
  72362. addKeyboard(): FreeCameraInputsManager;
  72363. /**
  72364. * Add mouse input support to the input manager.
  72365. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  72366. * @returns the current input manager
  72367. */
  72368. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  72369. /**
  72370. * Removes the mouse input support from the manager
  72371. * @returns the current input manager
  72372. */
  72373. removeMouse(): FreeCameraInputsManager;
  72374. /**
  72375. * Add touch input support to the input manager.
  72376. * @returns the current input manager
  72377. */
  72378. addTouch(): FreeCameraInputsManager;
  72379. /**
  72380. * Remove all attached input methods from a camera
  72381. */
  72382. clear(): void;
  72383. }
  72384. }
  72385. declare module BABYLON {
  72386. /**
  72387. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  72388. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  72389. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  72390. */
  72391. export class FreeCamera extends TargetCamera {
  72392. /**
  72393. * Define the collision ellipsoid of the camera.
  72394. * This is helpful to simulate a camera body like the player body around the camera
  72395. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  72396. */
  72397. ellipsoid: Vector3;
  72398. /**
  72399. * Define an offset for the position of the ellipsoid around the camera.
  72400. * This can be helpful to determine the center of the body near the gravity center of the body
  72401. * instead of its head.
  72402. */
  72403. ellipsoidOffset: Vector3;
  72404. /**
  72405. * Enable or disable collisions of the camera with the rest of the scene objects.
  72406. */
  72407. checkCollisions: boolean;
  72408. /**
  72409. * Enable or disable gravity on the camera.
  72410. */
  72411. applyGravity: boolean;
  72412. /**
  72413. * Define the input manager associated to the camera.
  72414. */
  72415. inputs: FreeCameraInputsManager;
  72416. /**
  72417. * Gets the input sensibility for a mouse input. (default is 2000.0)
  72418. * Higher values reduce sensitivity.
  72419. */
  72420. /**
  72421. * Sets the input sensibility for a mouse input. (default is 2000.0)
  72422. * Higher values reduce sensitivity.
  72423. */
  72424. angularSensibility: number;
  72425. /**
  72426. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  72427. */
  72428. keysUp: number[];
  72429. /**
  72430. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  72431. */
  72432. keysDown: number[];
  72433. /**
  72434. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  72435. */
  72436. keysLeft: number[];
  72437. /**
  72438. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  72439. */
  72440. keysRight: number[];
  72441. /**
  72442. * Event raised when the camera collide with a mesh in the scene.
  72443. */
  72444. onCollide: (collidedMesh: AbstractMesh) => void;
  72445. private _collider;
  72446. private _needMoveForGravity;
  72447. private _oldPosition;
  72448. private _diffPosition;
  72449. private _newPosition;
  72450. /** @hidden */
  72451. _localDirection: Vector3;
  72452. /** @hidden */
  72453. _transformedDirection: Vector3;
  72454. /**
  72455. * Instantiates a Free Camera.
  72456. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  72457. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  72458. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  72459. * @param name Define the name of the camera in the scene
  72460. * @param position Define the start position of the camera in the scene
  72461. * @param scene Define the scene the camera belongs to
  72462. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  72463. */
  72464. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  72465. /**
  72466. * Attached controls to the current camera.
  72467. * @param element Defines the element the controls should be listened from
  72468. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72469. */
  72470. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  72471. /**
  72472. * Detach the current controls from the camera.
  72473. * The camera will stop reacting to inputs.
  72474. * @param element Defines the element to stop listening the inputs from
  72475. */
  72476. detachControl(element: HTMLElement): void;
  72477. private _collisionMask;
  72478. /**
  72479. * Define a collision mask to limit the list of object the camera can collide with
  72480. */
  72481. collisionMask: number;
  72482. /** @hidden */
  72483. _collideWithWorld(displacement: Vector3): void;
  72484. private _onCollisionPositionChange;
  72485. /** @hidden */
  72486. _checkInputs(): void;
  72487. /** @hidden */
  72488. _decideIfNeedsToMove(): boolean;
  72489. /** @hidden */
  72490. _updatePosition(): void;
  72491. /**
  72492. * Destroy the camera and release the current resources hold by it.
  72493. */
  72494. dispose(): void;
  72495. /**
  72496. * Gets the current object class name.
  72497. * @return the class name
  72498. */
  72499. getClassName(): string;
  72500. }
  72501. }
  72502. declare module BABYLON {
  72503. /**
  72504. * Represents a gamepad control stick position
  72505. */
  72506. export class StickValues {
  72507. /**
  72508. * The x component of the control stick
  72509. */
  72510. x: number;
  72511. /**
  72512. * The y component of the control stick
  72513. */
  72514. y: number;
  72515. /**
  72516. * Initializes the gamepad x and y control stick values
  72517. * @param x The x component of the gamepad control stick value
  72518. * @param y The y component of the gamepad control stick value
  72519. */
  72520. constructor(
  72521. /**
  72522. * The x component of the control stick
  72523. */
  72524. x: number,
  72525. /**
  72526. * The y component of the control stick
  72527. */
  72528. y: number);
  72529. }
  72530. /**
  72531. * An interface which manages callbacks for gamepad button changes
  72532. */
  72533. export interface GamepadButtonChanges {
  72534. /**
  72535. * Called when a gamepad has been changed
  72536. */
  72537. changed: boolean;
  72538. /**
  72539. * Called when a gamepad press event has been triggered
  72540. */
  72541. pressChanged: boolean;
  72542. /**
  72543. * Called when a touch event has been triggered
  72544. */
  72545. touchChanged: boolean;
  72546. /**
  72547. * Called when a value has changed
  72548. */
  72549. valueChanged: boolean;
  72550. }
  72551. /**
  72552. * Represents a gamepad
  72553. */
  72554. export class Gamepad {
  72555. /**
  72556. * The id of the gamepad
  72557. */
  72558. id: string;
  72559. /**
  72560. * The index of the gamepad
  72561. */
  72562. index: number;
  72563. /**
  72564. * The browser gamepad
  72565. */
  72566. browserGamepad: any;
  72567. /**
  72568. * Specifies what type of gamepad this represents
  72569. */
  72570. type: number;
  72571. private _leftStick;
  72572. private _rightStick;
  72573. /** @hidden */
  72574. _isConnected: boolean;
  72575. private _leftStickAxisX;
  72576. private _leftStickAxisY;
  72577. private _rightStickAxisX;
  72578. private _rightStickAxisY;
  72579. /**
  72580. * Triggered when the left control stick has been changed
  72581. */
  72582. private _onleftstickchanged;
  72583. /**
  72584. * Triggered when the right control stick has been changed
  72585. */
  72586. private _onrightstickchanged;
  72587. /**
  72588. * Represents a gamepad controller
  72589. */
  72590. static GAMEPAD: number;
  72591. /**
  72592. * Represents a generic controller
  72593. */
  72594. static GENERIC: number;
  72595. /**
  72596. * Represents an XBox controller
  72597. */
  72598. static XBOX: number;
  72599. /**
  72600. * Represents a pose-enabled controller
  72601. */
  72602. static POSE_ENABLED: number;
  72603. /**
  72604. * Specifies whether the left control stick should be Y-inverted
  72605. */
  72606. protected _invertLeftStickY: boolean;
  72607. /**
  72608. * Specifies if the gamepad has been connected
  72609. */
  72610. readonly isConnected: boolean;
  72611. /**
  72612. * Initializes the gamepad
  72613. * @param id The id of the gamepad
  72614. * @param index The index of the gamepad
  72615. * @param browserGamepad The browser gamepad
  72616. * @param leftStickX The x component of the left joystick
  72617. * @param leftStickY The y component of the left joystick
  72618. * @param rightStickX The x component of the right joystick
  72619. * @param rightStickY The y component of the right joystick
  72620. */
  72621. constructor(
  72622. /**
  72623. * The id of the gamepad
  72624. */
  72625. id: string,
  72626. /**
  72627. * The index of the gamepad
  72628. */
  72629. index: number,
  72630. /**
  72631. * The browser gamepad
  72632. */
  72633. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  72634. /**
  72635. * Callback triggered when the left joystick has changed
  72636. * @param callback
  72637. */
  72638. onleftstickchanged(callback: (values: StickValues) => void): void;
  72639. /**
  72640. * Callback triggered when the right joystick has changed
  72641. * @param callback
  72642. */
  72643. onrightstickchanged(callback: (values: StickValues) => void): void;
  72644. /**
  72645. * Gets the left joystick
  72646. */
  72647. /**
  72648. * Sets the left joystick values
  72649. */
  72650. leftStick: StickValues;
  72651. /**
  72652. * Gets the right joystick
  72653. */
  72654. /**
  72655. * Sets the right joystick value
  72656. */
  72657. rightStick: StickValues;
  72658. /**
  72659. * Updates the gamepad joystick positions
  72660. */
  72661. update(): void;
  72662. /**
  72663. * Disposes the gamepad
  72664. */
  72665. dispose(): void;
  72666. }
  72667. /**
  72668. * Represents a generic gamepad
  72669. */
  72670. export class GenericPad extends Gamepad {
  72671. private _buttons;
  72672. private _onbuttondown;
  72673. private _onbuttonup;
  72674. /**
  72675. * Observable triggered when a button has been pressed
  72676. */
  72677. onButtonDownObservable: Observable<number>;
  72678. /**
  72679. * Observable triggered when a button has been released
  72680. */
  72681. onButtonUpObservable: Observable<number>;
  72682. /**
  72683. * Callback triggered when a button has been pressed
  72684. * @param callback Called when a button has been pressed
  72685. */
  72686. onbuttondown(callback: (buttonPressed: number) => void): void;
  72687. /**
  72688. * Callback triggered when a button has been released
  72689. * @param callback Called when a button has been released
  72690. */
  72691. onbuttonup(callback: (buttonReleased: number) => void): void;
  72692. /**
  72693. * Initializes the generic gamepad
  72694. * @param id The id of the generic gamepad
  72695. * @param index The index of the generic gamepad
  72696. * @param browserGamepad The browser gamepad
  72697. */
  72698. constructor(id: string, index: number, browserGamepad: any);
  72699. private _setButtonValue;
  72700. /**
  72701. * Updates the generic gamepad
  72702. */
  72703. update(): void;
  72704. /**
  72705. * Disposes the generic gamepad
  72706. */
  72707. dispose(): void;
  72708. }
  72709. }
  72710. declare module BABYLON {
  72711. /**
  72712. * Defines the types of pose enabled controllers that are supported
  72713. */
  72714. export enum PoseEnabledControllerType {
  72715. /**
  72716. * HTC Vive
  72717. */
  72718. VIVE = 0,
  72719. /**
  72720. * Oculus Rift
  72721. */
  72722. OCULUS = 1,
  72723. /**
  72724. * Windows mixed reality
  72725. */
  72726. WINDOWS = 2,
  72727. /**
  72728. * Samsung gear VR
  72729. */
  72730. GEAR_VR = 3,
  72731. /**
  72732. * Google Daydream
  72733. */
  72734. DAYDREAM = 4,
  72735. /**
  72736. * Generic
  72737. */
  72738. GENERIC = 5
  72739. }
  72740. /**
  72741. * Defines the MutableGamepadButton interface for the state of a gamepad button
  72742. */
  72743. export interface MutableGamepadButton {
  72744. /**
  72745. * Value of the button/trigger
  72746. */
  72747. value: number;
  72748. /**
  72749. * If the button/trigger is currently touched
  72750. */
  72751. touched: boolean;
  72752. /**
  72753. * If the button/trigger is currently pressed
  72754. */
  72755. pressed: boolean;
  72756. }
  72757. /**
  72758. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  72759. * @hidden
  72760. */
  72761. export interface ExtendedGamepadButton extends GamepadButton {
  72762. /**
  72763. * If the button/trigger is currently pressed
  72764. */
  72765. readonly pressed: boolean;
  72766. /**
  72767. * If the button/trigger is currently touched
  72768. */
  72769. readonly touched: boolean;
  72770. /**
  72771. * Value of the button/trigger
  72772. */
  72773. readonly value: number;
  72774. }
  72775. /** @hidden */
  72776. export interface _GamePadFactory {
  72777. /**
  72778. * Returns wether or not the current gamepad can be created for this type of controller.
  72779. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  72780. * @returns true if it can be created, otherwise false
  72781. */
  72782. canCreate(gamepadInfo: any): boolean;
  72783. /**
  72784. * Creates a new instance of the Gamepad.
  72785. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  72786. * @returns the new gamepad instance
  72787. */
  72788. create(gamepadInfo: any): Gamepad;
  72789. }
  72790. /**
  72791. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  72792. */
  72793. export class PoseEnabledControllerHelper {
  72794. /** @hidden */
  72795. static _ControllerFactories: _GamePadFactory[];
  72796. /** @hidden */
  72797. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  72798. /**
  72799. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  72800. * @param vrGamepad the gamepad to initialized
  72801. * @returns a vr controller of the type the gamepad identified as
  72802. */
  72803. static InitiateController(vrGamepad: any): Gamepad;
  72804. }
  72805. /**
  72806. * Defines the PoseEnabledController object that contains state of a vr capable controller
  72807. */
  72808. export class PoseEnabledController extends Gamepad implements PoseControlled {
  72809. private _deviceRoomPosition;
  72810. private _deviceRoomRotationQuaternion;
  72811. /**
  72812. * The device position in babylon space
  72813. */
  72814. devicePosition: Vector3;
  72815. /**
  72816. * The device rotation in babylon space
  72817. */
  72818. deviceRotationQuaternion: Quaternion;
  72819. /**
  72820. * The scale factor of the device in babylon space
  72821. */
  72822. deviceScaleFactor: number;
  72823. /**
  72824. * (Likely devicePosition should be used instead) The device position in its room space
  72825. */
  72826. position: Vector3;
  72827. /**
  72828. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  72829. */
  72830. rotationQuaternion: Quaternion;
  72831. /**
  72832. * The type of controller (Eg. Windows mixed reality)
  72833. */
  72834. controllerType: PoseEnabledControllerType;
  72835. protected _calculatedPosition: Vector3;
  72836. private _calculatedRotation;
  72837. /**
  72838. * The raw pose from the device
  72839. */
  72840. rawPose: DevicePose;
  72841. private _trackPosition;
  72842. private _maxRotationDistFromHeadset;
  72843. private _draggedRoomRotation;
  72844. /**
  72845. * @hidden
  72846. */
  72847. _disableTrackPosition(fixedPosition: Vector3): void;
  72848. /**
  72849. * Internal, the mesh attached to the controller
  72850. * @hidden
  72851. */
  72852. _mesh: Nullable<AbstractMesh>;
  72853. private _poseControlledCamera;
  72854. private _leftHandSystemQuaternion;
  72855. /**
  72856. * Internal, matrix used to convert room space to babylon space
  72857. * @hidden
  72858. */
  72859. _deviceToWorld: Matrix;
  72860. /**
  72861. * Node to be used when casting a ray from the controller
  72862. * @hidden
  72863. */
  72864. _pointingPoseNode: Nullable<TransformNode>;
  72865. /**
  72866. * Name of the child mesh that can be used to cast a ray from the controller
  72867. */
  72868. static readonly POINTING_POSE: string;
  72869. /**
  72870. * Creates a new PoseEnabledController from a gamepad
  72871. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  72872. */
  72873. constructor(browserGamepad: any);
  72874. private _workingMatrix;
  72875. /**
  72876. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  72877. */
  72878. update(): void;
  72879. /**
  72880. * Updates only the pose device and mesh without doing any button event checking
  72881. */
  72882. protected _updatePoseAndMesh(): void;
  72883. /**
  72884. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  72885. * @param poseData raw pose fromthe device
  72886. */
  72887. updateFromDevice(poseData: DevicePose): void;
  72888. /**
  72889. * @hidden
  72890. */
  72891. _meshAttachedObservable: Observable<AbstractMesh>;
  72892. /**
  72893. * Attaches a mesh to the controller
  72894. * @param mesh the mesh to be attached
  72895. */
  72896. attachToMesh(mesh: AbstractMesh): void;
  72897. /**
  72898. * Attaches the controllers mesh to a camera
  72899. * @param camera the camera the mesh should be attached to
  72900. */
  72901. attachToPoseControlledCamera(camera: TargetCamera): void;
  72902. /**
  72903. * Disposes of the controller
  72904. */
  72905. dispose(): void;
  72906. /**
  72907. * The mesh that is attached to the controller
  72908. */
  72909. readonly mesh: Nullable<AbstractMesh>;
  72910. /**
  72911. * Gets the ray of the controller in the direction the controller is pointing
  72912. * @param length the length the resulting ray should be
  72913. * @returns a ray in the direction the controller is pointing
  72914. */
  72915. getForwardRay(length?: number): Ray;
  72916. }
  72917. }
  72918. declare module BABYLON {
  72919. /**
  72920. * Defines the WebVRController object that represents controllers tracked in 3D space
  72921. */
  72922. export abstract class WebVRController extends PoseEnabledController {
  72923. /**
  72924. * Internal, the default controller model for the controller
  72925. */
  72926. protected _defaultModel: AbstractMesh;
  72927. /**
  72928. * Fired when the trigger state has changed
  72929. */
  72930. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  72931. /**
  72932. * Fired when the main button state has changed
  72933. */
  72934. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  72935. /**
  72936. * Fired when the secondary button state has changed
  72937. */
  72938. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  72939. /**
  72940. * Fired when the pad state has changed
  72941. */
  72942. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  72943. /**
  72944. * Fired when controllers stick values have changed
  72945. */
  72946. onPadValuesChangedObservable: Observable<StickValues>;
  72947. /**
  72948. * Array of button availible on the controller
  72949. */
  72950. protected _buttons: Array<MutableGamepadButton>;
  72951. private _onButtonStateChange;
  72952. /**
  72953. * Fired when a controller button's state has changed
  72954. * @param callback the callback containing the button that was modified
  72955. */
  72956. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  72957. /**
  72958. * X and Y axis corrisponding to the controllers joystick
  72959. */
  72960. pad: StickValues;
  72961. /**
  72962. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  72963. */
  72964. hand: string;
  72965. /**
  72966. * The default controller model for the controller
  72967. */
  72968. readonly defaultModel: AbstractMesh;
  72969. /**
  72970. * Creates a new WebVRController from a gamepad
  72971. * @param vrGamepad the gamepad that the WebVRController should be created from
  72972. */
  72973. constructor(vrGamepad: any);
  72974. /**
  72975. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  72976. */
  72977. update(): void;
  72978. /**
  72979. * Function to be called when a button is modified
  72980. */
  72981. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  72982. /**
  72983. * Loads a mesh and attaches it to the controller
  72984. * @param scene the scene the mesh should be added to
  72985. * @param meshLoaded callback for when the mesh has been loaded
  72986. */
  72987. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  72988. private _setButtonValue;
  72989. private _changes;
  72990. private _checkChanges;
  72991. /**
  72992. * Disposes of th webVRCOntroller
  72993. */
  72994. dispose(): void;
  72995. }
  72996. }
  72997. declare module BABYLON {
  72998. /**
  72999. * The HemisphericLight simulates the ambient environment light,
  73000. * so the passed direction is the light reflection direction, not the incoming direction.
  73001. */
  73002. export class HemisphericLight extends Light {
  73003. /**
  73004. * The groundColor is the light in the opposite direction to the one specified during creation.
  73005. * 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.
  73006. */
  73007. groundColor: Color3;
  73008. /**
  73009. * The light reflection direction, not the incoming direction.
  73010. */
  73011. direction: Vector3;
  73012. /**
  73013. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  73014. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  73015. * The HemisphericLight can't cast shadows.
  73016. * Documentation : https://doc.babylonjs.com/babylon101/lights
  73017. * @param name The friendly name of the light
  73018. * @param direction The direction of the light reflection
  73019. * @param scene The scene the light belongs to
  73020. */
  73021. constructor(name: string, direction: Vector3, scene: Scene);
  73022. protected _buildUniformLayout(): void;
  73023. /**
  73024. * Returns the string "HemisphericLight".
  73025. * @return The class name
  73026. */
  73027. getClassName(): string;
  73028. /**
  73029. * Sets the HemisphericLight direction towards the passed target (Vector3).
  73030. * Returns the updated direction.
  73031. * @param target The target the direction should point to
  73032. * @return The computed direction
  73033. */
  73034. setDirectionToTarget(target: Vector3): Vector3;
  73035. /**
  73036. * Returns the shadow generator associated to the light.
  73037. * @returns Always null for hemispheric lights because it does not support shadows.
  73038. */
  73039. getShadowGenerator(): Nullable<IShadowGenerator>;
  73040. /**
  73041. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  73042. * @param effect The effect to update
  73043. * @param lightIndex The index of the light in the effect to update
  73044. * @returns The hemispheric light
  73045. */
  73046. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  73047. /**
  73048. * Computes the world matrix of the node
  73049. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  73050. * @param useWasUpdatedFlag defines a reserved property
  73051. * @returns the world matrix
  73052. */
  73053. computeWorldMatrix(): Matrix;
  73054. /**
  73055. * Returns the integer 3.
  73056. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  73057. */
  73058. getTypeID(): number;
  73059. /**
  73060. * Prepares the list of defines specific to the light type.
  73061. * @param defines the list of defines
  73062. * @param lightIndex defines the index of the light for the effect
  73063. */
  73064. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  73065. }
  73066. }
  73067. declare module BABYLON {
  73068. /** @hidden */
  73069. export var vrMultiviewToSingleviewPixelShader: {
  73070. name: string;
  73071. shader: string;
  73072. };
  73073. }
  73074. declare module BABYLON {
  73075. /**
  73076. * Renders to multiple views with a single draw call
  73077. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  73078. */
  73079. export class MultiviewRenderTarget extends RenderTargetTexture {
  73080. /**
  73081. * Creates a multiview render target
  73082. * @param scene scene used with the render target
  73083. * @param size the size of the render target (used for each view)
  73084. */
  73085. constructor(scene: Scene, size?: number | {
  73086. width: number;
  73087. height: number;
  73088. } | {
  73089. ratio: number;
  73090. });
  73091. /**
  73092. * @hidden
  73093. * @param faceIndex the face index, if its a cube texture
  73094. */
  73095. _bindFrameBuffer(faceIndex?: number): void;
  73096. /**
  73097. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  73098. * @returns the view count
  73099. */
  73100. getViewCount(): number;
  73101. }
  73102. }
  73103. declare module BABYLON {
  73104. interface Engine {
  73105. /**
  73106. * Creates a new multiview render target
  73107. * @param width defines the width of the texture
  73108. * @param height defines the height of the texture
  73109. * @returns the created multiview texture
  73110. */
  73111. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  73112. /**
  73113. * Binds a multiview framebuffer to be drawn to
  73114. * @param multiviewTexture texture to bind
  73115. */
  73116. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  73117. }
  73118. interface Camera {
  73119. /**
  73120. * @hidden
  73121. * 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)
  73122. */
  73123. _useMultiviewToSingleView: boolean;
  73124. /**
  73125. * @hidden
  73126. * 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)
  73127. */
  73128. _multiviewTexture: Nullable<RenderTargetTexture>;
  73129. /**
  73130. * @hidden
  73131. * ensures the multiview texture of the camera exists and has the specified width/height
  73132. * @param width height to set on the multiview texture
  73133. * @param height width to set on the multiview texture
  73134. */
  73135. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  73136. }
  73137. interface Scene {
  73138. /** @hidden */
  73139. _transformMatrixR: Matrix;
  73140. /** @hidden */
  73141. _multiviewSceneUbo: Nullable<UniformBuffer>;
  73142. /** @hidden */
  73143. _createMultiviewUbo(): void;
  73144. /** @hidden */
  73145. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  73146. /** @hidden */
  73147. _renderMultiviewToSingleView(camera: Camera): void;
  73148. }
  73149. }
  73150. declare module BABYLON {
  73151. /**
  73152. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  73153. * This will not be used for webXR as it supports displaying texture arrays directly
  73154. */
  73155. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  73156. /**
  73157. * Initializes a VRMultiviewToSingleview
  73158. * @param name name of the post process
  73159. * @param camera camera to be applied to
  73160. * @param scaleFactor scaling factor to the size of the output texture
  73161. */
  73162. constructor(name: string, camera: Camera, scaleFactor: number);
  73163. }
  73164. }
  73165. declare module BABYLON {
  73166. /**
  73167. * Defines the interface used by display changed events
  73168. */
  73169. interface IDisplayChangedEventArgs {
  73170. /** Gets the vrDisplay object (if any) */
  73171. vrDisplay: Nullable<any>;
  73172. /** Gets a boolean indicating if webVR is supported */
  73173. vrSupported: boolean;
  73174. }
  73175. interface Engine {
  73176. /** @hidden */
  73177. _vrDisplay: any;
  73178. /** @hidden */
  73179. _vrSupported: boolean;
  73180. /** @hidden */
  73181. _oldSize: Size;
  73182. /** @hidden */
  73183. _oldHardwareScaleFactor: number;
  73184. /** @hidden */
  73185. _vrExclusivePointerMode: boolean;
  73186. /** @hidden */
  73187. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  73188. /** @hidden */
  73189. _onVRDisplayPointerRestricted: () => void;
  73190. /** @hidden */
  73191. _onVRDisplayPointerUnrestricted: () => void;
  73192. /** @hidden */
  73193. _onVrDisplayConnect: Nullable<(display: any) => void>;
  73194. /** @hidden */
  73195. _onVrDisplayDisconnect: Nullable<() => void>;
  73196. /** @hidden */
  73197. _onVrDisplayPresentChange: Nullable<() => void>;
  73198. /**
  73199. * Observable signaled when VR display mode changes
  73200. */
  73201. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  73202. /**
  73203. * Observable signaled when VR request present is complete
  73204. */
  73205. onVRRequestPresentComplete: Observable<boolean>;
  73206. /**
  73207. * Observable signaled when VR request present starts
  73208. */
  73209. onVRRequestPresentStart: Observable<Engine>;
  73210. /**
  73211. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  73212. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  73213. */
  73214. isInVRExclusivePointerMode: boolean;
  73215. /**
  73216. * Gets a boolean indicating if a webVR device was detected
  73217. * @returns true if a webVR device was detected
  73218. */
  73219. isVRDevicePresent(): boolean;
  73220. /**
  73221. * Gets the current webVR device
  73222. * @returns the current webVR device (or null)
  73223. */
  73224. getVRDevice(): any;
  73225. /**
  73226. * Initializes a webVR display and starts listening to display change events
  73227. * The onVRDisplayChangedObservable will be notified upon these changes
  73228. * @returns A promise containing a VRDisplay and if vr is supported
  73229. */
  73230. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  73231. /** @hidden */
  73232. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  73233. /**
  73234. * Call this function to switch to webVR mode
  73235. * Will do nothing if webVR is not supported or if there is no webVR device
  73236. * @see http://doc.babylonjs.com/how_to/webvr_camera
  73237. */
  73238. enableVR(): void;
  73239. /** @hidden */
  73240. _onVRFullScreenTriggered(): void;
  73241. }
  73242. }
  73243. declare module BABYLON {
  73244. /**
  73245. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  73246. * IMPORTANT!! The data is right-hand data.
  73247. * @export
  73248. * @interface DevicePose
  73249. */
  73250. export interface DevicePose {
  73251. /**
  73252. * The position of the device, values in array are [x,y,z].
  73253. */
  73254. readonly position: Nullable<Float32Array>;
  73255. /**
  73256. * The linearVelocity of the device, values in array are [x,y,z].
  73257. */
  73258. readonly linearVelocity: Nullable<Float32Array>;
  73259. /**
  73260. * The linearAcceleration of the device, values in array are [x,y,z].
  73261. */
  73262. readonly linearAcceleration: Nullable<Float32Array>;
  73263. /**
  73264. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  73265. */
  73266. readonly orientation: Nullable<Float32Array>;
  73267. /**
  73268. * The angularVelocity of the device, values in array are [x,y,z].
  73269. */
  73270. readonly angularVelocity: Nullable<Float32Array>;
  73271. /**
  73272. * The angularAcceleration of the device, values in array are [x,y,z].
  73273. */
  73274. readonly angularAcceleration: Nullable<Float32Array>;
  73275. }
  73276. /**
  73277. * Interface representing a pose controlled object in Babylon.
  73278. * A pose controlled object has both regular pose values as well as pose values
  73279. * from an external device such as a VR head mounted display
  73280. */
  73281. export interface PoseControlled {
  73282. /**
  73283. * The position of the object in babylon space.
  73284. */
  73285. position: Vector3;
  73286. /**
  73287. * The rotation quaternion of the object in babylon space.
  73288. */
  73289. rotationQuaternion: Quaternion;
  73290. /**
  73291. * The position of the device in babylon space.
  73292. */
  73293. devicePosition?: Vector3;
  73294. /**
  73295. * The rotation quaternion of the device in babylon space.
  73296. */
  73297. deviceRotationQuaternion: Quaternion;
  73298. /**
  73299. * The raw pose coming from the device.
  73300. */
  73301. rawPose: Nullable<DevicePose>;
  73302. /**
  73303. * The scale of the device to be used when translating from device space to babylon space.
  73304. */
  73305. deviceScaleFactor: number;
  73306. /**
  73307. * Updates the poseControlled values based on the input device pose.
  73308. * @param poseData the pose data to update the object with
  73309. */
  73310. updateFromDevice(poseData: DevicePose): void;
  73311. }
  73312. /**
  73313. * Set of options to customize the webVRCamera
  73314. */
  73315. export interface WebVROptions {
  73316. /**
  73317. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  73318. */
  73319. trackPosition?: boolean;
  73320. /**
  73321. * Sets the scale of the vrDevice in babylon space. (default: 1)
  73322. */
  73323. positionScale?: number;
  73324. /**
  73325. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  73326. */
  73327. displayName?: string;
  73328. /**
  73329. * Should the native controller meshes be initialized. (default: true)
  73330. */
  73331. controllerMeshes?: boolean;
  73332. /**
  73333. * Creating a default HemiLight only on controllers. (default: true)
  73334. */
  73335. defaultLightingOnControllers?: boolean;
  73336. /**
  73337. * If you don't want to use the default VR button of the helper. (default: false)
  73338. */
  73339. useCustomVRButton?: boolean;
  73340. /**
  73341. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  73342. */
  73343. customVRButton?: HTMLButtonElement;
  73344. /**
  73345. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  73346. */
  73347. rayLength?: number;
  73348. /**
  73349. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  73350. */
  73351. defaultHeight?: number;
  73352. /**
  73353. * If multiview should be used if availible (default: false)
  73354. */
  73355. useMultiview?: boolean;
  73356. }
  73357. /**
  73358. * This represents a WebVR camera.
  73359. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  73360. * @example http://doc.babylonjs.com/how_to/webvr_camera
  73361. */
  73362. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  73363. private webVROptions;
  73364. /**
  73365. * @hidden
  73366. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  73367. */
  73368. _vrDevice: any;
  73369. /**
  73370. * The rawPose of the vrDevice.
  73371. */
  73372. rawPose: Nullable<DevicePose>;
  73373. private _onVREnabled;
  73374. private _specsVersion;
  73375. private _attached;
  73376. private _frameData;
  73377. protected _descendants: Array<Node>;
  73378. private _deviceRoomPosition;
  73379. /** @hidden */
  73380. _deviceRoomRotationQuaternion: Quaternion;
  73381. private _standingMatrix;
  73382. /**
  73383. * Represents device position in babylon space.
  73384. */
  73385. devicePosition: Vector3;
  73386. /**
  73387. * Represents device rotation in babylon space.
  73388. */
  73389. deviceRotationQuaternion: Quaternion;
  73390. /**
  73391. * The scale of the device to be used when translating from device space to babylon space.
  73392. */
  73393. deviceScaleFactor: number;
  73394. private _deviceToWorld;
  73395. private _worldToDevice;
  73396. /**
  73397. * References to the webVR controllers for the vrDevice.
  73398. */
  73399. controllers: Array<WebVRController>;
  73400. /**
  73401. * Emits an event when a controller is attached.
  73402. */
  73403. onControllersAttachedObservable: Observable<WebVRController[]>;
  73404. /**
  73405. * Emits an event when a controller's mesh has been loaded;
  73406. */
  73407. onControllerMeshLoadedObservable: Observable<WebVRController>;
  73408. /**
  73409. * Emits an event when the HMD's pose has been updated.
  73410. */
  73411. onPoseUpdatedFromDeviceObservable: Observable<any>;
  73412. private _poseSet;
  73413. /**
  73414. * If the rig cameras be used as parent instead of this camera.
  73415. */
  73416. rigParenting: boolean;
  73417. private _lightOnControllers;
  73418. private _defaultHeight?;
  73419. /**
  73420. * Instantiates a WebVRFreeCamera.
  73421. * @param name The name of the WebVRFreeCamera
  73422. * @param position The starting anchor position for the camera
  73423. * @param scene The scene the camera belongs to
  73424. * @param webVROptions a set of customizable options for the webVRCamera
  73425. */
  73426. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  73427. /**
  73428. * Gets the device distance from the ground in meters.
  73429. * @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.
  73430. */
  73431. deviceDistanceToRoomGround(): number;
  73432. /**
  73433. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  73434. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  73435. */
  73436. useStandingMatrix(callback?: (bool: boolean) => void): void;
  73437. /**
  73438. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  73439. * @returns A promise with a boolean set to if the standing matrix is supported.
  73440. */
  73441. useStandingMatrixAsync(): Promise<boolean>;
  73442. /**
  73443. * Disposes the camera
  73444. */
  73445. dispose(): void;
  73446. /**
  73447. * Gets a vrController by name.
  73448. * @param name The name of the controller to retreive
  73449. * @returns the controller matching the name specified or null if not found
  73450. */
  73451. getControllerByName(name: string): Nullable<WebVRController>;
  73452. private _leftController;
  73453. /**
  73454. * The controller corrisponding to the users left hand.
  73455. */
  73456. readonly leftController: Nullable<WebVRController>;
  73457. private _rightController;
  73458. /**
  73459. * The controller corrisponding to the users right hand.
  73460. */
  73461. readonly rightController: Nullable<WebVRController>;
  73462. /**
  73463. * Casts a ray forward from the vrCamera's gaze.
  73464. * @param length Length of the ray (default: 100)
  73465. * @returns the ray corrisponding to the gaze
  73466. */
  73467. getForwardRay(length?: number): Ray;
  73468. /**
  73469. * @hidden
  73470. * Updates the camera based on device's frame data
  73471. */
  73472. _checkInputs(): void;
  73473. /**
  73474. * Updates the poseControlled values based on the input device pose.
  73475. * @param poseData Pose coming from the device
  73476. */
  73477. updateFromDevice(poseData: DevicePose): void;
  73478. private _htmlElementAttached;
  73479. private _detachIfAttached;
  73480. /**
  73481. * WebVR's attach control will start broadcasting frames to the device.
  73482. * Note that in certain browsers (chrome for example) this function must be called
  73483. * within a user-interaction callback. Example:
  73484. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  73485. *
  73486. * @param element html element to attach the vrDevice to
  73487. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  73488. */
  73489. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  73490. /**
  73491. * Detaches the camera from the html element and disables VR
  73492. *
  73493. * @param element html element to detach from
  73494. */
  73495. detachControl(element: HTMLElement): void;
  73496. /**
  73497. * @returns the name of this class
  73498. */
  73499. getClassName(): string;
  73500. /**
  73501. * Calls resetPose on the vrDisplay
  73502. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  73503. */
  73504. resetToCurrentRotation(): void;
  73505. /**
  73506. * @hidden
  73507. * Updates the rig cameras (left and right eye)
  73508. */
  73509. _updateRigCameras(): void;
  73510. private _workingVector;
  73511. private _oneVector;
  73512. private _workingMatrix;
  73513. private updateCacheCalled;
  73514. private _correctPositionIfNotTrackPosition;
  73515. /**
  73516. * @hidden
  73517. * Updates the cached values of the camera
  73518. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  73519. */
  73520. _updateCache(ignoreParentClass?: boolean): void;
  73521. /**
  73522. * @hidden
  73523. * Get current device position in babylon world
  73524. */
  73525. _computeDevicePosition(): void;
  73526. /**
  73527. * Updates the current device position and rotation in the babylon world
  73528. */
  73529. update(): void;
  73530. /**
  73531. * @hidden
  73532. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  73533. * @returns an identity matrix
  73534. */
  73535. _getViewMatrix(): Matrix;
  73536. private _tmpMatrix;
  73537. /**
  73538. * This function is called by the two RIG cameras.
  73539. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  73540. * @hidden
  73541. */
  73542. _getWebVRViewMatrix(): Matrix;
  73543. /** @hidden */
  73544. _getWebVRProjectionMatrix(): Matrix;
  73545. private _onGamepadConnectedObserver;
  73546. private _onGamepadDisconnectedObserver;
  73547. private _updateCacheWhenTrackingDisabledObserver;
  73548. /**
  73549. * Initializes the controllers and their meshes
  73550. */
  73551. initControllers(): void;
  73552. }
  73553. }
  73554. declare module BABYLON {
  73555. /**
  73556. * Size options for a post process
  73557. */
  73558. export type PostProcessOptions = {
  73559. width: number;
  73560. height: number;
  73561. };
  73562. /**
  73563. * PostProcess can be used to apply a shader to a texture after it has been rendered
  73564. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  73565. */
  73566. export class PostProcess {
  73567. /** Name of the PostProcess. */
  73568. name: string;
  73569. /**
  73570. * Gets or sets the unique id of the post process
  73571. */
  73572. uniqueId: number;
  73573. /**
  73574. * Width of the texture to apply the post process on
  73575. */
  73576. width: number;
  73577. /**
  73578. * Height of the texture to apply the post process on
  73579. */
  73580. height: number;
  73581. /**
  73582. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  73583. * @hidden
  73584. */
  73585. _outputTexture: Nullable<InternalTexture>;
  73586. /**
  73587. * Sampling mode used by the shader
  73588. * See https://doc.babylonjs.com/classes/3.1/texture
  73589. */
  73590. renderTargetSamplingMode: number;
  73591. /**
  73592. * Clear color to use when screen clearing
  73593. */
  73594. clearColor: Color4;
  73595. /**
  73596. * If the buffer needs to be cleared before applying the post process. (default: true)
  73597. * Should be set to false if shader will overwrite all previous pixels.
  73598. */
  73599. autoClear: boolean;
  73600. /**
  73601. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  73602. */
  73603. alphaMode: number;
  73604. /**
  73605. * Sets the setAlphaBlendConstants of the babylon engine
  73606. */
  73607. alphaConstants: Color4;
  73608. /**
  73609. * Animations to be used for the post processing
  73610. */
  73611. animations: Animation[];
  73612. /**
  73613. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  73614. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  73615. */
  73616. enablePixelPerfectMode: boolean;
  73617. /**
  73618. * Force the postprocess to be applied without taking in account viewport
  73619. */
  73620. forceFullscreenViewport: boolean;
  73621. /**
  73622. * List of inspectable custom properties (used by the Inspector)
  73623. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  73624. */
  73625. inspectableCustomProperties: IInspectable[];
  73626. /**
  73627. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  73628. *
  73629. * | Value | Type | Description |
  73630. * | ----- | ----------------------------------- | ----------- |
  73631. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  73632. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  73633. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  73634. *
  73635. */
  73636. scaleMode: number;
  73637. /**
  73638. * Force textures to be a power of two (default: false)
  73639. */
  73640. alwaysForcePOT: boolean;
  73641. private _samples;
  73642. /**
  73643. * Number of sample textures (default: 1)
  73644. */
  73645. samples: number;
  73646. /**
  73647. * Modify the scale of the post process to be the same as the viewport (default: false)
  73648. */
  73649. adaptScaleToCurrentViewport: boolean;
  73650. private _camera;
  73651. private _scene;
  73652. private _engine;
  73653. private _options;
  73654. private _reusable;
  73655. private _textureType;
  73656. /**
  73657. * Smart array of input and output textures for the post process.
  73658. * @hidden
  73659. */
  73660. _textures: SmartArray<InternalTexture>;
  73661. /**
  73662. * The index in _textures that corresponds to the output texture.
  73663. * @hidden
  73664. */
  73665. _currentRenderTextureInd: number;
  73666. private _effect;
  73667. private _samplers;
  73668. private _fragmentUrl;
  73669. private _vertexUrl;
  73670. private _parameters;
  73671. private _scaleRatio;
  73672. protected _indexParameters: any;
  73673. private _shareOutputWithPostProcess;
  73674. private _texelSize;
  73675. private _forcedOutputTexture;
  73676. /**
  73677. * Returns the fragment url or shader name used in the post process.
  73678. * @returns the fragment url or name in the shader store.
  73679. */
  73680. getEffectName(): string;
  73681. /**
  73682. * An event triggered when the postprocess is activated.
  73683. */
  73684. onActivateObservable: Observable<Camera>;
  73685. private _onActivateObserver;
  73686. /**
  73687. * A function that is added to the onActivateObservable
  73688. */
  73689. onActivate: Nullable<(camera: Camera) => void>;
  73690. /**
  73691. * An event triggered when the postprocess changes its size.
  73692. */
  73693. onSizeChangedObservable: Observable<PostProcess>;
  73694. private _onSizeChangedObserver;
  73695. /**
  73696. * A function that is added to the onSizeChangedObservable
  73697. */
  73698. onSizeChanged: (postProcess: PostProcess) => void;
  73699. /**
  73700. * An event triggered when the postprocess applies its effect.
  73701. */
  73702. onApplyObservable: Observable<Effect>;
  73703. private _onApplyObserver;
  73704. /**
  73705. * A function that is added to the onApplyObservable
  73706. */
  73707. onApply: (effect: Effect) => void;
  73708. /**
  73709. * An event triggered before rendering the postprocess
  73710. */
  73711. onBeforeRenderObservable: Observable<Effect>;
  73712. private _onBeforeRenderObserver;
  73713. /**
  73714. * A function that is added to the onBeforeRenderObservable
  73715. */
  73716. onBeforeRender: (effect: Effect) => void;
  73717. /**
  73718. * An event triggered after rendering the postprocess
  73719. */
  73720. onAfterRenderObservable: Observable<Effect>;
  73721. private _onAfterRenderObserver;
  73722. /**
  73723. * A function that is added to the onAfterRenderObservable
  73724. */
  73725. onAfterRender: (efect: Effect) => void;
  73726. /**
  73727. * 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
  73728. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  73729. */
  73730. inputTexture: InternalTexture;
  73731. /**
  73732. * Gets the camera which post process is applied to.
  73733. * @returns The camera the post process is applied to.
  73734. */
  73735. getCamera(): Camera;
  73736. /**
  73737. * Gets the texel size of the postprocess.
  73738. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  73739. */
  73740. readonly texelSize: Vector2;
  73741. /**
  73742. * Creates a new instance PostProcess
  73743. * @param name The name of the PostProcess.
  73744. * @param fragmentUrl The url of the fragment shader to be used.
  73745. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  73746. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  73747. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  73748. * @param camera The camera to apply the render pass to.
  73749. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73750. * @param engine The engine which the post process will be applied. (default: current engine)
  73751. * @param reusable If the post process can be reused on the same frame. (default: false)
  73752. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  73753. * @param textureType Type of textures used when performing the post process. (default: 0)
  73754. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  73755. * @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
  73756. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  73757. */
  73758. constructor(
  73759. /** Name of the PostProcess. */
  73760. 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);
  73761. /**
  73762. * Gets a string idenfifying the name of the class
  73763. * @returns "PostProcess" string
  73764. */
  73765. getClassName(): string;
  73766. /**
  73767. * Gets the engine which this post process belongs to.
  73768. * @returns The engine the post process was enabled with.
  73769. */
  73770. getEngine(): Engine;
  73771. /**
  73772. * The effect that is created when initializing the post process.
  73773. * @returns The created effect corrisponding the the postprocess.
  73774. */
  73775. getEffect(): Effect;
  73776. /**
  73777. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  73778. * @param postProcess The post process to share the output with.
  73779. * @returns This post process.
  73780. */
  73781. shareOutputWith(postProcess: PostProcess): PostProcess;
  73782. /**
  73783. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  73784. * This should be called if the post process that shares output with this post process is disabled/disposed.
  73785. */
  73786. useOwnOutput(): void;
  73787. /**
  73788. * Updates the effect with the current post process compile time values and recompiles the shader.
  73789. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  73790. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  73791. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  73792. * @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
  73793. * @param onCompiled Called when the shader has been compiled.
  73794. * @param onError Called if there is an error when compiling a shader.
  73795. */
  73796. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  73797. /**
  73798. * The post process is reusable if it can be used multiple times within one frame.
  73799. * @returns If the post process is reusable
  73800. */
  73801. isReusable(): boolean;
  73802. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  73803. markTextureDirty(): void;
  73804. /**
  73805. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  73806. * 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.
  73807. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  73808. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  73809. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  73810. * @returns The target texture that was bound to be written to.
  73811. */
  73812. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  73813. /**
  73814. * If the post process is supported.
  73815. */
  73816. readonly isSupported: boolean;
  73817. /**
  73818. * The aspect ratio of the output texture.
  73819. */
  73820. readonly aspectRatio: number;
  73821. /**
  73822. * Get a value indicating if the post-process is ready to be used
  73823. * @returns true if the post-process is ready (shader is compiled)
  73824. */
  73825. isReady(): boolean;
  73826. /**
  73827. * Binds all textures and uniforms to the shader, this will be run on every pass.
  73828. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  73829. */
  73830. apply(): Nullable<Effect>;
  73831. private _disposeTextures;
  73832. /**
  73833. * Disposes the post process.
  73834. * @param camera The camera to dispose the post process on.
  73835. */
  73836. dispose(camera?: Camera): void;
  73837. }
  73838. }
  73839. declare module BABYLON {
  73840. /**
  73841. * PostProcessManager is used to manage one or more post processes or post process pipelines
  73842. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  73843. */
  73844. export class PostProcessManager {
  73845. private _scene;
  73846. private _indexBuffer;
  73847. private _vertexBuffers;
  73848. /**
  73849. * Creates a new instance PostProcess
  73850. * @param scene The scene that the post process is associated with.
  73851. */
  73852. constructor(scene: Scene);
  73853. private _prepareBuffers;
  73854. private _buildIndexBuffer;
  73855. /**
  73856. * Rebuilds the vertex buffers of the manager.
  73857. * @hidden
  73858. */
  73859. _rebuild(): void;
  73860. /**
  73861. * Prepares a frame to be run through a post process.
  73862. * @param sourceTexture The input texture to the post procesess. (default: null)
  73863. * @param postProcesses An array of post processes to be run. (default: null)
  73864. * @returns True if the post processes were able to be run.
  73865. * @hidden
  73866. */
  73867. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  73868. /**
  73869. * Manually render a set of post processes to a texture.
  73870. * @param postProcesses An array of post processes to be run.
  73871. * @param targetTexture The target texture to render to.
  73872. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  73873. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  73874. * @param lodLevel defines which lod of the texture to render to
  73875. */
  73876. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  73877. /**
  73878. * Finalize the result of the output of the postprocesses.
  73879. * @param doNotPresent If true the result will not be displayed to the screen.
  73880. * @param targetTexture The target texture to render to.
  73881. * @param faceIndex The index of the face to bind the target texture to.
  73882. * @param postProcesses The array of post processes to render.
  73883. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  73884. * @hidden
  73885. */
  73886. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  73887. /**
  73888. * Disposes of the post process manager.
  73889. */
  73890. dispose(): void;
  73891. }
  73892. }
  73893. declare module BABYLON {
  73894. interface AbstractScene {
  73895. /**
  73896. * The list of layers (background and foreground) of the scene
  73897. */
  73898. layers: Array<Layer>;
  73899. }
  73900. /**
  73901. * Defines the layer scene component responsible to manage any layers
  73902. * in a given scene.
  73903. */
  73904. export class LayerSceneComponent implements ISceneComponent {
  73905. /**
  73906. * The component name helpfull to identify the component in the list of scene components.
  73907. */
  73908. readonly name: string;
  73909. /**
  73910. * The scene the component belongs to.
  73911. */
  73912. scene: Scene;
  73913. private _engine;
  73914. /**
  73915. * Creates a new instance of the component for the given scene
  73916. * @param scene Defines the scene to register the component in
  73917. */
  73918. constructor(scene: Scene);
  73919. /**
  73920. * Registers the component in a given scene
  73921. */
  73922. register(): void;
  73923. /**
  73924. * Rebuilds the elements related to this component in case of
  73925. * context lost for instance.
  73926. */
  73927. rebuild(): void;
  73928. /**
  73929. * Disposes the component and the associated ressources.
  73930. */
  73931. dispose(): void;
  73932. private _draw;
  73933. private _drawCameraPredicate;
  73934. private _drawCameraBackground;
  73935. private _drawCameraForeground;
  73936. private _drawRenderTargetPredicate;
  73937. private _drawRenderTargetBackground;
  73938. private _drawRenderTargetForeground;
  73939. }
  73940. }
  73941. declare module BABYLON {
  73942. /** @hidden */
  73943. export var layerPixelShader: {
  73944. name: string;
  73945. shader: string;
  73946. };
  73947. }
  73948. declare module BABYLON {
  73949. /** @hidden */
  73950. export var layerVertexShader: {
  73951. name: string;
  73952. shader: string;
  73953. };
  73954. }
  73955. declare module BABYLON {
  73956. /**
  73957. * This represents a full screen 2d layer.
  73958. * This can be useful to display a picture in the background of your scene for instance.
  73959. * @see https://www.babylonjs-playground.com/#08A2BS#1
  73960. */
  73961. export class Layer {
  73962. /**
  73963. * Define the name of the layer.
  73964. */
  73965. name: string;
  73966. /**
  73967. * Define the texture the layer should display.
  73968. */
  73969. texture: Nullable<Texture>;
  73970. /**
  73971. * Is the layer in background or foreground.
  73972. */
  73973. isBackground: boolean;
  73974. /**
  73975. * Define the color of the layer (instead of texture).
  73976. */
  73977. color: Color4;
  73978. /**
  73979. * Define the scale of the layer in order to zoom in out of the texture.
  73980. */
  73981. scale: Vector2;
  73982. /**
  73983. * Define an offset for the layer in order to shift the texture.
  73984. */
  73985. offset: Vector2;
  73986. /**
  73987. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  73988. */
  73989. alphaBlendingMode: number;
  73990. /**
  73991. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  73992. * Alpha test will not mix with the background color in case of transparency.
  73993. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  73994. */
  73995. alphaTest: boolean;
  73996. /**
  73997. * Define a mask to restrict the layer to only some of the scene cameras.
  73998. */
  73999. layerMask: number;
  74000. /**
  74001. * Define the list of render target the layer is visible into.
  74002. */
  74003. renderTargetTextures: RenderTargetTexture[];
  74004. /**
  74005. * Define if the layer is only used in renderTarget or if it also
  74006. * renders in the main frame buffer of the canvas.
  74007. */
  74008. renderOnlyInRenderTargetTextures: boolean;
  74009. private _scene;
  74010. private _vertexBuffers;
  74011. private _indexBuffer;
  74012. private _effect;
  74013. private _alphaTestEffect;
  74014. /**
  74015. * An event triggered when the layer is disposed.
  74016. */
  74017. onDisposeObservable: Observable<Layer>;
  74018. private _onDisposeObserver;
  74019. /**
  74020. * Back compatibility with callback before the onDisposeObservable existed.
  74021. * The set callback will be triggered when the layer has been disposed.
  74022. */
  74023. onDispose: () => void;
  74024. /**
  74025. * An event triggered before rendering the scene
  74026. */
  74027. onBeforeRenderObservable: Observable<Layer>;
  74028. private _onBeforeRenderObserver;
  74029. /**
  74030. * Back compatibility with callback before the onBeforeRenderObservable existed.
  74031. * The set callback will be triggered just before rendering the layer.
  74032. */
  74033. onBeforeRender: () => void;
  74034. /**
  74035. * An event triggered after rendering the scene
  74036. */
  74037. onAfterRenderObservable: Observable<Layer>;
  74038. private _onAfterRenderObserver;
  74039. /**
  74040. * Back compatibility with callback before the onAfterRenderObservable existed.
  74041. * The set callback will be triggered just after rendering the layer.
  74042. */
  74043. onAfterRender: () => void;
  74044. /**
  74045. * Instantiates a new layer.
  74046. * This represents a full screen 2d layer.
  74047. * This can be useful to display a picture in the background of your scene for instance.
  74048. * @see https://www.babylonjs-playground.com/#08A2BS#1
  74049. * @param name Define the name of the layer in the scene
  74050. * @param imgUrl Define the url of the texture to display in the layer
  74051. * @param scene Define the scene the layer belongs to
  74052. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  74053. * @param color Defines a color for the layer
  74054. */
  74055. constructor(
  74056. /**
  74057. * Define the name of the layer.
  74058. */
  74059. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  74060. private _createIndexBuffer;
  74061. /** @hidden */
  74062. _rebuild(): void;
  74063. /**
  74064. * Renders the layer in the scene.
  74065. */
  74066. render(): void;
  74067. /**
  74068. * Disposes and releases the associated ressources.
  74069. */
  74070. dispose(): void;
  74071. }
  74072. }
  74073. declare module BABYLON {
  74074. interface AbstractScene {
  74075. /**
  74076. * The list of procedural textures added to the scene
  74077. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  74078. */
  74079. proceduralTextures: Array<ProceduralTexture>;
  74080. }
  74081. /**
  74082. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  74083. * in a given scene.
  74084. */
  74085. export class ProceduralTextureSceneComponent implements ISceneComponent {
  74086. /**
  74087. * The component name helpfull to identify the component in the list of scene components.
  74088. */
  74089. readonly name: string;
  74090. /**
  74091. * The scene the component belongs to.
  74092. */
  74093. scene: Scene;
  74094. /**
  74095. * Creates a new instance of the component for the given scene
  74096. * @param scene Defines the scene to register the component in
  74097. */
  74098. constructor(scene: Scene);
  74099. /**
  74100. * Registers the component in a given scene
  74101. */
  74102. register(): void;
  74103. /**
  74104. * Rebuilds the elements related to this component in case of
  74105. * context lost for instance.
  74106. */
  74107. rebuild(): void;
  74108. /**
  74109. * Disposes the component and the associated ressources.
  74110. */
  74111. dispose(): void;
  74112. private _beforeClear;
  74113. }
  74114. }
  74115. declare module BABYLON {
  74116. interface Engine {
  74117. /**
  74118. * Creates a new render target cube texture
  74119. * @param size defines the size of the texture
  74120. * @param options defines the options used to create the texture
  74121. * @returns a new render target cube texture stored in an InternalTexture
  74122. */
  74123. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  74124. }
  74125. }
  74126. declare module BABYLON {
  74127. /** @hidden */
  74128. export var proceduralVertexShader: {
  74129. name: string;
  74130. shader: string;
  74131. };
  74132. }
  74133. declare module BABYLON {
  74134. /**
  74135. * 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.
  74136. * This is the base class of any Procedural texture and contains most of the shareable code.
  74137. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  74138. */
  74139. export class ProceduralTexture extends Texture {
  74140. isCube: boolean;
  74141. /**
  74142. * Define if the texture is enabled or not (disabled texture will not render)
  74143. */
  74144. isEnabled: boolean;
  74145. /**
  74146. * Define if the texture must be cleared before rendering (default is true)
  74147. */
  74148. autoClear: boolean;
  74149. /**
  74150. * Callback called when the texture is generated
  74151. */
  74152. onGenerated: () => void;
  74153. /**
  74154. * Event raised when the texture is generated
  74155. */
  74156. onGeneratedObservable: Observable<ProceduralTexture>;
  74157. /** @hidden */
  74158. _generateMipMaps: boolean;
  74159. /** @hidden **/
  74160. _effect: Effect;
  74161. /** @hidden */
  74162. _textures: {
  74163. [key: string]: Texture;
  74164. };
  74165. private _size;
  74166. private _currentRefreshId;
  74167. private _refreshRate;
  74168. private _vertexBuffers;
  74169. private _indexBuffer;
  74170. private _uniforms;
  74171. private _samplers;
  74172. private _fragment;
  74173. private _floats;
  74174. private _ints;
  74175. private _floatsArrays;
  74176. private _colors3;
  74177. private _colors4;
  74178. private _vectors2;
  74179. private _vectors3;
  74180. private _matrices;
  74181. private _fallbackTexture;
  74182. private _fallbackTextureUsed;
  74183. private _engine;
  74184. private _cachedDefines;
  74185. private _contentUpdateId;
  74186. private _contentData;
  74187. /**
  74188. * Instantiates a new procedural texture.
  74189. * 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.
  74190. * This is the base class of any Procedural texture and contains most of the shareable code.
  74191. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  74192. * @param name Define the name of the texture
  74193. * @param size Define the size of the texture to create
  74194. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  74195. * @param scene Define the scene the texture belongs to
  74196. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  74197. * @param generateMipMaps Define if the texture should creates mip maps or not
  74198. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  74199. */
  74200. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  74201. /**
  74202. * The effect that is created when initializing the post process.
  74203. * @returns The created effect corrisponding the the postprocess.
  74204. */
  74205. getEffect(): Effect;
  74206. /**
  74207. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  74208. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  74209. */
  74210. getContent(): Nullable<ArrayBufferView>;
  74211. private _createIndexBuffer;
  74212. /** @hidden */
  74213. _rebuild(): void;
  74214. /**
  74215. * Resets the texture in order to recreate its associated resources.
  74216. * This can be called in case of context loss
  74217. */
  74218. reset(): void;
  74219. protected _getDefines(): string;
  74220. /**
  74221. * Is the texture ready to be used ? (rendered at least once)
  74222. * @returns true if ready, otherwise, false.
  74223. */
  74224. isReady(): boolean;
  74225. /**
  74226. * Resets the refresh counter of the texture and start bak from scratch.
  74227. * Could be useful to regenerate the texture if it is setup to render only once.
  74228. */
  74229. resetRefreshCounter(): void;
  74230. /**
  74231. * Set the fragment shader to use in order to render the texture.
  74232. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  74233. */
  74234. setFragment(fragment: any): void;
  74235. /**
  74236. * Define the refresh rate of the texture or the rendering frequency.
  74237. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  74238. */
  74239. refreshRate: number;
  74240. /** @hidden */
  74241. _shouldRender(): boolean;
  74242. /**
  74243. * Get the size the texture is rendering at.
  74244. * @returns the size (texture is always squared)
  74245. */
  74246. getRenderSize(): number;
  74247. /**
  74248. * Resize the texture to new value.
  74249. * @param size Define the new size the texture should have
  74250. * @param generateMipMaps Define whether the new texture should create mip maps
  74251. */
  74252. resize(size: number, generateMipMaps: boolean): void;
  74253. private _checkUniform;
  74254. /**
  74255. * Set a texture in the shader program used to render.
  74256. * @param name Define the name of the uniform samplers as defined in the shader
  74257. * @param texture Define the texture to bind to this sampler
  74258. * @return the texture itself allowing "fluent" like uniform updates
  74259. */
  74260. setTexture(name: string, texture: Texture): ProceduralTexture;
  74261. /**
  74262. * Set a float in the shader.
  74263. * @param name Define the name of the uniform as defined in the shader
  74264. * @param value Define the value to give to the uniform
  74265. * @return the texture itself allowing "fluent" like uniform updates
  74266. */
  74267. setFloat(name: string, value: number): ProceduralTexture;
  74268. /**
  74269. * Set a int in the shader.
  74270. * @param name Define the name of the uniform as defined in the shader
  74271. * @param value Define the value to give to the uniform
  74272. * @return the texture itself allowing "fluent" like uniform updates
  74273. */
  74274. setInt(name: string, value: number): ProceduralTexture;
  74275. /**
  74276. * Set an array of floats in the shader.
  74277. * @param name Define the name of the uniform as defined in the shader
  74278. * @param value Define the value to give to the uniform
  74279. * @return the texture itself allowing "fluent" like uniform updates
  74280. */
  74281. setFloats(name: string, value: number[]): ProceduralTexture;
  74282. /**
  74283. * Set a vec3 in the shader from a Color3.
  74284. * @param name Define the name of the uniform as defined in the shader
  74285. * @param value Define the value to give to the uniform
  74286. * @return the texture itself allowing "fluent" like uniform updates
  74287. */
  74288. setColor3(name: string, value: Color3): ProceduralTexture;
  74289. /**
  74290. * Set a vec4 in the shader from a Color4.
  74291. * @param name Define the name of the uniform as defined in the shader
  74292. * @param value Define the value to give to the uniform
  74293. * @return the texture itself allowing "fluent" like uniform updates
  74294. */
  74295. setColor4(name: string, value: Color4): ProceduralTexture;
  74296. /**
  74297. * Set a vec2 in the shader from a Vector2.
  74298. * @param name Define the name of the uniform as defined in the shader
  74299. * @param value Define the value to give to the uniform
  74300. * @return the texture itself allowing "fluent" like uniform updates
  74301. */
  74302. setVector2(name: string, value: Vector2): ProceduralTexture;
  74303. /**
  74304. * Set a vec3 in the shader from a Vector3.
  74305. * @param name Define the name of the uniform as defined in the shader
  74306. * @param value Define the value to give to the uniform
  74307. * @return the texture itself allowing "fluent" like uniform updates
  74308. */
  74309. setVector3(name: string, value: Vector3): ProceduralTexture;
  74310. /**
  74311. * Set a mat4 in the shader from a MAtrix.
  74312. * @param name Define the name of the uniform as defined in the shader
  74313. * @param value Define the value to give to the uniform
  74314. * @return the texture itself allowing "fluent" like uniform updates
  74315. */
  74316. setMatrix(name: string, value: Matrix): ProceduralTexture;
  74317. /**
  74318. * Render the texture to its associated render target.
  74319. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  74320. */
  74321. render(useCameraPostProcess?: boolean): void;
  74322. /**
  74323. * Clone the texture.
  74324. * @returns the cloned texture
  74325. */
  74326. clone(): ProceduralTexture;
  74327. /**
  74328. * Dispose the texture and release its asoociated resources.
  74329. */
  74330. dispose(): void;
  74331. }
  74332. }
  74333. declare module BABYLON {
  74334. /**
  74335. * This represents the base class for particle system in Babylon.
  74336. * 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.
  74337. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  74338. * @example https://doc.babylonjs.com/babylon101/particles
  74339. */
  74340. export class BaseParticleSystem {
  74341. /**
  74342. * Source color is added to the destination color without alpha affecting the result
  74343. */
  74344. static BLENDMODE_ONEONE: number;
  74345. /**
  74346. * Blend current color and particle color using particle’s alpha
  74347. */
  74348. static BLENDMODE_STANDARD: number;
  74349. /**
  74350. * Add current color and particle color multiplied by particle’s alpha
  74351. */
  74352. static BLENDMODE_ADD: number;
  74353. /**
  74354. * Multiply current color with particle color
  74355. */
  74356. static BLENDMODE_MULTIPLY: number;
  74357. /**
  74358. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  74359. */
  74360. static BLENDMODE_MULTIPLYADD: number;
  74361. /**
  74362. * List of animations used by the particle system.
  74363. */
  74364. animations: Animation[];
  74365. /**
  74366. * The id of the Particle system.
  74367. */
  74368. id: string;
  74369. /**
  74370. * The friendly name of the Particle system.
  74371. */
  74372. name: string;
  74373. /**
  74374. * The rendering group used by the Particle system to chose when to render.
  74375. */
  74376. renderingGroupId: number;
  74377. /**
  74378. * The emitter represents the Mesh or position we are attaching the particle system to.
  74379. */
  74380. emitter: Nullable<AbstractMesh | Vector3>;
  74381. /**
  74382. * The maximum number of particles to emit per frame
  74383. */
  74384. emitRate: number;
  74385. /**
  74386. * If you want to launch only a few particles at once, that can be done, as well.
  74387. */
  74388. manualEmitCount: number;
  74389. /**
  74390. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  74391. */
  74392. updateSpeed: number;
  74393. /**
  74394. * The amount of time the particle system is running (depends of the overall update speed).
  74395. */
  74396. targetStopDuration: number;
  74397. /**
  74398. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  74399. */
  74400. disposeOnStop: boolean;
  74401. /**
  74402. * Minimum power of emitting particles.
  74403. */
  74404. minEmitPower: number;
  74405. /**
  74406. * Maximum power of emitting particles.
  74407. */
  74408. maxEmitPower: number;
  74409. /**
  74410. * Minimum life time of emitting particles.
  74411. */
  74412. minLifeTime: number;
  74413. /**
  74414. * Maximum life time of emitting particles.
  74415. */
  74416. maxLifeTime: number;
  74417. /**
  74418. * Minimum Size of emitting particles.
  74419. */
  74420. minSize: number;
  74421. /**
  74422. * Maximum Size of emitting particles.
  74423. */
  74424. maxSize: number;
  74425. /**
  74426. * Minimum scale of emitting particles on X axis.
  74427. */
  74428. minScaleX: number;
  74429. /**
  74430. * Maximum scale of emitting particles on X axis.
  74431. */
  74432. maxScaleX: number;
  74433. /**
  74434. * Minimum scale of emitting particles on Y axis.
  74435. */
  74436. minScaleY: number;
  74437. /**
  74438. * Maximum scale of emitting particles on Y axis.
  74439. */
  74440. maxScaleY: number;
  74441. /**
  74442. * Gets or sets the minimal initial rotation in radians.
  74443. */
  74444. minInitialRotation: number;
  74445. /**
  74446. * Gets or sets the maximal initial rotation in radians.
  74447. */
  74448. maxInitialRotation: number;
  74449. /**
  74450. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  74451. */
  74452. minAngularSpeed: number;
  74453. /**
  74454. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  74455. */
  74456. maxAngularSpeed: number;
  74457. /**
  74458. * The texture used to render each particle. (this can be a spritesheet)
  74459. */
  74460. particleTexture: Nullable<Texture>;
  74461. /**
  74462. * The layer mask we are rendering the particles through.
  74463. */
  74464. layerMask: number;
  74465. /**
  74466. * This can help using your own shader to render the particle system.
  74467. * The according effect will be created
  74468. */
  74469. customShader: any;
  74470. /**
  74471. * By default particle system starts as soon as they are created. This prevents the
  74472. * automatic start to happen and let you decide when to start emitting particles.
  74473. */
  74474. preventAutoStart: boolean;
  74475. private _noiseTexture;
  74476. /**
  74477. * Gets or sets a texture used to add random noise to particle positions
  74478. */
  74479. noiseTexture: Nullable<ProceduralTexture>;
  74480. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  74481. noiseStrength: Vector3;
  74482. /**
  74483. * Callback triggered when the particle animation is ending.
  74484. */
  74485. onAnimationEnd: Nullable<() => void>;
  74486. /**
  74487. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  74488. */
  74489. blendMode: number;
  74490. /**
  74491. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  74492. * to override the particles.
  74493. */
  74494. forceDepthWrite: boolean;
  74495. /** 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 */
  74496. preWarmCycles: number;
  74497. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  74498. preWarmStepOffset: number;
  74499. /**
  74500. * 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)
  74501. */
  74502. spriteCellChangeSpeed: number;
  74503. /**
  74504. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  74505. */
  74506. startSpriteCellID: number;
  74507. /**
  74508. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  74509. */
  74510. endSpriteCellID: number;
  74511. /**
  74512. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  74513. */
  74514. spriteCellWidth: number;
  74515. /**
  74516. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  74517. */
  74518. spriteCellHeight: number;
  74519. /**
  74520. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  74521. */
  74522. spriteRandomStartCell: boolean;
  74523. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  74524. translationPivot: Vector2;
  74525. /** @hidden */
  74526. protected _isAnimationSheetEnabled: boolean;
  74527. /**
  74528. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  74529. */
  74530. beginAnimationOnStart: boolean;
  74531. /**
  74532. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  74533. */
  74534. beginAnimationFrom: number;
  74535. /**
  74536. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  74537. */
  74538. beginAnimationTo: number;
  74539. /**
  74540. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  74541. */
  74542. beginAnimationLoop: boolean;
  74543. /**
  74544. * Gets or sets a world offset applied to all particles
  74545. */
  74546. worldOffset: Vector3;
  74547. /**
  74548. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  74549. */
  74550. isAnimationSheetEnabled: boolean;
  74551. /**
  74552. * Get hosting scene
  74553. * @returns the scene
  74554. */
  74555. getScene(): Scene;
  74556. /**
  74557. * You can use gravity if you want to give an orientation to your particles.
  74558. */
  74559. gravity: Vector3;
  74560. protected _colorGradients: Nullable<Array<ColorGradient>>;
  74561. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  74562. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  74563. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  74564. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  74565. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  74566. protected _dragGradients: Nullable<Array<FactorGradient>>;
  74567. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  74568. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  74569. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  74570. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  74571. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  74572. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  74573. /**
  74574. * Defines the delay in milliseconds before starting the system (0 by default)
  74575. */
  74576. startDelay: number;
  74577. /**
  74578. * Gets the current list of drag gradients.
  74579. * You must use addDragGradient and removeDragGradient to udpate this list
  74580. * @returns the list of drag gradients
  74581. */
  74582. getDragGradients(): Nullable<Array<FactorGradient>>;
  74583. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  74584. limitVelocityDamping: number;
  74585. /**
  74586. * Gets the current list of limit velocity gradients.
  74587. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  74588. * @returns the list of limit velocity gradients
  74589. */
  74590. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  74591. /**
  74592. * Gets the current list of color gradients.
  74593. * You must use addColorGradient and removeColorGradient to udpate this list
  74594. * @returns the list of color gradients
  74595. */
  74596. getColorGradients(): Nullable<Array<ColorGradient>>;
  74597. /**
  74598. * Gets the current list of size gradients.
  74599. * You must use addSizeGradient and removeSizeGradient to udpate this list
  74600. * @returns the list of size gradients
  74601. */
  74602. getSizeGradients(): Nullable<Array<FactorGradient>>;
  74603. /**
  74604. * Gets the current list of color remap gradients.
  74605. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  74606. * @returns the list of color remap gradients
  74607. */
  74608. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  74609. /**
  74610. * Gets the current list of alpha remap gradients.
  74611. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  74612. * @returns the list of alpha remap gradients
  74613. */
  74614. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  74615. /**
  74616. * Gets the current list of life time gradients.
  74617. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  74618. * @returns the list of life time gradients
  74619. */
  74620. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  74621. /**
  74622. * Gets the current list of angular speed gradients.
  74623. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  74624. * @returns the list of angular speed gradients
  74625. */
  74626. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  74627. /**
  74628. * Gets the current list of velocity gradients.
  74629. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  74630. * @returns the list of velocity gradients
  74631. */
  74632. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  74633. /**
  74634. * Gets the current list of start size gradients.
  74635. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  74636. * @returns the list of start size gradients
  74637. */
  74638. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  74639. /**
  74640. * Gets the current list of emit rate gradients.
  74641. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  74642. * @returns the list of emit rate gradients
  74643. */
  74644. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  74645. /**
  74646. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  74647. * This only works when particleEmitterTyps is a BoxParticleEmitter
  74648. */
  74649. direction1: Vector3;
  74650. /**
  74651. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  74652. * This only works when particleEmitterTyps is a BoxParticleEmitter
  74653. */
  74654. direction2: Vector3;
  74655. /**
  74656. * 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.
  74657. * This only works when particleEmitterTyps is a BoxParticleEmitter
  74658. */
  74659. minEmitBox: Vector3;
  74660. /**
  74661. * 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.
  74662. * This only works when particleEmitterTyps is a BoxParticleEmitter
  74663. */
  74664. maxEmitBox: Vector3;
  74665. /**
  74666. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  74667. */
  74668. color1: Color4;
  74669. /**
  74670. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  74671. */
  74672. color2: Color4;
  74673. /**
  74674. * Color the particle will have at the end of its lifetime
  74675. */
  74676. colorDead: Color4;
  74677. /**
  74678. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  74679. */
  74680. textureMask: Color4;
  74681. /**
  74682. * The particle emitter type defines the emitter used by the particle system.
  74683. * It can be for example box, sphere, or cone...
  74684. */
  74685. particleEmitterType: IParticleEmitterType;
  74686. /** @hidden */
  74687. _isSubEmitter: boolean;
  74688. /**
  74689. * Gets or sets the billboard mode to use when isBillboardBased = true.
  74690. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  74691. */
  74692. billboardMode: number;
  74693. protected _isBillboardBased: boolean;
  74694. /**
  74695. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  74696. */
  74697. isBillboardBased: boolean;
  74698. /**
  74699. * The scene the particle system belongs to.
  74700. */
  74701. protected _scene: Scene;
  74702. /**
  74703. * Local cache of defines for image processing.
  74704. */
  74705. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  74706. /**
  74707. * Default configuration related to image processing available in the standard Material.
  74708. */
  74709. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  74710. /**
  74711. * Gets the image processing configuration used either in this material.
  74712. */
  74713. /**
  74714. * Sets the Default image processing configuration used either in the this material.
  74715. *
  74716. * If sets to null, the scene one is in use.
  74717. */
  74718. imageProcessingConfiguration: ImageProcessingConfiguration;
  74719. /**
  74720. * Attaches a new image processing configuration to the Standard Material.
  74721. * @param configuration
  74722. */
  74723. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  74724. /** @hidden */
  74725. protected _reset(): void;
  74726. /** @hidden */
  74727. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  74728. /**
  74729. * Instantiates a particle system.
  74730. * 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.
  74731. * @param name The name of the particle system
  74732. */
  74733. constructor(name: string);
  74734. /**
  74735. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  74736. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  74737. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  74738. * @returns the emitter
  74739. */
  74740. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  74741. /**
  74742. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  74743. * @param radius The radius of the hemisphere to emit from
  74744. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  74745. * @returns the emitter
  74746. */
  74747. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  74748. /**
  74749. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  74750. * @param radius The radius of the sphere to emit from
  74751. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  74752. * @returns the emitter
  74753. */
  74754. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  74755. /**
  74756. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  74757. * @param radius The radius of the sphere to emit from
  74758. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  74759. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  74760. * @returns the emitter
  74761. */
  74762. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  74763. /**
  74764. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  74765. * @param radius The radius of the emission cylinder
  74766. * @param height The height of the emission cylinder
  74767. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  74768. * @param directionRandomizer How much to randomize the particle direction [0-1]
  74769. * @returns the emitter
  74770. */
  74771. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  74772. /**
  74773. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  74774. * @param radius The radius of the cylinder to emit from
  74775. * @param height The height of the emission cylinder
  74776. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  74777. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  74778. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  74779. * @returns the emitter
  74780. */
  74781. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  74782. /**
  74783. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  74784. * @param radius The radius of the cone to emit from
  74785. * @param angle The base angle of the cone
  74786. * @returns the emitter
  74787. */
  74788. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  74789. /**
  74790. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  74791. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  74792. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  74793. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  74794. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  74795. * @returns the emitter
  74796. */
  74797. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  74798. }
  74799. }
  74800. declare module BABYLON {
  74801. /**
  74802. * Type of sub emitter
  74803. */
  74804. export enum SubEmitterType {
  74805. /**
  74806. * Attached to the particle over it's lifetime
  74807. */
  74808. ATTACHED = 0,
  74809. /**
  74810. * Created when the particle dies
  74811. */
  74812. END = 1
  74813. }
  74814. /**
  74815. * Sub emitter class used to emit particles from an existing particle
  74816. */
  74817. export class SubEmitter {
  74818. /**
  74819. * the particle system to be used by the sub emitter
  74820. */
  74821. particleSystem: ParticleSystem;
  74822. /**
  74823. * Type of the submitter (Default: END)
  74824. */
  74825. type: SubEmitterType;
  74826. /**
  74827. * 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)
  74828. * Note: This only is supported when using an emitter of type Mesh
  74829. */
  74830. inheritDirection: boolean;
  74831. /**
  74832. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  74833. */
  74834. inheritedVelocityAmount: number;
  74835. /**
  74836. * Creates a sub emitter
  74837. * @param particleSystem the particle system to be used by the sub emitter
  74838. */
  74839. constructor(
  74840. /**
  74841. * the particle system to be used by the sub emitter
  74842. */
  74843. particleSystem: ParticleSystem);
  74844. /**
  74845. * Clones the sub emitter
  74846. * @returns the cloned sub emitter
  74847. */
  74848. clone(): SubEmitter;
  74849. /**
  74850. * Serialize current object to a JSON object
  74851. * @returns the serialized object
  74852. */
  74853. serialize(): any;
  74854. /** @hidden */
  74855. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  74856. /**
  74857. * Creates a new SubEmitter from a serialized JSON version
  74858. * @param serializationObject defines the JSON object to read from
  74859. * @param scene defines the hosting scene
  74860. * @param rootUrl defines the rootUrl for data loading
  74861. * @returns a new SubEmitter
  74862. */
  74863. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  74864. /** Release associated resources */
  74865. dispose(): void;
  74866. }
  74867. }
  74868. declare module BABYLON {
  74869. /** @hidden */
  74870. export var clipPlaneFragmentDeclaration: {
  74871. name: string;
  74872. shader: string;
  74873. };
  74874. }
  74875. declare module BABYLON {
  74876. /** @hidden */
  74877. export var imageProcessingDeclaration: {
  74878. name: string;
  74879. shader: string;
  74880. };
  74881. }
  74882. declare module BABYLON {
  74883. /** @hidden */
  74884. export var imageProcessingFunctions: {
  74885. name: string;
  74886. shader: string;
  74887. };
  74888. }
  74889. declare module BABYLON {
  74890. /** @hidden */
  74891. export var clipPlaneFragment: {
  74892. name: string;
  74893. shader: string;
  74894. };
  74895. }
  74896. declare module BABYLON {
  74897. /** @hidden */
  74898. export var particlesPixelShader: {
  74899. name: string;
  74900. shader: string;
  74901. };
  74902. }
  74903. declare module BABYLON {
  74904. /** @hidden */
  74905. export var clipPlaneVertexDeclaration: {
  74906. name: string;
  74907. shader: string;
  74908. };
  74909. }
  74910. declare module BABYLON {
  74911. /** @hidden */
  74912. export var clipPlaneVertex: {
  74913. name: string;
  74914. shader: string;
  74915. };
  74916. }
  74917. declare module BABYLON {
  74918. /** @hidden */
  74919. export var particlesVertexShader: {
  74920. name: string;
  74921. shader: string;
  74922. };
  74923. }
  74924. declare module BABYLON {
  74925. /**
  74926. * This represents a particle system in Babylon.
  74927. * 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.
  74928. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  74929. * @example https://doc.babylonjs.com/babylon101/particles
  74930. */
  74931. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  74932. /**
  74933. * Billboard mode will only apply to Y axis
  74934. */
  74935. static readonly BILLBOARDMODE_Y: number;
  74936. /**
  74937. * Billboard mode will apply to all axes
  74938. */
  74939. static readonly BILLBOARDMODE_ALL: number;
  74940. /**
  74941. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  74942. */
  74943. static readonly BILLBOARDMODE_STRETCHED: number;
  74944. /**
  74945. * This function can be defined to provide custom update for active particles.
  74946. * This function will be called instead of regular update (age, position, color, etc.).
  74947. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  74948. */
  74949. updateFunction: (particles: Particle[]) => void;
  74950. private _emitterWorldMatrix;
  74951. /**
  74952. * This function can be defined to specify initial direction for every new particle.
  74953. * It by default use the emitterType defined function
  74954. */
  74955. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  74956. /**
  74957. * This function can be defined to specify initial position for every new particle.
  74958. * It by default use the emitterType defined function
  74959. */
  74960. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  74961. /**
  74962. * @hidden
  74963. */
  74964. _inheritedVelocityOffset: Vector3;
  74965. /**
  74966. * An event triggered when the system is disposed
  74967. */
  74968. onDisposeObservable: Observable<ParticleSystem>;
  74969. private _onDisposeObserver;
  74970. /**
  74971. * Sets a callback that will be triggered when the system is disposed
  74972. */
  74973. onDispose: () => void;
  74974. private _particles;
  74975. private _epsilon;
  74976. private _capacity;
  74977. private _stockParticles;
  74978. private _newPartsExcess;
  74979. private _vertexData;
  74980. private _vertexBuffer;
  74981. private _vertexBuffers;
  74982. private _spriteBuffer;
  74983. private _indexBuffer;
  74984. private _effect;
  74985. private _customEffect;
  74986. private _cachedDefines;
  74987. private _scaledColorStep;
  74988. private _colorDiff;
  74989. private _scaledDirection;
  74990. private _scaledGravity;
  74991. private _currentRenderId;
  74992. private _alive;
  74993. private _useInstancing;
  74994. private _started;
  74995. private _stopped;
  74996. private _actualFrame;
  74997. private _scaledUpdateSpeed;
  74998. private _vertexBufferSize;
  74999. /** @hidden */
  75000. _currentEmitRateGradient: Nullable<FactorGradient>;
  75001. /** @hidden */
  75002. _currentEmitRate1: number;
  75003. /** @hidden */
  75004. _currentEmitRate2: number;
  75005. /** @hidden */
  75006. _currentStartSizeGradient: Nullable<FactorGradient>;
  75007. /** @hidden */
  75008. _currentStartSize1: number;
  75009. /** @hidden */
  75010. _currentStartSize2: number;
  75011. private readonly _rawTextureWidth;
  75012. private _rampGradientsTexture;
  75013. private _useRampGradients;
  75014. /** Gets or sets a boolean indicating that ramp gradients must be used
  75015. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  75016. */
  75017. useRampGradients: boolean;
  75018. /**
  75019. * 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.
  75020. * 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: [])
  75021. */
  75022. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  75023. private _subEmitters;
  75024. /**
  75025. * @hidden
  75026. * If the particle systems emitter should be disposed when the particle system is disposed
  75027. */
  75028. _disposeEmitterOnDispose: boolean;
  75029. /**
  75030. * The current active Sub-systems, this property is used by the root particle system only.
  75031. */
  75032. activeSubSystems: Array<ParticleSystem>;
  75033. private _rootParticleSystem;
  75034. /**
  75035. * Gets the current list of active particles
  75036. */
  75037. readonly particles: Particle[];
  75038. /**
  75039. * Returns the string "ParticleSystem"
  75040. * @returns a string containing the class name
  75041. */
  75042. getClassName(): string;
  75043. /**
  75044. * Instantiates a particle system.
  75045. * 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.
  75046. * @param name The name of the particle system
  75047. * @param capacity The max number of particles alive at the same time
  75048. * @param scene The scene the particle system belongs to
  75049. * @param customEffect a custom effect used to change the way particles are rendered by default
  75050. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  75051. * @param epsilon Offset used to render the particles
  75052. */
  75053. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  75054. private _addFactorGradient;
  75055. private _removeFactorGradient;
  75056. /**
  75057. * Adds a new life time gradient
  75058. * @param gradient defines the gradient to use (between 0 and 1)
  75059. * @param factor defines the life time factor to affect to the specified gradient
  75060. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75061. * @returns the current particle system
  75062. */
  75063. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75064. /**
  75065. * Remove a specific life time gradient
  75066. * @param gradient defines the gradient to remove
  75067. * @returns the current particle system
  75068. */
  75069. removeLifeTimeGradient(gradient: number): IParticleSystem;
  75070. /**
  75071. * Adds a new size gradient
  75072. * @param gradient defines the gradient to use (between 0 and 1)
  75073. * @param factor defines the size factor to affect to the specified gradient
  75074. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75075. * @returns the current particle system
  75076. */
  75077. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75078. /**
  75079. * Remove a specific size gradient
  75080. * @param gradient defines the gradient to remove
  75081. * @returns the current particle system
  75082. */
  75083. removeSizeGradient(gradient: number): IParticleSystem;
  75084. /**
  75085. * Adds a new color remap gradient
  75086. * @param gradient defines the gradient to use (between 0 and 1)
  75087. * @param min defines the color remap minimal range
  75088. * @param max defines the color remap maximal range
  75089. * @returns the current particle system
  75090. */
  75091. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  75092. /**
  75093. * Remove a specific color remap gradient
  75094. * @param gradient defines the gradient to remove
  75095. * @returns the current particle system
  75096. */
  75097. removeColorRemapGradient(gradient: number): IParticleSystem;
  75098. /**
  75099. * Adds a new alpha remap gradient
  75100. * @param gradient defines the gradient to use (between 0 and 1)
  75101. * @param min defines the alpha remap minimal range
  75102. * @param max defines the alpha remap maximal range
  75103. * @returns the current particle system
  75104. */
  75105. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  75106. /**
  75107. * Remove a specific alpha remap gradient
  75108. * @param gradient defines the gradient to remove
  75109. * @returns the current particle system
  75110. */
  75111. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  75112. /**
  75113. * Adds a new angular speed gradient
  75114. * @param gradient defines the gradient to use (between 0 and 1)
  75115. * @param factor defines the angular speed to affect to the specified gradient
  75116. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75117. * @returns the current particle system
  75118. */
  75119. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75120. /**
  75121. * Remove a specific angular speed gradient
  75122. * @param gradient defines the gradient to remove
  75123. * @returns the current particle system
  75124. */
  75125. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  75126. /**
  75127. * Adds a new velocity gradient
  75128. * @param gradient defines the gradient to use (between 0 and 1)
  75129. * @param factor defines the velocity to affect to the specified gradient
  75130. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75131. * @returns the current particle system
  75132. */
  75133. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75134. /**
  75135. * Remove a specific velocity gradient
  75136. * @param gradient defines the gradient to remove
  75137. * @returns the current particle system
  75138. */
  75139. removeVelocityGradient(gradient: number): IParticleSystem;
  75140. /**
  75141. * Adds a new limit velocity gradient
  75142. * @param gradient defines the gradient to use (between 0 and 1)
  75143. * @param factor defines the limit velocity value to affect to the specified gradient
  75144. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75145. * @returns the current particle system
  75146. */
  75147. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75148. /**
  75149. * Remove a specific limit velocity gradient
  75150. * @param gradient defines the gradient to remove
  75151. * @returns the current particle system
  75152. */
  75153. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  75154. /**
  75155. * Adds a new drag gradient
  75156. * @param gradient defines the gradient to use (between 0 and 1)
  75157. * @param factor defines the drag value to affect to the specified gradient
  75158. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75159. * @returns the current particle system
  75160. */
  75161. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75162. /**
  75163. * Remove a specific drag gradient
  75164. * @param gradient defines the gradient to remove
  75165. * @returns the current particle system
  75166. */
  75167. removeDragGradient(gradient: number): IParticleSystem;
  75168. /**
  75169. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  75170. * @param gradient defines the gradient to use (between 0 and 1)
  75171. * @param factor defines the emit rate value to affect to the specified gradient
  75172. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75173. * @returns the current particle system
  75174. */
  75175. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75176. /**
  75177. * Remove a specific emit rate gradient
  75178. * @param gradient defines the gradient to remove
  75179. * @returns the current particle system
  75180. */
  75181. removeEmitRateGradient(gradient: number): IParticleSystem;
  75182. /**
  75183. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  75184. * @param gradient defines the gradient to use (between 0 and 1)
  75185. * @param factor defines the start size value to affect to the specified gradient
  75186. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75187. * @returns the current particle system
  75188. */
  75189. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75190. /**
  75191. * Remove a specific start size gradient
  75192. * @param gradient defines the gradient to remove
  75193. * @returns the current particle system
  75194. */
  75195. removeStartSizeGradient(gradient: number): IParticleSystem;
  75196. private _createRampGradientTexture;
  75197. /**
  75198. * Gets the current list of ramp gradients.
  75199. * You must use addRampGradient and removeRampGradient to udpate this list
  75200. * @returns the list of ramp gradients
  75201. */
  75202. getRampGradients(): Nullable<Array<Color3Gradient>>;
  75203. /**
  75204. * Adds a new ramp gradient used to remap particle colors
  75205. * @param gradient defines the gradient to use (between 0 and 1)
  75206. * @param color defines the color to affect to the specified gradient
  75207. * @returns the current particle system
  75208. */
  75209. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  75210. /**
  75211. * Remove a specific ramp gradient
  75212. * @param gradient defines the gradient to remove
  75213. * @returns the current particle system
  75214. */
  75215. removeRampGradient(gradient: number): ParticleSystem;
  75216. /**
  75217. * Adds a new color gradient
  75218. * @param gradient defines the gradient to use (between 0 and 1)
  75219. * @param color1 defines the color to affect to the specified gradient
  75220. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  75221. * @returns this particle system
  75222. */
  75223. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  75224. /**
  75225. * Remove a specific color gradient
  75226. * @param gradient defines the gradient to remove
  75227. * @returns this particle system
  75228. */
  75229. removeColorGradient(gradient: number): IParticleSystem;
  75230. private _fetchR;
  75231. protected _reset(): void;
  75232. private _resetEffect;
  75233. private _createVertexBuffers;
  75234. private _createIndexBuffer;
  75235. /**
  75236. * Gets the maximum number of particles active at the same time.
  75237. * @returns The max number of active particles.
  75238. */
  75239. getCapacity(): number;
  75240. /**
  75241. * Gets whether there are still active particles in the system.
  75242. * @returns True if it is alive, otherwise false.
  75243. */
  75244. isAlive(): boolean;
  75245. /**
  75246. * Gets if the system has been started. (Note: this will still be true after stop is called)
  75247. * @returns True if it has been started, otherwise false.
  75248. */
  75249. isStarted(): boolean;
  75250. private _prepareSubEmitterInternalArray;
  75251. /**
  75252. * Starts the particle system and begins to emit
  75253. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  75254. */
  75255. start(delay?: number): void;
  75256. /**
  75257. * Stops the particle system.
  75258. * @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.
  75259. */
  75260. stop(stopSubEmitters?: boolean): void;
  75261. /**
  75262. * Remove all active particles
  75263. */
  75264. reset(): void;
  75265. /**
  75266. * @hidden (for internal use only)
  75267. */
  75268. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  75269. /**
  75270. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  75271. * Its lifetime will start back at 0.
  75272. */
  75273. recycleParticle: (particle: Particle) => void;
  75274. private _stopSubEmitters;
  75275. private _createParticle;
  75276. private _removeFromRoot;
  75277. private _emitFromParticle;
  75278. private _update;
  75279. /** @hidden */
  75280. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  75281. /** @hidden */
  75282. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  75283. /** @hidden */
  75284. private _getEffect;
  75285. /**
  75286. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  75287. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  75288. */
  75289. animate(preWarmOnly?: boolean): void;
  75290. private _appendParticleVertices;
  75291. /**
  75292. * Rebuilds the particle system.
  75293. */
  75294. rebuild(): void;
  75295. /**
  75296. * Is this system ready to be used/rendered
  75297. * @return true if the system is ready
  75298. */
  75299. isReady(): boolean;
  75300. private _render;
  75301. /**
  75302. * Renders the particle system in its current state.
  75303. * @returns the current number of particles
  75304. */
  75305. render(): number;
  75306. /**
  75307. * Disposes the particle system and free the associated resources
  75308. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  75309. */
  75310. dispose(disposeTexture?: boolean): void;
  75311. /**
  75312. * Clones the particle system.
  75313. * @param name The name of the cloned object
  75314. * @param newEmitter The new emitter to use
  75315. * @returns the cloned particle system
  75316. */
  75317. clone(name: string, newEmitter: any): ParticleSystem;
  75318. /**
  75319. * Serializes the particle system to a JSON object.
  75320. * @returns the JSON object
  75321. */
  75322. serialize(): any;
  75323. /** @hidden */
  75324. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  75325. /** @hidden */
  75326. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  75327. /**
  75328. * Parses a JSON object to create a particle system.
  75329. * @param parsedParticleSystem The JSON object to parse
  75330. * @param scene The scene to create the particle system in
  75331. * @param rootUrl The root url to use to load external dependencies like texture
  75332. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  75333. * @returns the Parsed particle system
  75334. */
  75335. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  75336. }
  75337. }
  75338. declare module BABYLON {
  75339. /**
  75340. * A particle represents one of the element emitted by a particle system.
  75341. * This is mainly define by its coordinates, direction, velocity and age.
  75342. */
  75343. export class Particle {
  75344. /**
  75345. * The particle system the particle belongs to.
  75346. */
  75347. particleSystem: ParticleSystem;
  75348. private static _Count;
  75349. /**
  75350. * Unique ID of the particle
  75351. */
  75352. id: number;
  75353. /**
  75354. * The world position of the particle in the scene.
  75355. */
  75356. position: Vector3;
  75357. /**
  75358. * The world direction of the particle in the scene.
  75359. */
  75360. direction: Vector3;
  75361. /**
  75362. * The color of the particle.
  75363. */
  75364. color: Color4;
  75365. /**
  75366. * The color change of the particle per step.
  75367. */
  75368. colorStep: Color4;
  75369. /**
  75370. * Defines how long will the life of the particle be.
  75371. */
  75372. lifeTime: number;
  75373. /**
  75374. * The current age of the particle.
  75375. */
  75376. age: number;
  75377. /**
  75378. * The current size of the particle.
  75379. */
  75380. size: number;
  75381. /**
  75382. * The current scale of the particle.
  75383. */
  75384. scale: Vector2;
  75385. /**
  75386. * The current angle of the particle.
  75387. */
  75388. angle: number;
  75389. /**
  75390. * Defines how fast is the angle changing.
  75391. */
  75392. angularSpeed: number;
  75393. /**
  75394. * Defines the cell index used by the particle to be rendered from a sprite.
  75395. */
  75396. cellIndex: number;
  75397. /**
  75398. * The information required to support color remapping
  75399. */
  75400. remapData: Vector4;
  75401. /** @hidden */
  75402. _randomCellOffset?: number;
  75403. /** @hidden */
  75404. _initialDirection: Nullable<Vector3>;
  75405. /** @hidden */
  75406. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  75407. /** @hidden */
  75408. _initialStartSpriteCellID: number;
  75409. /** @hidden */
  75410. _initialEndSpriteCellID: number;
  75411. /** @hidden */
  75412. _currentColorGradient: Nullable<ColorGradient>;
  75413. /** @hidden */
  75414. _currentColor1: Color4;
  75415. /** @hidden */
  75416. _currentColor2: Color4;
  75417. /** @hidden */
  75418. _currentSizeGradient: Nullable<FactorGradient>;
  75419. /** @hidden */
  75420. _currentSize1: number;
  75421. /** @hidden */
  75422. _currentSize2: number;
  75423. /** @hidden */
  75424. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  75425. /** @hidden */
  75426. _currentAngularSpeed1: number;
  75427. /** @hidden */
  75428. _currentAngularSpeed2: number;
  75429. /** @hidden */
  75430. _currentVelocityGradient: Nullable<FactorGradient>;
  75431. /** @hidden */
  75432. _currentVelocity1: number;
  75433. /** @hidden */
  75434. _currentVelocity2: number;
  75435. /** @hidden */
  75436. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  75437. /** @hidden */
  75438. _currentLimitVelocity1: number;
  75439. /** @hidden */
  75440. _currentLimitVelocity2: number;
  75441. /** @hidden */
  75442. _currentDragGradient: Nullable<FactorGradient>;
  75443. /** @hidden */
  75444. _currentDrag1: number;
  75445. /** @hidden */
  75446. _currentDrag2: number;
  75447. /** @hidden */
  75448. _randomNoiseCoordinates1: Vector3;
  75449. /** @hidden */
  75450. _randomNoiseCoordinates2: Vector3;
  75451. /**
  75452. * Creates a new instance Particle
  75453. * @param particleSystem the particle system the particle belongs to
  75454. */
  75455. constructor(
  75456. /**
  75457. * The particle system the particle belongs to.
  75458. */
  75459. particleSystem: ParticleSystem);
  75460. private updateCellInfoFromSystem;
  75461. /**
  75462. * Defines how the sprite cell index is updated for the particle
  75463. */
  75464. updateCellIndex(): void;
  75465. /** @hidden */
  75466. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  75467. /** @hidden */
  75468. _inheritParticleInfoToSubEmitters(): void;
  75469. /** @hidden */
  75470. _reset(): void;
  75471. /**
  75472. * Copy the properties of particle to another one.
  75473. * @param other the particle to copy the information to.
  75474. */
  75475. copyTo(other: Particle): void;
  75476. }
  75477. }
  75478. declare module BABYLON {
  75479. /**
  75480. * Particle emitter represents a volume emitting particles.
  75481. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  75482. */
  75483. export interface IParticleEmitterType {
  75484. /**
  75485. * Called by the particle System when the direction is computed for the created particle.
  75486. * @param worldMatrix is the world matrix of the particle system
  75487. * @param directionToUpdate is the direction vector to update with the result
  75488. * @param particle is the particle we are computed the direction for
  75489. */
  75490. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75491. /**
  75492. * Called by the particle System when the position is computed for the created particle.
  75493. * @param worldMatrix is the world matrix of the particle system
  75494. * @param positionToUpdate is the position vector to update with the result
  75495. * @param particle is the particle we are computed the position for
  75496. */
  75497. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  75498. /**
  75499. * Clones the current emitter and returns a copy of it
  75500. * @returns the new emitter
  75501. */
  75502. clone(): IParticleEmitterType;
  75503. /**
  75504. * Called by the GPUParticleSystem to setup the update shader
  75505. * @param effect defines the update shader
  75506. */
  75507. applyToShader(effect: Effect): void;
  75508. /**
  75509. * Returns a string to use to update the GPU particles update shader
  75510. * @returns the effect defines string
  75511. */
  75512. getEffectDefines(): string;
  75513. /**
  75514. * Returns a string representing the class name
  75515. * @returns a string containing the class name
  75516. */
  75517. getClassName(): string;
  75518. /**
  75519. * Serializes the particle system to a JSON object.
  75520. * @returns the JSON object
  75521. */
  75522. serialize(): any;
  75523. /**
  75524. * Parse properties from a JSON object
  75525. * @param serializationObject defines the JSON object
  75526. */
  75527. parse(serializationObject: any): void;
  75528. }
  75529. }
  75530. declare module BABYLON {
  75531. /**
  75532. * Particle emitter emitting particles from the inside of a box.
  75533. * It emits the particles randomly between 2 given directions.
  75534. */
  75535. export class BoxParticleEmitter implements IParticleEmitterType {
  75536. /**
  75537. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  75538. */
  75539. direction1: Vector3;
  75540. /**
  75541. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  75542. */
  75543. direction2: Vector3;
  75544. /**
  75545. * 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.
  75546. */
  75547. minEmitBox: Vector3;
  75548. /**
  75549. * 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.
  75550. */
  75551. maxEmitBox: Vector3;
  75552. /**
  75553. * Creates a new instance BoxParticleEmitter
  75554. */
  75555. constructor();
  75556. /**
  75557. * Called by the particle System when the direction is computed for the created particle.
  75558. * @param worldMatrix is the world matrix of the particle system
  75559. * @param directionToUpdate is the direction vector to update with the result
  75560. * @param particle is the particle we are computed the direction for
  75561. */
  75562. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75563. /**
  75564. * Called by the particle System when the position is computed for the created particle.
  75565. * @param worldMatrix is the world matrix of the particle system
  75566. * @param positionToUpdate is the position vector to update with the result
  75567. * @param particle is the particle we are computed the position for
  75568. */
  75569. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  75570. /**
  75571. * Clones the current emitter and returns a copy of it
  75572. * @returns the new emitter
  75573. */
  75574. clone(): BoxParticleEmitter;
  75575. /**
  75576. * Called by the GPUParticleSystem to setup the update shader
  75577. * @param effect defines the update shader
  75578. */
  75579. applyToShader(effect: Effect): void;
  75580. /**
  75581. * Returns a string to use to update the GPU particles update shader
  75582. * @returns a string containng the defines string
  75583. */
  75584. getEffectDefines(): string;
  75585. /**
  75586. * Returns the string "BoxParticleEmitter"
  75587. * @returns a string containing the class name
  75588. */
  75589. getClassName(): string;
  75590. /**
  75591. * Serializes the particle system to a JSON object.
  75592. * @returns the JSON object
  75593. */
  75594. serialize(): any;
  75595. /**
  75596. * Parse properties from a JSON object
  75597. * @param serializationObject defines the JSON object
  75598. */
  75599. parse(serializationObject: any): void;
  75600. }
  75601. }
  75602. declare module BABYLON {
  75603. /**
  75604. * Particle emitter emitting particles from the inside of a cone.
  75605. * It emits the particles alongside the cone volume from the base to the particle.
  75606. * The emission direction might be randomized.
  75607. */
  75608. export class ConeParticleEmitter implements IParticleEmitterType {
  75609. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  75610. directionRandomizer: number;
  75611. private _radius;
  75612. private _angle;
  75613. private _height;
  75614. /**
  75615. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  75616. */
  75617. radiusRange: number;
  75618. /**
  75619. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  75620. */
  75621. heightRange: number;
  75622. /**
  75623. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  75624. */
  75625. emitFromSpawnPointOnly: boolean;
  75626. /**
  75627. * Gets or sets the radius of the emission cone
  75628. */
  75629. radius: number;
  75630. /**
  75631. * Gets or sets the angle of the emission cone
  75632. */
  75633. angle: number;
  75634. private _buildHeight;
  75635. /**
  75636. * Creates a new instance ConeParticleEmitter
  75637. * @param radius the radius of the emission cone (1 by default)
  75638. * @param angle the cone base angle (PI by default)
  75639. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  75640. */
  75641. constructor(radius?: number, angle?: number,
  75642. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  75643. directionRandomizer?: number);
  75644. /**
  75645. * Called by the particle System when the direction is computed for the created particle.
  75646. * @param worldMatrix is the world matrix of the particle system
  75647. * @param directionToUpdate is the direction vector to update with the result
  75648. * @param particle is the particle we are computed the direction for
  75649. */
  75650. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75651. /**
  75652. * Called by the particle System when the position is computed for the created particle.
  75653. * @param worldMatrix is the world matrix of the particle system
  75654. * @param positionToUpdate is the position vector to update with the result
  75655. * @param particle is the particle we are computed the position for
  75656. */
  75657. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  75658. /**
  75659. * Clones the current emitter and returns a copy of it
  75660. * @returns the new emitter
  75661. */
  75662. clone(): ConeParticleEmitter;
  75663. /**
  75664. * Called by the GPUParticleSystem to setup the update shader
  75665. * @param effect defines the update shader
  75666. */
  75667. applyToShader(effect: Effect): void;
  75668. /**
  75669. * Returns a string to use to update the GPU particles update shader
  75670. * @returns a string containng the defines string
  75671. */
  75672. getEffectDefines(): string;
  75673. /**
  75674. * Returns the string "ConeParticleEmitter"
  75675. * @returns a string containing the class name
  75676. */
  75677. getClassName(): string;
  75678. /**
  75679. * Serializes the particle system to a JSON object.
  75680. * @returns the JSON object
  75681. */
  75682. serialize(): any;
  75683. /**
  75684. * Parse properties from a JSON object
  75685. * @param serializationObject defines the JSON object
  75686. */
  75687. parse(serializationObject: any): void;
  75688. }
  75689. }
  75690. declare module BABYLON {
  75691. /**
  75692. * Particle emitter emitting particles from the inside of a cylinder.
  75693. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  75694. */
  75695. export class CylinderParticleEmitter implements IParticleEmitterType {
  75696. /**
  75697. * The radius of the emission cylinder.
  75698. */
  75699. radius: number;
  75700. /**
  75701. * The height of the emission cylinder.
  75702. */
  75703. height: number;
  75704. /**
  75705. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  75706. */
  75707. radiusRange: number;
  75708. /**
  75709. * How much to randomize the particle direction [0-1].
  75710. */
  75711. directionRandomizer: number;
  75712. /**
  75713. * Creates a new instance CylinderParticleEmitter
  75714. * @param radius the radius of the emission cylinder (1 by default)
  75715. * @param height the height of the emission cylinder (1 by default)
  75716. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  75717. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  75718. */
  75719. constructor(
  75720. /**
  75721. * The radius of the emission cylinder.
  75722. */
  75723. radius?: number,
  75724. /**
  75725. * The height of the emission cylinder.
  75726. */
  75727. height?: number,
  75728. /**
  75729. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  75730. */
  75731. radiusRange?: number,
  75732. /**
  75733. * How much to randomize the particle direction [0-1].
  75734. */
  75735. directionRandomizer?: number);
  75736. /**
  75737. * Called by the particle System when the direction is computed for the created particle.
  75738. * @param worldMatrix is the world matrix of the particle system
  75739. * @param directionToUpdate is the direction vector to update with the result
  75740. * @param particle is the particle we are computed the direction for
  75741. */
  75742. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75743. /**
  75744. * Called by the particle System when the position is computed for the created particle.
  75745. * @param worldMatrix is the world matrix of the particle system
  75746. * @param positionToUpdate is the position vector to update with the result
  75747. * @param particle is the particle we are computed the position for
  75748. */
  75749. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  75750. /**
  75751. * Clones the current emitter and returns a copy of it
  75752. * @returns the new emitter
  75753. */
  75754. clone(): CylinderParticleEmitter;
  75755. /**
  75756. * Called by the GPUParticleSystem to setup the update shader
  75757. * @param effect defines the update shader
  75758. */
  75759. applyToShader(effect: Effect): void;
  75760. /**
  75761. * Returns a string to use to update the GPU particles update shader
  75762. * @returns a string containng the defines string
  75763. */
  75764. getEffectDefines(): string;
  75765. /**
  75766. * Returns the string "CylinderParticleEmitter"
  75767. * @returns a string containing the class name
  75768. */
  75769. getClassName(): string;
  75770. /**
  75771. * Serializes the particle system to a JSON object.
  75772. * @returns the JSON object
  75773. */
  75774. serialize(): any;
  75775. /**
  75776. * Parse properties from a JSON object
  75777. * @param serializationObject defines the JSON object
  75778. */
  75779. parse(serializationObject: any): void;
  75780. }
  75781. /**
  75782. * Particle emitter emitting particles from the inside of a cylinder.
  75783. * It emits the particles randomly between two vectors.
  75784. */
  75785. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  75786. /**
  75787. * The min limit of the emission direction.
  75788. */
  75789. direction1: Vector3;
  75790. /**
  75791. * The max limit of the emission direction.
  75792. */
  75793. direction2: Vector3;
  75794. /**
  75795. * Creates a new instance CylinderDirectedParticleEmitter
  75796. * @param radius the radius of the emission cylinder (1 by default)
  75797. * @param height the height of the emission cylinder (1 by default)
  75798. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  75799. * @param direction1 the min limit of the emission direction (up vector by default)
  75800. * @param direction2 the max limit of the emission direction (up vector by default)
  75801. */
  75802. constructor(radius?: number, height?: number, radiusRange?: number,
  75803. /**
  75804. * The min limit of the emission direction.
  75805. */
  75806. direction1?: Vector3,
  75807. /**
  75808. * The max limit of the emission direction.
  75809. */
  75810. direction2?: Vector3);
  75811. /**
  75812. * Called by the particle System when the direction is computed for the created particle.
  75813. * @param worldMatrix is the world matrix of the particle system
  75814. * @param directionToUpdate is the direction vector to update with the result
  75815. * @param particle is the particle we are computed the direction for
  75816. */
  75817. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75818. /**
  75819. * Clones the current emitter and returns a copy of it
  75820. * @returns the new emitter
  75821. */
  75822. clone(): CylinderDirectedParticleEmitter;
  75823. /**
  75824. * Called by the GPUParticleSystem to setup the update shader
  75825. * @param effect defines the update shader
  75826. */
  75827. applyToShader(effect: Effect): void;
  75828. /**
  75829. * Returns a string to use to update the GPU particles update shader
  75830. * @returns a string containng the defines string
  75831. */
  75832. getEffectDefines(): string;
  75833. /**
  75834. * Returns the string "CylinderDirectedParticleEmitter"
  75835. * @returns a string containing the class name
  75836. */
  75837. getClassName(): string;
  75838. /**
  75839. * Serializes the particle system to a JSON object.
  75840. * @returns the JSON object
  75841. */
  75842. serialize(): any;
  75843. /**
  75844. * Parse properties from a JSON object
  75845. * @param serializationObject defines the JSON object
  75846. */
  75847. parse(serializationObject: any): void;
  75848. }
  75849. }
  75850. declare module BABYLON {
  75851. /**
  75852. * Particle emitter emitting particles from the inside of a hemisphere.
  75853. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  75854. */
  75855. export class HemisphericParticleEmitter implements IParticleEmitterType {
  75856. /**
  75857. * The radius of the emission hemisphere.
  75858. */
  75859. radius: number;
  75860. /**
  75861. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  75862. */
  75863. radiusRange: number;
  75864. /**
  75865. * How much to randomize the particle direction [0-1].
  75866. */
  75867. directionRandomizer: number;
  75868. /**
  75869. * Creates a new instance HemisphericParticleEmitter
  75870. * @param radius the radius of the emission hemisphere (1 by default)
  75871. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  75872. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  75873. */
  75874. constructor(
  75875. /**
  75876. * The radius of the emission hemisphere.
  75877. */
  75878. radius?: number,
  75879. /**
  75880. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  75881. */
  75882. radiusRange?: number,
  75883. /**
  75884. * How much to randomize the particle direction [0-1].
  75885. */
  75886. directionRandomizer?: number);
  75887. /**
  75888. * Called by the particle System when the direction is computed for the created particle.
  75889. * @param worldMatrix is the world matrix of the particle system
  75890. * @param directionToUpdate is the direction vector to update with the result
  75891. * @param particle is the particle we are computed the direction for
  75892. */
  75893. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75894. /**
  75895. * Called by the particle System when the position is computed for the created particle.
  75896. * @param worldMatrix is the world matrix of the particle system
  75897. * @param positionToUpdate is the position vector to update with the result
  75898. * @param particle is the particle we are computed the position for
  75899. */
  75900. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  75901. /**
  75902. * Clones the current emitter and returns a copy of it
  75903. * @returns the new emitter
  75904. */
  75905. clone(): HemisphericParticleEmitter;
  75906. /**
  75907. * Called by the GPUParticleSystem to setup the update shader
  75908. * @param effect defines the update shader
  75909. */
  75910. applyToShader(effect: Effect): void;
  75911. /**
  75912. * Returns a string to use to update the GPU particles update shader
  75913. * @returns a string containng the defines string
  75914. */
  75915. getEffectDefines(): string;
  75916. /**
  75917. * Returns the string "HemisphericParticleEmitter"
  75918. * @returns a string containing the class name
  75919. */
  75920. getClassName(): string;
  75921. /**
  75922. * Serializes the particle system to a JSON object.
  75923. * @returns the JSON object
  75924. */
  75925. serialize(): any;
  75926. /**
  75927. * Parse properties from a JSON object
  75928. * @param serializationObject defines the JSON object
  75929. */
  75930. parse(serializationObject: any): void;
  75931. }
  75932. }
  75933. declare module BABYLON {
  75934. /**
  75935. * Particle emitter emitting particles from a point.
  75936. * It emits the particles randomly between 2 given directions.
  75937. */
  75938. export class PointParticleEmitter implements IParticleEmitterType {
  75939. /**
  75940. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  75941. */
  75942. direction1: Vector3;
  75943. /**
  75944. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  75945. */
  75946. direction2: Vector3;
  75947. /**
  75948. * Creates a new instance PointParticleEmitter
  75949. */
  75950. constructor();
  75951. /**
  75952. * Called by the particle System when the direction is computed for the created particle.
  75953. * @param worldMatrix is the world matrix of the particle system
  75954. * @param directionToUpdate is the direction vector to update with the result
  75955. * @param particle is the particle we are computed the direction for
  75956. */
  75957. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75958. /**
  75959. * Called by the particle System when the position is computed for the created particle.
  75960. * @param worldMatrix is the world matrix of the particle system
  75961. * @param positionToUpdate is the position vector to update with the result
  75962. * @param particle is the particle we are computed the position for
  75963. */
  75964. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  75965. /**
  75966. * Clones the current emitter and returns a copy of it
  75967. * @returns the new emitter
  75968. */
  75969. clone(): PointParticleEmitter;
  75970. /**
  75971. * Called by the GPUParticleSystem to setup the update shader
  75972. * @param effect defines the update shader
  75973. */
  75974. applyToShader(effect: Effect): void;
  75975. /**
  75976. * Returns a string to use to update the GPU particles update shader
  75977. * @returns a string containng the defines string
  75978. */
  75979. getEffectDefines(): string;
  75980. /**
  75981. * Returns the string "PointParticleEmitter"
  75982. * @returns a string containing the class name
  75983. */
  75984. getClassName(): string;
  75985. /**
  75986. * Serializes the particle system to a JSON object.
  75987. * @returns the JSON object
  75988. */
  75989. serialize(): any;
  75990. /**
  75991. * Parse properties from a JSON object
  75992. * @param serializationObject defines the JSON object
  75993. */
  75994. parse(serializationObject: any): void;
  75995. }
  75996. }
  75997. declare module BABYLON {
  75998. /**
  75999. * Particle emitter emitting particles from the inside of a sphere.
  76000. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  76001. */
  76002. export class SphereParticleEmitter implements IParticleEmitterType {
  76003. /**
  76004. * The radius of the emission sphere.
  76005. */
  76006. radius: number;
  76007. /**
  76008. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  76009. */
  76010. radiusRange: number;
  76011. /**
  76012. * How much to randomize the particle direction [0-1].
  76013. */
  76014. directionRandomizer: number;
  76015. /**
  76016. * Creates a new instance SphereParticleEmitter
  76017. * @param radius the radius of the emission sphere (1 by default)
  76018. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  76019. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  76020. */
  76021. constructor(
  76022. /**
  76023. * The radius of the emission sphere.
  76024. */
  76025. radius?: number,
  76026. /**
  76027. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  76028. */
  76029. radiusRange?: number,
  76030. /**
  76031. * How much to randomize the particle direction [0-1].
  76032. */
  76033. directionRandomizer?: number);
  76034. /**
  76035. * Called by the particle System when the direction is computed for the created particle.
  76036. * @param worldMatrix is the world matrix of the particle system
  76037. * @param directionToUpdate is the direction vector to update with the result
  76038. * @param particle is the particle we are computed the direction for
  76039. */
  76040. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  76041. /**
  76042. * Called by the particle System when the position is computed for the created particle.
  76043. * @param worldMatrix is the world matrix of the particle system
  76044. * @param positionToUpdate is the position vector to update with the result
  76045. * @param particle is the particle we are computed the position for
  76046. */
  76047. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  76048. /**
  76049. * Clones the current emitter and returns a copy of it
  76050. * @returns the new emitter
  76051. */
  76052. clone(): SphereParticleEmitter;
  76053. /**
  76054. * Called by the GPUParticleSystem to setup the update shader
  76055. * @param effect defines the update shader
  76056. */
  76057. applyToShader(effect: Effect): void;
  76058. /**
  76059. * Returns a string to use to update the GPU particles update shader
  76060. * @returns a string containng the defines string
  76061. */
  76062. getEffectDefines(): string;
  76063. /**
  76064. * Returns the string "SphereParticleEmitter"
  76065. * @returns a string containing the class name
  76066. */
  76067. getClassName(): string;
  76068. /**
  76069. * Serializes the particle system to a JSON object.
  76070. * @returns the JSON object
  76071. */
  76072. serialize(): any;
  76073. /**
  76074. * Parse properties from a JSON object
  76075. * @param serializationObject defines the JSON object
  76076. */
  76077. parse(serializationObject: any): void;
  76078. }
  76079. /**
  76080. * Particle emitter emitting particles from the inside of a sphere.
  76081. * It emits the particles randomly between two vectors.
  76082. */
  76083. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  76084. /**
  76085. * The min limit of the emission direction.
  76086. */
  76087. direction1: Vector3;
  76088. /**
  76089. * The max limit of the emission direction.
  76090. */
  76091. direction2: Vector3;
  76092. /**
  76093. * Creates a new instance SphereDirectedParticleEmitter
  76094. * @param radius the radius of the emission sphere (1 by default)
  76095. * @param direction1 the min limit of the emission direction (up vector by default)
  76096. * @param direction2 the max limit of the emission direction (up vector by default)
  76097. */
  76098. constructor(radius?: number,
  76099. /**
  76100. * The min limit of the emission direction.
  76101. */
  76102. direction1?: Vector3,
  76103. /**
  76104. * The max limit of the emission direction.
  76105. */
  76106. direction2?: Vector3);
  76107. /**
  76108. * Called by the particle System when the direction is computed for the created particle.
  76109. * @param worldMatrix is the world matrix of the particle system
  76110. * @param directionToUpdate is the direction vector to update with the result
  76111. * @param particle is the particle we are computed the direction for
  76112. */
  76113. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  76114. /**
  76115. * Clones the current emitter and returns a copy of it
  76116. * @returns the new emitter
  76117. */
  76118. clone(): SphereDirectedParticleEmitter;
  76119. /**
  76120. * Called by the GPUParticleSystem to setup the update shader
  76121. * @param effect defines the update shader
  76122. */
  76123. applyToShader(effect: Effect): void;
  76124. /**
  76125. * Returns a string to use to update the GPU particles update shader
  76126. * @returns a string containng the defines string
  76127. */
  76128. getEffectDefines(): string;
  76129. /**
  76130. * Returns the string "SphereDirectedParticleEmitter"
  76131. * @returns a string containing the class name
  76132. */
  76133. getClassName(): string;
  76134. /**
  76135. * Serializes the particle system to a JSON object.
  76136. * @returns the JSON object
  76137. */
  76138. serialize(): any;
  76139. /**
  76140. * Parse properties from a JSON object
  76141. * @param serializationObject defines the JSON object
  76142. */
  76143. parse(serializationObject: any): void;
  76144. }
  76145. }
  76146. declare module BABYLON {
  76147. /**
  76148. * Interface representing a particle system in Babylon.js.
  76149. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  76150. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  76151. */
  76152. export interface IParticleSystem {
  76153. /**
  76154. * List of animations used by the particle system.
  76155. */
  76156. animations: Animation[];
  76157. /**
  76158. * The id of the Particle system.
  76159. */
  76160. id: string;
  76161. /**
  76162. * The name of the Particle system.
  76163. */
  76164. name: string;
  76165. /**
  76166. * The emitter represents the Mesh or position we are attaching the particle system to.
  76167. */
  76168. emitter: Nullable<AbstractMesh | Vector3>;
  76169. /**
  76170. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  76171. */
  76172. isBillboardBased: boolean;
  76173. /**
  76174. * The rendering group used by the Particle system to chose when to render.
  76175. */
  76176. renderingGroupId: number;
  76177. /**
  76178. * The layer mask we are rendering the particles through.
  76179. */
  76180. layerMask: number;
  76181. /**
  76182. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  76183. */
  76184. updateSpeed: number;
  76185. /**
  76186. * The amount of time the particle system is running (depends of the overall update speed).
  76187. */
  76188. targetStopDuration: number;
  76189. /**
  76190. * The texture used to render each particle. (this can be a spritesheet)
  76191. */
  76192. particleTexture: Nullable<Texture>;
  76193. /**
  76194. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  76195. */
  76196. blendMode: number;
  76197. /**
  76198. * Minimum life time of emitting particles.
  76199. */
  76200. minLifeTime: number;
  76201. /**
  76202. * Maximum life time of emitting particles.
  76203. */
  76204. maxLifeTime: number;
  76205. /**
  76206. * Minimum Size of emitting particles.
  76207. */
  76208. minSize: number;
  76209. /**
  76210. * Maximum Size of emitting particles.
  76211. */
  76212. maxSize: number;
  76213. /**
  76214. * Minimum scale of emitting particles on X axis.
  76215. */
  76216. minScaleX: number;
  76217. /**
  76218. * Maximum scale of emitting particles on X axis.
  76219. */
  76220. maxScaleX: number;
  76221. /**
  76222. * Minimum scale of emitting particles on Y axis.
  76223. */
  76224. minScaleY: number;
  76225. /**
  76226. * Maximum scale of emitting particles on Y axis.
  76227. */
  76228. maxScaleY: number;
  76229. /**
  76230. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  76231. */
  76232. color1: Color4;
  76233. /**
  76234. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  76235. */
  76236. color2: Color4;
  76237. /**
  76238. * Color the particle will have at the end of its lifetime.
  76239. */
  76240. colorDead: Color4;
  76241. /**
  76242. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  76243. */
  76244. emitRate: number;
  76245. /**
  76246. * You can use gravity if you want to give an orientation to your particles.
  76247. */
  76248. gravity: Vector3;
  76249. /**
  76250. * Minimum power of emitting particles.
  76251. */
  76252. minEmitPower: number;
  76253. /**
  76254. * Maximum power of emitting particles.
  76255. */
  76256. maxEmitPower: number;
  76257. /**
  76258. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  76259. */
  76260. minAngularSpeed: number;
  76261. /**
  76262. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  76263. */
  76264. maxAngularSpeed: number;
  76265. /**
  76266. * Gets or sets the minimal initial rotation in radians.
  76267. */
  76268. minInitialRotation: number;
  76269. /**
  76270. * Gets or sets the maximal initial rotation in radians.
  76271. */
  76272. maxInitialRotation: number;
  76273. /**
  76274. * The particle emitter type defines the emitter used by the particle system.
  76275. * It can be for example box, sphere, or cone...
  76276. */
  76277. particleEmitterType: Nullable<IParticleEmitterType>;
  76278. /**
  76279. * Defines the delay in milliseconds before starting the system (0 by default)
  76280. */
  76281. startDelay: number;
  76282. /**
  76283. * 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
  76284. */
  76285. preWarmCycles: number;
  76286. /**
  76287. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  76288. */
  76289. preWarmStepOffset: number;
  76290. /**
  76291. * 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)
  76292. */
  76293. spriteCellChangeSpeed: number;
  76294. /**
  76295. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  76296. */
  76297. startSpriteCellID: number;
  76298. /**
  76299. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  76300. */
  76301. endSpriteCellID: number;
  76302. /**
  76303. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  76304. */
  76305. spriteCellWidth: number;
  76306. /**
  76307. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  76308. */
  76309. spriteCellHeight: number;
  76310. /**
  76311. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  76312. */
  76313. spriteRandomStartCell: boolean;
  76314. /**
  76315. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  76316. */
  76317. isAnimationSheetEnabled: boolean;
  76318. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  76319. translationPivot: Vector2;
  76320. /**
  76321. * Gets or sets a texture used to add random noise to particle positions
  76322. */
  76323. noiseTexture: Nullable<BaseTexture>;
  76324. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  76325. noiseStrength: Vector3;
  76326. /**
  76327. * Gets or sets the billboard mode to use when isBillboardBased = true.
  76328. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  76329. */
  76330. billboardMode: number;
  76331. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  76332. limitVelocityDamping: number;
  76333. /**
  76334. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  76335. */
  76336. beginAnimationOnStart: boolean;
  76337. /**
  76338. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  76339. */
  76340. beginAnimationFrom: number;
  76341. /**
  76342. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  76343. */
  76344. beginAnimationTo: number;
  76345. /**
  76346. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  76347. */
  76348. beginAnimationLoop: boolean;
  76349. /**
  76350. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  76351. */
  76352. disposeOnStop: boolean;
  76353. /**
  76354. * Gets the maximum number of particles active at the same time.
  76355. * @returns The max number of active particles.
  76356. */
  76357. getCapacity(): number;
  76358. /**
  76359. * Gets if the system has been started. (Note: this will still be true after stop is called)
  76360. * @returns True if it has been started, otherwise false.
  76361. */
  76362. isStarted(): boolean;
  76363. /**
  76364. * Animates the particle system for this frame.
  76365. */
  76366. animate(): void;
  76367. /**
  76368. * Renders the particle system in its current state.
  76369. * @returns the current number of particles
  76370. */
  76371. render(): number;
  76372. /**
  76373. * Dispose the particle system and frees its associated resources.
  76374. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  76375. */
  76376. dispose(disposeTexture?: boolean): void;
  76377. /**
  76378. * Clones the particle system.
  76379. * @param name The name of the cloned object
  76380. * @param newEmitter The new emitter to use
  76381. * @returns the cloned particle system
  76382. */
  76383. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  76384. /**
  76385. * Serializes the particle system to a JSON object.
  76386. * @returns the JSON object
  76387. */
  76388. serialize(): any;
  76389. /**
  76390. * Rebuild the particle system
  76391. */
  76392. rebuild(): void;
  76393. /**
  76394. * Starts the particle system and begins to emit
  76395. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  76396. */
  76397. start(delay?: number): void;
  76398. /**
  76399. * Stops the particle system.
  76400. */
  76401. stop(): void;
  76402. /**
  76403. * Remove all active particles
  76404. */
  76405. reset(): void;
  76406. /**
  76407. * Is this system ready to be used/rendered
  76408. * @return true if the system is ready
  76409. */
  76410. isReady(): boolean;
  76411. /**
  76412. * Adds a new color gradient
  76413. * @param gradient defines the gradient to use (between 0 and 1)
  76414. * @param color1 defines the color to affect to the specified gradient
  76415. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  76416. * @returns the current particle system
  76417. */
  76418. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  76419. /**
  76420. * Remove a specific color gradient
  76421. * @param gradient defines the gradient to remove
  76422. * @returns the current particle system
  76423. */
  76424. removeColorGradient(gradient: number): IParticleSystem;
  76425. /**
  76426. * Adds a new size gradient
  76427. * @param gradient defines the gradient to use (between 0 and 1)
  76428. * @param factor defines the size factor to affect to the specified gradient
  76429. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  76430. * @returns the current particle system
  76431. */
  76432. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  76433. /**
  76434. * Remove a specific size gradient
  76435. * @param gradient defines the gradient to remove
  76436. * @returns the current particle system
  76437. */
  76438. removeSizeGradient(gradient: number): IParticleSystem;
  76439. /**
  76440. * Gets the current list of color gradients.
  76441. * You must use addColorGradient and removeColorGradient to udpate this list
  76442. * @returns the list of color gradients
  76443. */
  76444. getColorGradients(): Nullable<Array<ColorGradient>>;
  76445. /**
  76446. * Gets the current list of size gradients.
  76447. * You must use addSizeGradient and removeSizeGradient to udpate this list
  76448. * @returns the list of size gradients
  76449. */
  76450. getSizeGradients(): Nullable<Array<FactorGradient>>;
  76451. /**
  76452. * Gets the current list of angular speed gradients.
  76453. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  76454. * @returns the list of angular speed gradients
  76455. */
  76456. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  76457. /**
  76458. * Adds a new angular speed gradient
  76459. * @param gradient defines the gradient to use (between 0 and 1)
  76460. * @param factor defines the angular speed to affect to the specified gradient
  76461. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  76462. * @returns the current particle system
  76463. */
  76464. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  76465. /**
  76466. * Remove a specific angular speed gradient
  76467. * @param gradient defines the gradient to remove
  76468. * @returns the current particle system
  76469. */
  76470. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  76471. /**
  76472. * Gets the current list of velocity gradients.
  76473. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  76474. * @returns the list of velocity gradients
  76475. */
  76476. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  76477. /**
  76478. * Adds a new velocity gradient
  76479. * @param gradient defines the gradient to use (between 0 and 1)
  76480. * @param factor defines the velocity to affect to the specified gradient
  76481. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  76482. * @returns the current particle system
  76483. */
  76484. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  76485. /**
  76486. * Remove a specific velocity gradient
  76487. * @param gradient defines the gradient to remove
  76488. * @returns the current particle system
  76489. */
  76490. removeVelocityGradient(gradient: number): IParticleSystem;
  76491. /**
  76492. * Gets the current list of limit velocity gradients.
  76493. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  76494. * @returns the list of limit velocity gradients
  76495. */
  76496. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  76497. /**
  76498. * Adds a new limit velocity gradient
  76499. * @param gradient defines the gradient to use (between 0 and 1)
  76500. * @param factor defines the limit velocity to affect to the specified gradient
  76501. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  76502. * @returns the current particle system
  76503. */
  76504. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  76505. /**
  76506. * Remove a specific limit velocity gradient
  76507. * @param gradient defines the gradient to remove
  76508. * @returns the current particle system
  76509. */
  76510. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  76511. /**
  76512. * Adds a new drag gradient
  76513. * @param gradient defines the gradient to use (between 0 and 1)
  76514. * @param factor defines the drag to affect to the specified gradient
  76515. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  76516. * @returns the current particle system
  76517. */
  76518. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  76519. /**
  76520. * Remove a specific drag gradient
  76521. * @param gradient defines the gradient to remove
  76522. * @returns the current particle system
  76523. */
  76524. removeDragGradient(gradient: number): IParticleSystem;
  76525. /**
  76526. * Gets the current list of drag gradients.
  76527. * You must use addDragGradient and removeDragGradient to udpate this list
  76528. * @returns the list of drag gradients
  76529. */
  76530. getDragGradients(): Nullable<Array<FactorGradient>>;
  76531. /**
  76532. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  76533. * @param gradient defines the gradient to use (between 0 and 1)
  76534. * @param factor defines the emit rate to affect to the specified gradient
  76535. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  76536. * @returns the current particle system
  76537. */
  76538. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  76539. /**
  76540. * Remove a specific emit rate gradient
  76541. * @param gradient defines the gradient to remove
  76542. * @returns the current particle system
  76543. */
  76544. removeEmitRateGradient(gradient: number): IParticleSystem;
  76545. /**
  76546. * Gets the current list of emit rate gradients.
  76547. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  76548. * @returns the list of emit rate gradients
  76549. */
  76550. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  76551. /**
  76552. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  76553. * @param gradient defines the gradient to use (between 0 and 1)
  76554. * @param factor defines the start size to affect to the specified gradient
  76555. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  76556. * @returns the current particle system
  76557. */
  76558. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  76559. /**
  76560. * Remove a specific start size gradient
  76561. * @param gradient defines the gradient to remove
  76562. * @returns the current particle system
  76563. */
  76564. removeStartSizeGradient(gradient: number): IParticleSystem;
  76565. /**
  76566. * Gets the current list of start size gradients.
  76567. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  76568. * @returns the list of start size gradients
  76569. */
  76570. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  76571. /**
  76572. * Adds a new life time gradient
  76573. * @param gradient defines the gradient to use (between 0 and 1)
  76574. * @param factor defines the life time factor to affect to the specified gradient
  76575. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  76576. * @returns the current particle system
  76577. */
  76578. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  76579. /**
  76580. * Remove a specific life time gradient
  76581. * @param gradient defines the gradient to remove
  76582. * @returns the current particle system
  76583. */
  76584. removeLifeTimeGradient(gradient: number): IParticleSystem;
  76585. /**
  76586. * Gets the current list of life time gradients.
  76587. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  76588. * @returns the list of life time gradients
  76589. */
  76590. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  76591. /**
  76592. * Gets the current list of color gradients.
  76593. * You must use addColorGradient and removeColorGradient to udpate this list
  76594. * @returns the list of color gradients
  76595. */
  76596. getColorGradients(): Nullable<Array<ColorGradient>>;
  76597. /**
  76598. * Adds a new ramp gradient used to remap particle colors
  76599. * @param gradient defines the gradient to use (between 0 and 1)
  76600. * @param color defines the color to affect to the specified gradient
  76601. * @returns the current particle system
  76602. */
  76603. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  76604. /**
  76605. * Gets the current list of ramp gradients.
  76606. * You must use addRampGradient and removeRampGradient to udpate this list
  76607. * @returns the list of ramp gradients
  76608. */
  76609. getRampGradients(): Nullable<Array<Color3Gradient>>;
  76610. /** Gets or sets a boolean indicating that ramp gradients must be used
  76611. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  76612. */
  76613. useRampGradients: boolean;
  76614. /**
  76615. * Adds a new color remap gradient
  76616. * @param gradient defines the gradient to use (between 0 and 1)
  76617. * @param min defines the color remap minimal range
  76618. * @param max defines the color remap maximal range
  76619. * @returns the current particle system
  76620. */
  76621. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  76622. /**
  76623. * Gets the current list of color remap gradients.
  76624. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  76625. * @returns the list of color remap gradients
  76626. */
  76627. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  76628. /**
  76629. * Adds a new alpha remap gradient
  76630. * @param gradient defines the gradient to use (between 0 and 1)
  76631. * @param min defines the alpha remap minimal range
  76632. * @param max defines the alpha remap maximal range
  76633. * @returns the current particle system
  76634. */
  76635. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  76636. /**
  76637. * Gets the current list of alpha remap gradients.
  76638. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  76639. * @returns the list of alpha remap gradients
  76640. */
  76641. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  76642. /**
  76643. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  76644. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  76645. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  76646. * @returns the emitter
  76647. */
  76648. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  76649. /**
  76650. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  76651. * @param radius The radius of the hemisphere to emit from
  76652. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  76653. * @returns the emitter
  76654. */
  76655. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  76656. /**
  76657. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  76658. * @param radius The radius of the sphere to emit from
  76659. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  76660. * @returns the emitter
  76661. */
  76662. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  76663. /**
  76664. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  76665. * @param radius The radius of the sphere to emit from
  76666. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  76667. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  76668. * @returns the emitter
  76669. */
  76670. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  76671. /**
  76672. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  76673. * @param radius The radius of the emission cylinder
  76674. * @param height The height of the emission cylinder
  76675. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  76676. * @param directionRandomizer How much to randomize the particle direction [0-1]
  76677. * @returns the emitter
  76678. */
  76679. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  76680. /**
  76681. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  76682. * @param radius The radius of the cylinder to emit from
  76683. * @param height The height of the emission cylinder
  76684. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  76685. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  76686. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  76687. * @returns the emitter
  76688. */
  76689. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  76690. /**
  76691. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  76692. * @param radius The radius of the cone to emit from
  76693. * @param angle The base angle of the cone
  76694. * @returns the emitter
  76695. */
  76696. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  76697. /**
  76698. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  76699. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  76700. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  76701. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  76702. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  76703. * @returns the emitter
  76704. */
  76705. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  76706. /**
  76707. * Get hosting scene
  76708. * @returns the scene
  76709. */
  76710. getScene(): Scene;
  76711. }
  76712. }
  76713. declare module BABYLON {
  76714. /**
  76715. * Creates an instance based on a source mesh.
  76716. */
  76717. export class InstancedMesh extends AbstractMesh {
  76718. private _sourceMesh;
  76719. private _currentLOD;
  76720. /** @hidden */
  76721. _indexInSourceMeshInstanceArray: number;
  76722. constructor(name: string, source: Mesh);
  76723. /**
  76724. * Returns the string "InstancedMesh".
  76725. */
  76726. getClassName(): string;
  76727. /** Gets the list of lights affecting that mesh */
  76728. readonly lightSources: Light[];
  76729. _resyncLightSources(): void;
  76730. _resyncLighSource(light: Light): void;
  76731. _removeLightSource(light: Light): void;
  76732. /**
  76733. * If the source mesh receives shadows
  76734. */
  76735. readonly receiveShadows: boolean;
  76736. /**
  76737. * The material of the source mesh
  76738. */
  76739. readonly material: Nullable<Material>;
  76740. /**
  76741. * Visibility of the source mesh
  76742. */
  76743. readonly visibility: number;
  76744. /**
  76745. * Skeleton of the source mesh
  76746. */
  76747. readonly skeleton: Nullable<Skeleton>;
  76748. /**
  76749. * Rendering ground id of the source mesh
  76750. */
  76751. renderingGroupId: number;
  76752. /**
  76753. * Returns the total number of vertices (integer).
  76754. */
  76755. getTotalVertices(): number;
  76756. /**
  76757. * Returns a positive integer : the total number of indices in this mesh geometry.
  76758. * @returns the numner of indices or zero if the mesh has no geometry.
  76759. */
  76760. getTotalIndices(): number;
  76761. /**
  76762. * The source mesh of the instance
  76763. */
  76764. readonly sourceMesh: Mesh;
  76765. /**
  76766. * Is this node ready to be used/rendered
  76767. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  76768. * @return {boolean} is it ready
  76769. */
  76770. isReady(completeCheck?: boolean): boolean;
  76771. /**
  76772. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  76773. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  76774. * @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.
  76775. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  76776. */
  76777. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  76778. /**
  76779. * Sets the vertex data of the mesh geometry for the requested `kind`.
  76780. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  76781. * The `data` are either a numeric array either a Float32Array.
  76782. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  76783. * 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).
  76784. * Note that a new underlying VertexBuffer object is created each call.
  76785. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  76786. *
  76787. * Possible `kind` values :
  76788. * - VertexBuffer.PositionKind
  76789. * - VertexBuffer.UVKind
  76790. * - VertexBuffer.UV2Kind
  76791. * - VertexBuffer.UV3Kind
  76792. * - VertexBuffer.UV4Kind
  76793. * - VertexBuffer.UV5Kind
  76794. * - VertexBuffer.UV6Kind
  76795. * - VertexBuffer.ColorKind
  76796. * - VertexBuffer.MatricesIndicesKind
  76797. * - VertexBuffer.MatricesIndicesExtraKind
  76798. * - VertexBuffer.MatricesWeightsKind
  76799. * - VertexBuffer.MatricesWeightsExtraKind
  76800. *
  76801. * Returns the Mesh.
  76802. */
  76803. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  76804. /**
  76805. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  76806. * If the mesh has no geometry, it is simply returned as it is.
  76807. * The `data` are either a numeric array either a Float32Array.
  76808. * No new underlying VertexBuffer object is created.
  76809. * 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.
  76810. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  76811. *
  76812. * Possible `kind` values :
  76813. * - VertexBuffer.PositionKind
  76814. * - VertexBuffer.UVKind
  76815. * - VertexBuffer.UV2Kind
  76816. * - VertexBuffer.UV3Kind
  76817. * - VertexBuffer.UV4Kind
  76818. * - VertexBuffer.UV5Kind
  76819. * - VertexBuffer.UV6Kind
  76820. * - VertexBuffer.ColorKind
  76821. * - VertexBuffer.MatricesIndicesKind
  76822. * - VertexBuffer.MatricesIndicesExtraKind
  76823. * - VertexBuffer.MatricesWeightsKind
  76824. * - VertexBuffer.MatricesWeightsExtraKind
  76825. *
  76826. * Returns the Mesh.
  76827. */
  76828. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  76829. /**
  76830. * Sets the mesh indices.
  76831. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  76832. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  76833. * This method creates a new index buffer each call.
  76834. * Returns the Mesh.
  76835. */
  76836. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  76837. /**
  76838. * Boolean : True if the mesh owns the requested kind of data.
  76839. */
  76840. isVerticesDataPresent(kind: string): boolean;
  76841. /**
  76842. * Returns an array of indices (IndicesArray).
  76843. */
  76844. getIndices(): Nullable<IndicesArray>;
  76845. readonly _positions: Nullable<Vector3[]>;
  76846. /**
  76847. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  76848. * This means the mesh underlying bounding box and sphere are recomputed.
  76849. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  76850. * @returns the current mesh
  76851. */
  76852. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  76853. /** @hidden */
  76854. _preActivate(): InstancedMesh;
  76855. /** @hidden */
  76856. _activate(renderId: number): boolean;
  76857. /** @hidden */
  76858. _postActivate(): void;
  76859. getWorldMatrix(): Matrix;
  76860. readonly isAnInstance: boolean;
  76861. /**
  76862. * Returns the current associated LOD AbstractMesh.
  76863. */
  76864. getLOD(camera: Camera): AbstractMesh;
  76865. /** @hidden */
  76866. _syncSubMeshes(): InstancedMesh;
  76867. /** @hidden */
  76868. _generatePointsArray(): boolean;
  76869. /**
  76870. * Creates a new InstancedMesh from the current mesh.
  76871. * - name (string) : the cloned mesh name
  76872. * - newParent (optional Node) : the optional Node to parent the clone to.
  76873. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  76874. *
  76875. * Returns the clone.
  76876. */
  76877. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  76878. /**
  76879. * Disposes the InstancedMesh.
  76880. * Returns nothing.
  76881. */
  76882. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  76883. }
  76884. }
  76885. declare module BABYLON {
  76886. /**
  76887. * Defines the options associated with the creation of a shader material.
  76888. */
  76889. export interface IShaderMaterialOptions {
  76890. /**
  76891. * Does the material work in alpha blend mode
  76892. */
  76893. needAlphaBlending: boolean;
  76894. /**
  76895. * Does the material work in alpha test mode
  76896. */
  76897. needAlphaTesting: boolean;
  76898. /**
  76899. * The list of attribute names used in the shader
  76900. */
  76901. attributes: string[];
  76902. /**
  76903. * The list of unifrom names used in the shader
  76904. */
  76905. uniforms: string[];
  76906. /**
  76907. * The list of UBO names used in the shader
  76908. */
  76909. uniformBuffers: string[];
  76910. /**
  76911. * The list of sampler names used in the shader
  76912. */
  76913. samplers: string[];
  76914. /**
  76915. * The list of defines used in the shader
  76916. */
  76917. defines: string[];
  76918. }
  76919. /**
  76920. * 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.
  76921. *
  76922. * This returned material effects how the mesh will look based on the code in the shaders.
  76923. *
  76924. * @see http://doc.babylonjs.com/how_to/shader_material
  76925. */
  76926. export class ShaderMaterial extends Material {
  76927. private _shaderPath;
  76928. private _options;
  76929. private _textures;
  76930. private _textureArrays;
  76931. private _floats;
  76932. private _ints;
  76933. private _floatsArrays;
  76934. private _colors3;
  76935. private _colors3Arrays;
  76936. private _colors4;
  76937. private _vectors2;
  76938. private _vectors3;
  76939. private _vectors4;
  76940. private _matrices;
  76941. private _matrices3x3;
  76942. private _matrices2x2;
  76943. private _vectors2Arrays;
  76944. private _vectors3Arrays;
  76945. private _cachedWorldViewMatrix;
  76946. private _renderId;
  76947. /**
  76948. * Instantiate a new shader material.
  76949. * 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.
  76950. * This returned material effects how the mesh will look based on the code in the shaders.
  76951. * @see http://doc.babylonjs.com/how_to/shader_material
  76952. * @param name Define the name of the material in the scene
  76953. * @param scene Define the scene the material belongs to
  76954. * @param shaderPath Defines the route to the shader code in one of three ways:
  76955. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  76956. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  76957. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  76958. * @param options Define the options used to create the shader
  76959. */
  76960. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  76961. /**
  76962. * Gets the options used to compile the shader.
  76963. * They can be modified to trigger a new compilation
  76964. */
  76965. readonly options: IShaderMaterialOptions;
  76966. /**
  76967. * Gets the current class name of the material e.g. "ShaderMaterial"
  76968. * Mainly use in serialization.
  76969. * @returns the class name
  76970. */
  76971. getClassName(): string;
  76972. /**
  76973. * Specifies if the material will require alpha blending
  76974. * @returns a boolean specifying if alpha blending is needed
  76975. */
  76976. needAlphaBlending(): boolean;
  76977. /**
  76978. * Specifies if this material should be rendered in alpha test mode
  76979. * @returns a boolean specifying if an alpha test is needed.
  76980. */
  76981. needAlphaTesting(): boolean;
  76982. private _checkUniform;
  76983. /**
  76984. * Set a texture in the shader.
  76985. * @param name Define the name of the uniform samplers as defined in the shader
  76986. * @param texture Define the texture to bind to this sampler
  76987. * @return the material itself allowing "fluent" like uniform updates
  76988. */
  76989. setTexture(name: string, texture: Texture): ShaderMaterial;
  76990. /**
  76991. * Set a texture array in the shader.
  76992. * @param name Define the name of the uniform sampler array as defined in the shader
  76993. * @param textures Define the list of textures to bind to this sampler
  76994. * @return the material itself allowing "fluent" like uniform updates
  76995. */
  76996. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  76997. /**
  76998. * Set a float in the shader.
  76999. * @param name Define the name of the uniform as defined in the shader
  77000. * @param value Define the value to give to the uniform
  77001. * @return the material itself allowing "fluent" like uniform updates
  77002. */
  77003. setFloat(name: string, value: number): ShaderMaterial;
  77004. /**
  77005. * Set a int in the shader.
  77006. * @param name Define the name of the uniform as defined in the shader
  77007. * @param value Define the value to give to the uniform
  77008. * @return the material itself allowing "fluent" like uniform updates
  77009. */
  77010. setInt(name: string, value: number): ShaderMaterial;
  77011. /**
  77012. * Set an array of floats in the shader.
  77013. * @param name Define the name of the uniform as defined in the shader
  77014. * @param value Define the value to give to the uniform
  77015. * @return the material itself allowing "fluent" like uniform updates
  77016. */
  77017. setFloats(name: string, value: number[]): ShaderMaterial;
  77018. /**
  77019. * Set a vec3 in the shader from a Color3.
  77020. * @param name Define the name of the uniform as defined in the shader
  77021. * @param value Define the value to give to the uniform
  77022. * @return the material itself allowing "fluent" like uniform updates
  77023. */
  77024. setColor3(name: string, value: Color3): ShaderMaterial;
  77025. /**
  77026. * Set a vec3 array in the shader from a Color3 array.
  77027. * @param name Define the name of the uniform as defined in the shader
  77028. * @param value Define the value to give to the uniform
  77029. * @return the material itself allowing "fluent" like uniform updates
  77030. */
  77031. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  77032. /**
  77033. * Set a vec4 in the shader from a Color4.
  77034. * @param name Define the name of the uniform as defined in the shader
  77035. * @param value Define the value to give to the uniform
  77036. * @return the material itself allowing "fluent" like uniform updates
  77037. */
  77038. setColor4(name: string, value: Color4): ShaderMaterial;
  77039. /**
  77040. * Set a vec2 in the shader from a Vector2.
  77041. * @param name Define the name of the uniform as defined in the shader
  77042. * @param value Define the value to give to the uniform
  77043. * @return the material itself allowing "fluent" like uniform updates
  77044. */
  77045. setVector2(name: string, value: Vector2): ShaderMaterial;
  77046. /**
  77047. * Set a vec3 in the shader from a Vector3.
  77048. * @param name Define the name of the uniform as defined in the shader
  77049. * @param value Define the value to give to the uniform
  77050. * @return the material itself allowing "fluent" like uniform updates
  77051. */
  77052. setVector3(name: string, value: Vector3): ShaderMaterial;
  77053. /**
  77054. * Set a vec4 in the shader from a Vector4.
  77055. * @param name Define the name of the uniform as defined in the shader
  77056. * @param value Define the value to give to the uniform
  77057. * @return the material itself allowing "fluent" like uniform updates
  77058. */
  77059. setVector4(name: string, value: Vector4): ShaderMaterial;
  77060. /**
  77061. * Set a mat4 in the shader from a Matrix.
  77062. * @param name Define the name of the uniform as defined in the shader
  77063. * @param value Define the value to give to the uniform
  77064. * @return the material itself allowing "fluent" like uniform updates
  77065. */
  77066. setMatrix(name: string, value: Matrix): ShaderMaterial;
  77067. /**
  77068. * Set a mat3 in the shader from a Float32Array.
  77069. * @param name Define the name of the uniform as defined in the shader
  77070. * @param value Define the value to give to the uniform
  77071. * @return the material itself allowing "fluent" like uniform updates
  77072. */
  77073. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  77074. /**
  77075. * Set a mat2 in the shader from a Float32Array.
  77076. * @param name Define the name of the uniform as defined in the shader
  77077. * @param value Define the value to give to the uniform
  77078. * @return the material itself allowing "fluent" like uniform updates
  77079. */
  77080. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  77081. /**
  77082. * Set a vec2 array in the shader from a number array.
  77083. * @param name Define the name of the uniform as defined in the shader
  77084. * @param value Define the value to give to the uniform
  77085. * @return the material itself allowing "fluent" like uniform updates
  77086. */
  77087. setArray2(name: string, value: number[]): ShaderMaterial;
  77088. /**
  77089. * Set a vec3 array in the shader from a number array.
  77090. * @param name Define the name of the uniform as defined in the shader
  77091. * @param value Define the value to give to the uniform
  77092. * @return the material itself allowing "fluent" like uniform updates
  77093. */
  77094. setArray3(name: string, value: number[]): ShaderMaterial;
  77095. private _checkCache;
  77096. /**
  77097. * Specifies that the submesh is ready to be used
  77098. * @param mesh defines the mesh to check
  77099. * @param subMesh defines which submesh to check
  77100. * @param useInstances specifies that instances should be used
  77101. * @returns a boolean indicating that the submesh is ready or not
  77102. */
  77103. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  77104. /**
  77105. * Checks if the material is ready to render the requested mesh
  77106. * @param mesh Define the mesh to render
  77107. * @param useInstances Define whether or not the material is used with instances
  77108. * @returns true if ready, otherwise false
  77109. */
  77110. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  77111. /**
  77112. * Binds the world matrix to the material
  77113. * @param world defines the world transformation matrix
  77114. */
  77115. bindOnlyWorldMatrix(world: Matrix): void;
  77116. /**
  77117. * Binds the material to the mesh
  77118. * @param world defines the world transformation matrix
  77119. * @param mesh defines the mesh to bind the material to
  77120. */
  77121. bind(world: Matrix, mesh?: Mesh): void;
  77122. /**
  77123. * Gets the active textures from the material
  77124. * @returns an array of textures
  77125. */
  77126. getActiveTextures(): BaseTexture[];
  77127. /**
  77128. * Specifies if the material uses a texture
  77129. * @param texture defines the texture to check against the material
  77130. * @returns a boolean specifying if the material uses the texture
  77131. */
  77132. hasTexture(texture: BaseTexture): boolean;
  77133. /**
  77134. * Makes a duplicate of the material, and gives it a new name
  77135. * @param name defines the new name for the duplicated material
  77136. * @returns the cloned material
  77137. */
  77138. clone(name: string): ShaderMaterial;
  77139. /**
  77140. * Disposes the material
  77141. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  77142. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  77143. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  77144. */
  77145. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  77146. /**
  77147. * Serializes this material in a JSON representation
  77148. * @returns the serialized material object
  77149. */
  77150. serialize(): any;
  77151. /**
  77152. * Creates a shader material from parsed shader material data
  77153. * @param source defines the JSON represnetation of the material
  77154. * @param scene defines the hosting scene
  77155. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  77156. * @returns a new material
  77157. */
  77158. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  77159. }
  77160. }
  77161. declare module BABYLON {
  77162. /** @hidden */
  77163. export var colorPixelShader: {
  77164. name: string;
  77165. shader: string;
  77166. };
  77167. }
  77168. declare module BABYLON {
  77169. /** @hidden */
  77170. export var colorVertexShader: {
  77171. name: string;
  77172. shader: string;
  77173. };
  77174. }
  77175. declare module BABYLON {
  77176. /**
  77177. * Line mesh
  77178. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  77179. */
  77180. export class LinesMesh extends Mesh {
  77181. /**
  77182. * If vertex color should be applied to the mesh
  77183. */
  77184. useVertexColor?: boolean | undefined;
  77185. /**
  77186. * If vertex alpha should be applied to the mesh
  77187. */
  77188. useVertexAlpha?: boolean | undefined;
  77189. /**
  77190. * Color of the line (Default: White)
  77191. */
  77192. color: Color3;
  77193. /**
  77194. * Alpha of the line (Default: 1)
  77195. */
  77196. alpha: number;
  77197. /**
  77198. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  77199. * This margin is expressed in world space coordinates, so its value may vary.
  77200. * Default value is 0.1
  77201. */
  77202. intersectionThreshold: number;
  77203. private _colorShader;
  77204. /**
  77205. * Creates a new LinesMesh
  77206. * @param name defines the name
  77207. * @param scene defines the hosting scene
  77208. * @param parent defines the parent mesh if any
  77209. * @param source defines the optional source LinesMesh used to clone data from
  77210. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  77211. * When false, achieved by calling a clone(), also passing False.
  77212. * This will make creation of children, recursive.
  77213. * @param useVertexColor defines if this LinesMesh supports vertex color
  77214. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  77215. */
  77216. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  77217. /**
  77218. * If vertex color should be applied to the mesh
  77219. */
  77220. useVertexColor?: boolean | undefined,
  77221. /**
  77222. * If vertex alpha should be applied to the mesh
  77223. */
  77224. useVertexAlpha?: boolean | undefined);
  77225. private _addClipPlaneDefine;
  77226. private _removeClipPlaneDefine;
  77227. isReady(): boolean;
  77228. /**
  77229. * Returns the string "LineMesh"
  77230. */
  77231. getClassName(): string;
  77232. /**
  77233. * @hidden
  77234. */
  77235. /**
  77236. * @hidden
  77237. */
  77238. material: Material;
  77239. /**
  77240. * @hidden
  77241. */
  77242. readonly checkCollisions: boolean;
  77243. /** @hidden */
  77244. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  77245. /** @hidden */
  77246. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  77247. /**
  77248. * Disposes of the line mesh
  77249. * @param doNotRecurse If children should be disposed
  77250. */
  77251. dispose(doNotRecurse?: boolean): void;
  77252. /**
  77253. * Returns a new LineMesh object cloned from the current one.
  77254. */
  77255. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  77256. /**
  77257. * Creates a new InstancedLinesMesh object from the mesh model.
  77258. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  77259. * @param name defines the name of the new instance
  77260. * @returns a new InstancedLinesMesh
  77261. */
  77262. createInstance(name: string): InstancedLinesMesh;
  77263. }
  77264. /**
  77265. * Creates an instance based on a source LinesMesh
  77266. */
  77267. export class InstancedLinesMesh extends InstancedMesh {
  77268. /**
  77269. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  77270. * This margin is expressed in world space coordinates, so its value may vary.
  77271. * Initilized with the intersectionThreshold value of the source LinesMesh
  77272. */
  77273. intersectionThreshold: number;
  77274. constructor(name: string, source: LinesMesh);
  77275. /**
  77276. * Returns the string "InstancedLinesMesh".
  77277. */
  77278. getClassName(): string;
  77279. }
  77280. }
  77281. declare module BABYLON {
  77282. /** @hidden */
  77283. export var linePixelShader: {
  77284. name: string;
  77285. shader: string;
  77286. };
  77287. }
  77288. declare module BABYLON {
  77289. /** @hidden */
  77290. export var lineVertexShader: {
  77291. name: string;
  77292. shader: string;
  77293. };
  77294. }
  77295. declare module BABYLON {
  77296. interface AbstractMesh {
  77297. /**
  77298. * Gets the edgesRenderer associated with the mesh
  77299. */
  77300. edgesRenderer: Nullable<EdgesRenderer>;
  77301. }
  77302. interface LinesMesh {
  77303. /**
  77304. * Enables the edge rendering mode on the mesh.
  77305. * This mode makes the mesh edges visible
  77306. * @param epsilon defines the maximal distance between two angles to detect a face
  77307. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  77308. * @returns the currentAbstractMesh
  77309. * @see https://www.babylonjs-playground.com/#19O9TU#0
  77310. */
  77311. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  77312. }
  77313. interface InstancedLinesMesh {
  77314. /**
  77315. * Enables the edge rendering mode on the mesh.
  77316. * This mode makes the mesh edges visible
  77317. * @param epsilon defines the maximal distance between two angles to detect a face
  77318. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  77319. * @returns the current InstancedLinesMesh
  77320. * @see https://www.babylonjs-playground.com/#19O9TU#0
  77321. */
  77322. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  77323. }
  77324. /**
  77325. * Defines the minimum contract an Edges renderer should follow.
  77326. */
  77327. export interface IEdgesRenderer extends IDisposable {
  77328. /**
  77329. * Gets or sets a boolean indicating if the edgesRenderer is active
  77330. */
  77331. isEnabled: boolean;
  77332. /**
  77333. * Renders the edges of the attached mesh,
  77334. */
  77335. render(): void;
  77336. /**
  77337. * Checks wether or not the edges renderer is ready to render.
  77338. * @return true if ready, otherwise false.
  77339. */
  77340. isReady(): boolean;
  77341. }
  77342. /**
  77343. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  77344. */
  77345. export class EdgesRenderer implements IEdgesRenderer {
  77346. /**
  77347. * Define the size of the edges with an orthographic camera
  77348. */
  77349. edgesWidthScalerForOrthographic: number;
  77350. /**
  77351. * Define the size of the edges with a perspective camera
  77352. */
  77353. edgesWidthScalerForPerspective: number;
  77354. protected _source: AbstractMesh;
  77355. protected _linesPositions: number[];
  77356. protected _linesNormals: number[];
  77357. protected _linesIndices: number[];
  77358. protected _epsilon: number;
  77359. protected _indicesCount: number;
  77360. protected _lineShader: ShaderMaterial;
  77361. protected _ib: DataBuffer;
  77362. protected _buffers: {
  77363. [key: string]: Nullable<VertexBuffer>;
  77364. };
  77365. protected _checkVerticesInsteadOfIndices: boolean;
  77366. private _meshRebuildObserver;
  77367. private _meshDisposeObserver;
  77368. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  77369. isEnabled: boolean;
  77370. /**
  77371. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  77372. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  77373. * @param source Mesh used to create edges
  77374. * @param epsilon sum of angles in adjacency to check for edge
  77375. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  77376. * @param generateEdgesLines - should generate Lines or only prepare resources.
  77377. */
  77378. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  77379. protected _prepareRessources(): void;
  77380. /** @hidden */
  77381. _rebuild(): void;
  77382. /**
  77383. * Releases the required resources for the edges renderer
  77384. */
  77385. dispose(): void;
  77386. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  77387. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  77388. /**
  77389. * Checks if the pair of p0 and p1 is en edge
  77390. * @param faceIndex
  77391. * @param edge
  77392. * @param faceNormals
  77393. * @param p0
  77394. * @param p1
  77395. * @private
  77396. */
  77397. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  77398. /**
  77399. * push line into the position, normal and index buffer
  77400. * @protected
  77401. */
  77402. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  77403. /**
  77404. * Generates lines edges from adjacencjes
  77405. * @private
  77406. */
  77407. _generateEdgesLines(): void;
  77408. /**
  77409. * Checks wether or not the edges renderer is ready to render.
  77410. * @return true if ready, otherwise false.
  77411. */
  77412. isReady(): boolean;
  77413. /**
  77414. * Renders the edges of the attached mesh,
  77415. */
  77416. render(): void;
  77417. }
  77418. /**
  77419. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  77420. */
  77421. export class LineEdgesRenderer extends EdgesRenderer {
  77422. /**
  77423. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  77424. * @param source LineMesh used to generate edges
  77425. * @param epsilon not important (specified angle for edge detection)
  77426. * @param checkVerticesInsteadOfIndices not important for LineMesh
  77427. */
  77428. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  77429. /**
  77430. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  77431. */
  77432. _generateEdgesLines(): void;
  77433. }
  77434. }
  77435. declare module BABYLON {
  77436. /**
  77437. * This represents the object necessary to create a rendering group.
  77438. * This is exclusively used and created by the rendering manager.
  77439. * To modify the behavior, you use the available helpers in your scene or meshes.
  77440. * @hidden
  77441. */
  77442. export class RenderingGroup {
  77443. index: number;
  77444. private _scene;
  77445. private _opaqueSubMeshes;
  77446. private _transparentSubMeshes;
  77447. private _alphaTestSubMeshes;
  77448. private _depthOnlySubMeshes;
  77449. private _particleSystems;
  77450. private _spriteManagers;
  77451. private _opaqueSortCompareFn;
  77452. private _alphaTestSortCompareFn;
  77453. private _transparentSortCompareFn;
  77454. private _renderOpaque;
  77455. private _renderAlphaTest;
  77456. private _renderTransparent;
  77457. /** @hidden */
  77458. _edgesRenderers: SmartArray<IEdgesRenderer>;
  77459. onBeforeTransparentRendering: () => void;
  77460. /**
  77461. * Set the opaque sort comparison function.
  77462. * If null the sub meshes will be render in the order they were created
  77463. */
  77464. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  77465. /**
  77466. * Set the alpha test sort comparison function.
  77467. * If null the sub meshes will be render in the order they were created
  77468. */
  77469. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  77470. /**
  77471. * Set the transparent sort comparison function.
  77472. * If null the sub meshes will be render in the order they were created
  77473. */
  77474. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  77475. /**
  77476. * Creates a new rendering group.
  77477. * @param index The rendering group index
  77478. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  77479. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  77480. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  77481. */
  77482. 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>);
  77483. /**
  77484. * Render all the sub meshes contained in the group.
  77485. * @param customRenderFunction Used to override the default render behaviour of the group.
  77486. * @returns true if rendered some submeshes.
  77487. */
  77488. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  77489. /**
  77490. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  77491. * @param subMeshes The submeshes to render
  77492. */
  77493. private renderOpaqueSorted;
  77494. /**
  77495. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  77496. * @param subMeshes The submeshes to render
  77497. */
  77498. private renderAlphaTestSorted;
  77499. /**
  77500. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  77501. * @param subMeshes The submeshes to render
  77502. */
  77503. private renderTransparentSorted;
  77504. /**
  77505. * Renders the submeshes in a specified order.
  77506. * @param subMeshes The submeshes to sort before render
  77507. * @param sortCompareFn The comparison function use to sort
  77508. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  77509. * @param transparent Specifies to activate blending if true
  77510. */
  77511. private static renderSorted;
  77512. /**
  77513. * Renders the submeshes in the order they were dispatched (no sort applied).
  77514. * @param subMeshes The submeshes to render
  77515. */
  77516. private static renderUnsorted;
  77517. /**
  77518. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  77519. * are rendered back to front if in the same alpha index.
  77520. *
  77521. * @param a The first submesh
  77522. * @param b The second submesh
  77523. * @returns The result of the comparison
  77524. */
  77525. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  77526. /**
  77527. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  77528. * are rendered back to front.
  77529. *
  77530. * @param a The first submesh
  77531. * @param b The second submesh
  77532. * @returns The result of the comparison
  77533. */
  77534. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  77535. /**
  77536. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  77537. * are rendered front to back (prevent overdraw).
  77538. *
  77539. * @param a The first submesh
  77540. * @param b The second submesh
  77541. * @returns The result of the comparison
  77542. */
  77543. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  77544. /**
  77545. * Resets the different lists of submeshes to prepare a new frame.
  77546. */
  77547. prepare(): void;
  77548. dispose(): void;
  77549. /**
  77550. * Inserts the submesh in its correct queue depending on its material.
  77551. * @param subMesh The submesh to dispatch
  77552. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  77553. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  77554. */
  77555. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  77556. dispatchSprites(spriteManager: ISpriteManager): void;
  77557. dispatchParticles(particleSystem: IParticleSystem): void;
  77558. private _renderParticles;
  77559. private _renderSprites;
  77560. }
  77561. }
  77562. declare module BABYLON {
  77563. /**
  77564. * Interface describing the different options available in the rendering manager
  77565. * regarding Auto Clear between groups.
  77566. */
  77567. export interface IRenderingManagerAutoClearSetup {
  77568. /**
  77569. * Defines whether or not autoclear is enable.
  77570. */
  77571. autoClear: boolean;
  77572. /**
  77573. * Defines whether or not to autoclear the depth buffer.
  77574. */
  77575. depth: boolean;
  77576. /**
  77577. * Defines whether or not to autoclear the stencil buffer.
  77578. */
  77579. stencil: boolean;
  77580. }
  77581. /**
  77582. * This class is used by the onRenderingGroupObservable
  77583. */
  77584. export class RenderingGroupInfo {
  77585. /**
  77586. * The Scene that being rendered
  77587. */
  77588. scene: Scene;
  77589. /**
  77590. * The camera currently used for the rendering pass
  77591. */
  77592. camera: Nullable<Camera>;
  77593. /**
  77594. * The ID of the renderingGroup being processed
  77595. */
  77596. renderingGroupId: number;
  77597. }
  77598. /**
  77599. * This is the manager responsible of all the rendering for meshes sprites and particles.
  77600. * It is enable to manage the different groups as well as the different necessary sort functions.
  77601. * This should not be used directly aside of the few static configurations
  77602. */
  77603. export class RenderingManager {
  77604. /**
  77605. * The max id used for rendering groups (not included)
  77606. */
  77607. static MAX_RENDERINGGROUPS: number;
  77608. /**
  77609. * The min id used for rendering groups (included)
  77610. */
  77611. static MIN_RENDERINGGROUPS: number;
  77612. /**
  77613. * Used to globally prevent autoclearing scenes.
  77614. */
  77615. static AUTOCLEAR: boolean;
  77616. /**
  77617. * @hidden
  77618. */
  77619. _useSceneAutoClearSetup: boolean;
  77620. private _scene;
  77621. private _renderingGroups;
  77622. private _depthStencilBufferAlreadyCleaned;
  77623. private _autoClearDepthStencil;
  77624. private _customOpaqueSortCompareFn;
  77625. private _customAlphaTestSortCompareFn;
  77626. private _customTransparentSortCompareFn;
  77627. private _renderingGroupInfo;
  77628. /**
  77629. * Instantiates a new rendering group for a particular scene
  77630. * @param scene Defines the scene the groups belongs to
  77631. */
  77632. constructor(scene: Scene);
  77633. private _clearDepthStencilBuffer;
  77634. /**
  77635. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  77636. * @hidden
  77637. */
  77638. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  77639. /**
  77640. * Resets the different information of the group to prepare a new frame
  77641. * @hidden
  77642. */
  77643. reset(): void;
  77644. /**
  77645. * Dispose and release the group and its associated resources.
  77646. * @hidden
  77647. */
  77648. dispose(): void;
  77649. /**
  77650. * Clear the info related to rendering groups preventing retention points during dispose.
  77651. */
  77652. freeRenderingGroups(): void;
  77653. private _prepareRenderingGroup;
  77654. /**
  77655. * Add a sprite manager to the rendering manager in order to render it this frame.
  77656. * @param spriteManager Define the sprite manager to render
  77657. */
  77658. dispatchSprites(spriteManager: ISpriteManager): void;
  77659. /**
  77660. * Add a particle system to the rendering manager in order to render it this frame.
  77661. * @param particleSystem Define the particle system to render
  77662. */
  77663. dispatchParticles(particleSystem: IParticleSystem): void;
  77664. /**
  77665. * Add a submesh to the manager in order to render it this frame
  77666. * @param subMesh The submesh to dispatch
  77667. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  77668. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  77669. */
  77670. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  77671. /**
  77672. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  77673. * This allowed control for front to back rendering or reversly depending of the special needs.
  77674. *
  77675. * @param renderingGroupId The rendering group id corresponding to its index
  77676. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  77677. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  77678. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  77679. */
  77680. 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;
  77681. /**
  77682. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  77683. *
  77684. * @param renderingGroupId The rendering group id corresponding to its index
  77685. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  77686. * @param depth Automatically clears depth between groups if true and autoClear is true.
  77687. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  77688. */
  77689. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  77690. /**
  77691. * Gets the current auto clear configuration for one rendering group of the rendering
  77692. * manager.
  77693. * @param index the rendering group index to get the information for
  77694. * @returns The auto clear setup for the requested rendering group
  77695. */
  77696. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  77697. }
  77698. }
  77699. declare module BABYLON {
  77700. /**
  77701. * This Helps creating a texture that will be created from a camera in your scene.
  77702. * It is basically a dynamic texture that could be used to create special effects for instance.
  77703. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  77704. */
  77705. export class RenderTargetTexture extends Texture {
  77706. isCube: boolean;
  77707. /**
  77708. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  77709. */
  77710. static readonly REFRESHRATE_RENDER_ONCE: number;
  77711. /**
  77712. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  77713. */
  77714. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  77715. /**
  77716. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  77717. * the central point of your effect and can save a lot of performances.
  77718. */
  77719. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  77720. /**
  77721. * Use this predicate to dynamically define the list of mesh you want to render.
  77722. * If set, the renderList property will be overwritten.
  77723. */
  77724. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  77725. private _renderList;
  77726. /**
  77727. * Use this list to define the list of mesh you want to render.
  77728. */
  77729. renderList: Nullable<Array<AbstractMesh>>;
  77730. private _hookArray;
  77731. /**
  77732. * Define if particles should be rendered in your texture.
  77733. */
  77734. renderParticles: boolean;
  77735. /**
  77736. * Define if sprites should be rendered in your texture.
  77737. */
  77738. renderSprites: boolean;
  77739. /**
  77740. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  77741. */
  77742. coordinatesMode: number;
  77743. /**
  77744. * Define the camera used to render the texture.
  77745. */
  77746. activeCamera: Nullable<Camera>;
  77747. /**
  77748. * Override the render function of the texture with your own one.
  77749. */
  77750. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  77751. /**
  77752. * Define if camera post processes should be use while rendering the texture.
  77753. */
  77754. useCameraPostProcesses: boolean;
  77755. /**
  77756. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  77757. */
  77758. ignoreCameraViewport: boolean;
  77759. private _postProcessManager;
  77760. private _postProcesses;
  77761. private _resizeObserver;
  77762. /**
  77763. * An event triggered when the texture is unbind.
  77764. */
  77765. onBeforeBindObservable: Observable<RenderTargetTexture>;
  77766. /**
  77767. * An event triggered when the texture is unbind.
  77768. */
  77769. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  77770. private _onAfterUnbindObserver;
  77771. /**
  77772. * Set a after unbind callback in the texture.
  77773. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  77774. */
  77775. onAfterUnbind: () => void;
  77776. /**
  77777. * An event triggered before rendering the texture
  77778. */
  77779. onBeforeRenderObservable: Observable<number>;
  77780. private _onBeforeRenderObserver;
  77781. /**
  77782. * Set a before render callback in the texture.
  77783. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  77784. */
  77785. onBeforeRender: (faceIndex: number) => void;
  77786. /**
  77787. * An event triggered after rendering the texture
  77788. */
  77789. onAfterRenderObservable: Observable<number>;
  77790. private _onAfterRenderObserver;
  77791. /**
  77792. * Set a after render callback in the texture.
  77793. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  77794. */
  77795. onAfterRender: (faceIndex: number) => void;
  77796. /**
  77797. * An event triggered after the texture clear
  77798. */
  77799. onClearObservable: Observable<Engine>;
  77800. private _onClearObserver;
  77801. /**
  77802. * Set a clear callback in the texture.
  77803. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  77804. */
  77805. onClear: (Engine: Engine) => void;
  77806. /**
  77807. * Define the clear color of the Render Target if it should be different from the scene.
  77808. */
  77809. clearColor: Color4;
  77810. protected _size: number | {
  77811. width: number;
  77812. height: number;
  77813. };
  77814. protected _initialSizeParameter: number | {
  77815. width: number;
  77816. height: number;
  77817. } | {
  77818. ratio: number;
  77819. };
  77820. protected _sizeRatio: Nullable<number>;
  77821. /** @hidden */
  77822. _generateMipMaps: boolean;
  77823. protected _renderingManager: RenderingManager;
  77824. /** @hidden */
  77825. _waitingRenderList: string[];
  77826. protected _doNotChangeAspectRatio: boolean;
  77827. protected _currentRefreshId: number;
  77828. protected _refreshRate: number;
  77829. protected _textureMatrix: Matrix;
  77830. protected _samples: number;
  77831. protected _renderTargetOptions: RenderTargetCreationOptions;
  77832. /**
  77833. * Gets render target creation options that were used.
  77834. */
  77835. readonly renderTargetOptions: RenderTargetCreationOptions;
  77836. protected _engine: Engine;
  77837. protected _onRatioRescale(): void;
  77838. /**
  77839. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  77840. * It must define where the camera used to render the texture is set
  77841. */
  77842. boundingBoxPosition: Vector3;
  77843. private _boundingBoxSize;
  77844. /**
  77845. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  77846. * When defined, the cubemap will switch to local mode
  77847. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  77848. * @example https://www.babylonjs-playground.com/#RNASML
  77849. */
  77850. boundingBoxSize: Vector3;
  77851. /**
  77852. * In case the RTT has been created with a depth texture, get the associated
  77853. * depth texture.
  77854. * Otherwise, return null.
  77855. */
  77856. depthStencilTexture: Nullable<InternalTexture>;
  77857. /**
  77858. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  77859. * or used a shadow, depth texture...
  77860. * @param name The friendly name of the texture
  77861. * @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)
  77862. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  77863. * @param generateMipMaps True if mip maps need to be generated after render.
  77864. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  77865. * @param type The type of the buffer in the RTT (int, half float, float...)
  77866. * @param isCube True if a cube texture needs to be created
  77867. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  77868. * @param generateDepthBuffer True to generate a depth buffer
  77869. * @param generateStencilBuffer True to generate a stencil buffer
  77870. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  77871. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  77872. * @param delayAllocation if the texture allocation should be delayed (default: false)
  77873. */
  77874. constructor(name: string, size: number | {
  77875. width: number;
  77876. height: number;
  77877. } | {
  77878. ratio: number;
  77879. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  77880. /**
  77881. * Creates a depth stencil texture.
  77882. * This is only available in WebGL 2 or with the depth texture extension available.
  77883. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  77884. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  77885. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  77886. */
  77887. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  77888. private _processSizeParameter;
  77889. /**
  77890. * Define the number of samples to use in case of MSAA.
  77891. * It defaults to one meaning no MSAA has been enabled.
  77892. */
  77893. samples: number;
  77894. /**
  77895. * Resets the refresh counter of the texture and start bak from scratch.
  77896. * Could be useful to regenerate the texture if it is setup to render only once.
  77897. */
  77898. resetRefreshCounter(): void;
  77899. /**
  77900. * Define the refresh rate of the texture or the rendering frequency.
  77901. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  77902. */
  77903. refreshRate: number;
  77904. /**
  77905. * Adds a post process to the render target rendering passes.
  77906. * @param postProcess define the post process to add
  77907. */
  77908. addPostProcess(postProcess: PostProcess): void;
  77909. /**
  77910. * Clear all the post processes attached to the render target
  77911. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  77912. */
  77913. clearPostProcesses(dispose?: boolean): void;
  77914. /**
  77915. * Remove one of the post process from the list of attached post processes to the texture
  77916. * @param postProcess define the post process to remove from the list
  77917. */
  77918. removePostProcess(postProcess: PostProcess): void;
  77919. /** @hidden */
  77920. _shouldRender(): boolean;
  77921. /**
  77922. * Gets the actual render size of the texture.
  77923. * @returns the width of the render size
  77924. */
  77925. getRenderSize(): number;
  77926. /**
  77927. * Gets the actual render width of the texture.
  77928. * @returns the width of the render size
  77929. */
  77930. getRenderWidth(): number;
  77931. /**
  77932. * Gets the actual render height of the texture.
  77933. * @returns the height of the render size
  77934. */
  77935. getRenderHeight(): number;
  77936. /**
  77937. * Get if the texture can be rescaled or not.
  77938. */
  77939. readonly canRescale: boolean;
  77940. /**
  77941. * Resize the texture using a ratio.
  77942. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  77943. */
  77944. scale(ratio: number): void;
  77945. /**
  77946. * Get the texture reflection matrix used to rotate/transform the reflection.
  77947. * @returns the reflection matrix
  77948. */
  77949. getReflectionTextureMatrix(): Matrix;
  77950. /**
  77951. * Resize the texture to a new desired size.
  77952. * Be carrefull as it will recreate all the data in the new texture.
  77953. * @param size Define the new size. It can be:
  77954. * - a number for squared texture,
  77955. * - an object containing { width: number, height: number }
  77956. * - or an object containing a ratio { ratio: number }
  77957. */
  77958. resize(size: number | {
  77959. width: number;
  77960. height: number;
  77961. } | {
  77962. ratio: number;
  77963. }): void;
  77964. /**
  77965. * Renders all the objects from the render list into the texture.
  77966. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  77967. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  77968. */
  77969. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  77970. private _bestReflectionRenderTargetDimension;
  77971. /**
  77972. * @hidden
  77973. * @param faceIndex face index to bind to if this is a cubetexture
  77974. */
  77975. _bindFrameBuffer(faceIndex?: number): void;
  77976. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  77977. private renderToTarget;
  77978. /**
  77979. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  77980. * This allowed control for front to back rendering or reversly depending of the special needs.
  77981. *
  77982. * @param renderingGroupId The rendering group id corresponding to its index
  77983. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  77984. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  77985. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  77986. */
  77987. 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;
  77988. /**
  77989. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  77990. *
  77991. * @param renderingGroupId The rendering group id corresponding to its index
  77992. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  77993. */
  77994. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  77995. /**
  77996. * Clones the texture.
  77997. * @returns the cloned texture
  77998. */
  77999. clone(): RenderTargetTexture;
  78000. /**
  78001. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  78002. * @returns The JSON representation of the texture
  78003. */
  78004. serialize(): any;
  78005. /**
  78006. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  78007. */
  78008. disposeFramebufferObjects(): void;
  78009. /**
  78010. * Dispose the texture and release its associated resources.
  78011. */
  78012. dispose(): void;
  78013. /** @hidden */
  78014. _rebuild(): void;
  78015. /**
  78016. * Clear the info related to rendering groups preventing retention point in material dispose.
  78017. */
  78018. freeRenderingGroups(): void;
  78019. /**
  78020. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  78021. * @returns the view count
  78022. */
  78023. getViewCount(): number;
  78024. }
  78025. }
  78026. declare module BABYLON {
  78027. /**
  78028. * Mirror texture can be used to simulate the view from a mirror in a scene.
  78029. * It will dynamically be rendered every frame to adapt to the camera point of view.
  78030. * You can then easily use it as a reflectionTexture on a flat surface.
  78031. * In case the surface is not a plane, please consider relying on reflection probes.
  78032. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  78033. */
  78034. export class MirrorTexture extends RenderTargetTexture {
  78035. private scene;
  78036. /**
  78037. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  78038. * 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.
  78039. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  78040. */
  78041. mirrorPlane: Plane;
  78042. /**
  78043. * Define the blur ratio used to blur the reflection if needed.
  78044. */
  78045. blurRatio: number;
  78046. /**
  78047. * Define the adaptive blur kernel used to blur the reflection if needed.
  78048. * This will autocompute the closest best match for the `blurKernel`
  78049. */
  78050. adaptiveBlurKernel: number;
  78051. /**
  78052. * Define the blur kernel used to blur the reflection if needed.
  78053. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  78054. */
  78055. blurKernel: number;
  78056. /**
  78057. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  78058. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  78059. */
  78060. blurKernelX: number;
  78061. /**
  78062. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  78063. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  78064. */
  78065. blurKernelY: number;
  78066. private _autoComputeBlurKernel;
  78067. protected _onRatioRescale(): void;
  78068. private _updateGammaSpace;
  78069. private _imageProcessingConfigChangeObserver;
  78070. private _transformMatrix;
  78071. private _mirrorMatrix;
  78072. private _savedViewMatrix;
  78073. private _blurX;
  78074. private _blurY;
  78075. private _adaptiveBlurKernel;
  78076. private _blurKernelX;
  78077. private _blurKernelY;
  78078. private _blurRatio;
  78079. /**
  78080. * Instantiates a Mirror Texture.
  78081. * Mirror texture can be used to simulate the view from a mirror in a scene.
  78082. * It will dynamically be rendered every frame to adapt to the camera point of view.
  78083. * You can then easily use it as a reflectionTexture on a flat surface.
  78084. * In case the surface is not a plane, please consider relying on reflection probes.
  78085. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  78086. * @param name
  78087. * @param size
  78088. * @param scene
  78089. * @param generateMipMaps
  78090. * @param type
  78091. * @param samplingMode
  78092. * @param generateDepthBuffer
  78093. */
  78094. constructor(name: string, size: number | {
  78095. width: number;
  78096. height: number;
  78097. } | {
  78098. ratio: number;
  78099. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  78100. private _preparePostProcesses;
  78101. /**
  78102. * Clone the mirror texture.
  78103. * @returns the cloned texture
  78104. */
  78105. clone(): MirrorTexture;
  78106. /**
  78107. * Serialize the texture to a JSON representation you could use in Parse later on
  78108. * @returns the serialized JSON representation
  78109. */
  78110. serialize(): any;
  78111. /**
  78112. * Dispose the texture and release its associated resources.
  78113. */
  78114. dispose(): void;
  78115. }
  78116. }
  78117. declare module BABYLON {
  78118. /**
  78119. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  78120. * @see http://doc.babylonjs.com/babylon101/materials#texture
  78121. */
  78122. export class Texture extends BaseTexture {
  78123. /** @hidden */
  78124. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  78125. /** @hidden */
  78126. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  78127. /** @hidden */
  78128. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  78129. /** nearest is mag = nearest and min = nearest and mip = linear */
  78130. static readonly NEAREST_SAMPLINGMODE: number;
  78131. /** nearest is mag = nearest and min = nearest and mip = linear */
  78132. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  78133. /** Bilinear is mag = linear and min = linear and mip = nearest */
  78134. static readonly BILINEAR_SAMPLINGMODE: number;
  78135. /** Bilinear is mag = linear and min = linear and mip = nearest */
  78136. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  78137. /** Trilinear is mag = linear and min = linear and mip = linear */
  78138. static readonly TRILINEAR_SAMPLINGMODE: number;
  78139. /** Trilinear is mag = linear and min = linear and mip = linear */
  78140. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  78141. /** mag = nearest and min = nearest and mip = nearest */
  78142. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  78143. /** mag = nearest and min = linear and mip = nearest */
  78144. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  78145. /** mag = nearest and min = linear and mip = linear */
  78146. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  78147. /** mag = nearest and min = linear and mip = none */
  78148. static readonly NEAREST_LINEAR: number;
  78149. /** mag = nearest and min = nearest and mip = none */
  78150. static readonly NEAREST_NEAREST: number;
  78151. /** mag = linear and min = nearest and mip = nearest */
  78152. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  78153. /** mag = linear and min = nearest and mip = linear */
  78154. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  78155. /** mag = linear and min = linear and mip = none */
  78156. static readonly LINEAR_LINEAR: number;
  78157. /** mag = linear and min = nearest and mip = none */
  78158. static readonly LINEAR_NEAREST: number;
  78159. /** Explicit coordinates mode */
  78160. static readonly EXPLICIT_MODE: number;
  78161. /** Spherical coordinates mode */
  78162. static readonly SPHERICAL_MODE: number;
  78163. /** Planar coordinates mode */
  78164. static readonly PLANAR_MODE: number;
  78165. /** Cubic coordinates mode */
  78166. static readonly CUBIC_MODE: number;
  78167. /** Projection coordinates mode */
  78168. static readonly PROJECTION_MODE: number;
  78169. /** Inverse Cubic coordinates mode */
  78170. static readonly SKYBOX_MODE: number;
  78171. /** Inverse Cubic coordinates mode */
  78172. static readonly INVCUBIC_MODE: number;
  78173. /** Equirectangular coordinates mode */
  78174. static readonly EQUIRECTANGULAR_MODE: number;
  78175. /** Equirectangular Fixed coordinates mode */
  78176. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  78177. /** Equirectangular Fixed Mirrored coordinates mode */
  78178. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  78179. /** Texture is not repeating outside of 0..1 UVs */
  78180. static readonly CLAMP_ADDRESSMODE: number;
  78181. /** Texture is repeating outside of 0..1 UVs */
  78182. static readonly WRAP_ADDRESSMODE: number;
  78183. /** Texture is repeating and mirrored */
  78184. static readonly MIRROR_ADDRESSMODE: number;
  78185. /**
  78186. * 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
  78187. */
  78188. static UseSerializedUrlIfAny: boolean;
  78189. /**
  78190. * Define the url of the texture.
  78191. */
  78192. url: Nullable<string>;
  78193. /**
  78194. * Define an offset on the texture to offset the u coordinates of the UVs
  78195. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  78196. */
  78197. uOffset: number;
  78198. /**
  78199. * Define an offset on the texture to offset the v coordinates of the UVs
  78200. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  78201. */
  78202. vOffset: number;
  78203. /**
  78204. * Define an offset on the texture to scale the u coordinates of the UVs
  78205. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  78206. */
  78207. uScale: number;
  78208. /**
  78209. * Define an offset on the texture to scale the v coordinates of the UVs
  78210. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  78211. */
  78212. vScale: number;
  78213. /**
  78214. * Define an offset on the texture to rotate around the u coordinates of the UVs
  78215. * @see http://doc.babylonjs.com/how_to/more_materials
  78216. */
  78217. uAng: number;
  78218. /**
  78219. * Define an offset on the texture to rotate around the v coordinates of the UVs
  78220. * @see http://doc.babylonjs.com/how_to/more_materials
  78221. */
  78222. vAng: number;
  78223. /**
  78224. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  78225. * @see http://doc.babylonjs.com/how_to/more_materials
  78226. */
  78227. wAng: number;
  78228. /**
  78229. * Defines the center of rotation (U)
  78230. */
  78231. uRotationCenter: number;
  78232. /**
  78233. * Defines the center of rotation (V)
  78234. */
  78235. vRotationCenter: number;
  78236. /**
  78237. * Defines the center of rotation (W)
  78238. */
  78239. wRotationCenter: number;
  78240. /**
  78241. * Are mip maps generated for this texture or not.
  78242. */
  78243. readonly noMipmap: boolean;
  78244. /**
  78245. * List of inspectable custom properties (used by the Inspector)
  78246. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  78247. */
  78248. inspectableCustomProperties: Nullable<IInspectable[]>;
  78249. private _noMipmap;
  78250. /** @hidden */
  78251. _invertY: boolean;
  78252. private _rowGenerationMatrix;
  78253. private _cachedTextureMatrix;
  78254. private _projectionModeMatrix;
  78255. private _t0;
  78256. private _t1;
  78257. private _t2;
  78258. private _cachedUOffset;
  78259. private _cachedVOffset;
  78260. private _cachedUScale;
  78261. private _cachedVScale;
  78262. private _cachedUAng;
  78263. private _cachedVAng;
  78264. private _cachedWAng;
  78265. private _cachedProjectionMatrixId;
  78266. private _cachedCoordinatesMode;
  78267. /** @hidden */
  78268. protected _initialSamplingMode: number;
  78269. /** @hidden */
  78270. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  78271. private _deleteBuffer;
  78272. protected _format: Nullable<number>;
  78273. private _delayedOnLoad;
  78274. private _delayedOnError;
  78275. /**
  78276. * Observable triggered once the texture has been loaded.
  78277. */
  78278. onLoadObservable: Observable<Texture>;
  78279. protected _isBlocking: boolean;
  78280. /**
  78281. * Is the texture preventing material to render while loading.
  78282. * If false, a default texture will be used instead of the loading one during the preparation step.
  78283. */
  78284. isBlocking: boolean;
  78285. /**
  78286. * Get the current sampling mode associated with the texture.
  78287. */
  78288. readonly samplingMode: number;
  78289. /**
  78290. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  78291. */
  78292. readonly invertY: boolean;
  78293. /**
  78294. * Instantiates a new texture.
  78295. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  78296. * @see http://doc.babylonjs.com/babylon101/materials#texture
  78297. * @param url define the url of the picture to load as a texture
  78298. * @param scene define the scene the texture will belong to
  78299. * @param noMipmap define if the texture will require mip maps or not
  78300. * @param invertY define if the texture needs to be inverted on the y axis during loading
  78301. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  78302. * @param onLoad define a callback triggered when the texture has been loaded
  78303. * @param onError define a callback triggered when an error occurred during the loading session
  78304. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  78305. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  78306. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  78307. */
  78308. 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);
  78309. /**
  78310. * Update the url (and optional buffer) of this texture if url was null during construction.
  78311. * @param url the url of the texture
  78312. * @param buffer the buffer of the texture (defaults to null)
  78313. * @param onLoad callback called when the texture is loaded (defaults to null)
  78314. */
  78315. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  78316. /**
  78317. * Finish the loading sequence of a texture flagged as delayed load.
  78318. * @hidden
  78319. */
  78320. delayLoad(): void;
  78321. private _prepareRowForTextureGeneration;
  78322. /**
  78323. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  78324. * @returns the transform matrix of the texture.
  78325. */
  78326. getTextureMatrix(): Matrix;
  78327. /**
  78328. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  78329. * @returns The reflection texture transform
  78330. */
  78331. getReflectionTextureMatrix(): Matrix;
  78332. /**
  78333. * Clones the texture.
  78334. * @returns the cloned texture
  78335. */
  78336. clone(): Texture;
  78337. /**
  78338. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  78339. * @returns The JSON representation of the texture
  78340. */
  78341. serialize(): any;
  78342. /**
  78343. * Get the current class name of the texture useful for serialization or dynamic coding.
  78344. * @returns "Texture"
  78345. */
  78346. getClassName(): string;
  78347. /**
  78348. * Dispose the texture and release its associated resources.
  78349. */
  78350. dispose(): void;
  78351. /**
  78352. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  78353. * @param parsedTexture Define the JSON representation of the texture
  78354. * @param scene Define the scene the parsed texture should be instantiated in
  78355. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  78356. * @returns The parsed texture if successful
  78357. */
  78358. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  78359. /**
  78360. * Creates a texture from its base 64 representation.
  78361. * @param data Define the base64 payload without the data: prefix
  78362. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  78363. * @param scene Define the scene the texture should belong to
  78364. * @param noMipmap Forces the texture to not create mip map information if true
  78365. * @param invertY define if the texture needs to be inverted on the y axis during loading
  78366. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  78367. * @param onLoad define a callback triggered when the texture has been loaded
  78368. * @param onError define a callback triggered when an error occurred during the loading session
  78369. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  78370. * @returns the created texture
  78371. */
  78372. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  78373. /**
  78374. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  78375. * @param data Define the base64 payload without the data: prefix
  78376. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  78377. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  78378. * @param scene Define the scene the texture should belong to
  78379. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  78380. * @param noMipmap Forces the texture to not create mip map information if true
  78381. * @param invertY define if the texture needs to be inverted on the y axis during loading
  78382. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  78383. * @param onLoad define a callback triggered when the texture has been loaded
  78384. * @param onError define a callback triggered when an error occurred during the loading session
  78385. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  78386. * @returns the created texture
  78387. */
  78388. 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;
  78389. }
  78390. }
  78391. declare module BABYLON {
  78392. interface Engine {
  78393. /**
  78394. * Creates a raw texture
  78395. * @param data defines the data to store in the texture
  78396. * @param width defines the width of the texture
  78397. * @param height defines the height of the texture
  78398. * @param format defines the format of the data
  78399. * @param generateMipMaps defines if the engine should generate the mip levels
  78400. * @param invertY defines if data must be stored with Y axis inverted
  78401. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  78402. * @param compression defines the compression used (null by default)
  78403. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78404. * @returns the raw texture inside an InternalTexture
  78405. */
  78406. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  78407. /**
  78408. * Update a raw texture
  78409. * @param texture defines the texture to update
  78410. * @param data defines the data to store in the texture
  78411. * @param format defines the format of the data
  78412. * @param invertY defines if data must be stored with Y axis inverted
  78413. */
  78414. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  78415. /**
  78416. * Update a raw texture
  78417. * @param texture defines the texture to update
  78418. * @param data defines the data to store in the texture
  78419. * @param format defines the format of the data
  78420. * @param invertY defines if data must be stored with Y axis inverted
  78421. * @param compression defines the compression used (null by default)
  78422. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78423. */
  78424. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  78425. /**
  78426. * Creates a new raw cube texture
  78427. * @param data defines the array of data to use to create each face
  78428. * @param size defines the size of the textures
  78429. * @param format defines the format of the data
  78430. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  78431. * @param generateMipMaps defines if the engine should generate the mip levels
  78432. * @param invertY defines if data must be stored with Y axis inverted
  78433. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  78434. * @param compression defines the compression used (null by default)
  78435. * @returns the cube texture as an InternalTexture
  78436. */
  78437. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  78438. /**
  78439. * Update a raw cube texture
  78440. * @param texture defines the texture to udpdate
  78441. * @param data defines the data to store
  78442. * @param format defines the data format
  78443. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78444. * @param invertY defines if data must be stored with Y axis inverted
  78445. */
  78446. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  78447. /**
  78448. * Update a raw cube texture
  78449. * @param texture defines the texture to udpdate
  78450. * @param data defines the data to store
  78451. * @param format defines the data format
  78452. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78453. * @param invertY defines if data must be stored with Y axis inverted
  78454. * @param compression defines the compression used (null by default)
  78455. */
  78456. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  78457. /**
  78458. * Update a raw cube texture
  78459. * @param texture defines the texture to udpdate
  78460. * @param data defines the data to store
  78461. * @param format defines the data format
  78462. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78463. * @param invertY defines if data must be stored with Y axis inverted
  78464. * @param compression defines the compression used (null by default)
  78465. * @param level defines which level of the texture to update
  78466. */
  78467. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  78468. /**
  78469. * Creates a new raw cube texture from a specified url
  78470. * @param url defines the url where the data is located
  78471. * @param scene defines the current scene
  78472. * @param size defines the size of the textures
  78473. * @param format defines the format of the data
  78474. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  78475. * @param noMipmap defines if the engine should avoid generating the mip levels
  78476. * @param callback defines a callback used to extract texture data from loaded data
  78477. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  78478. * @param onLoad defines a callback called when texture is loaded
  78479. * @param onError defines a callback called if there is an error
  78480. * @returns the cube texture as an InternalTexture
  78481. */
  78482. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>): InternalTexture;
  78483. /**
  78484. * Creates a new raw cube texture from a specified url
  78485. * @param url defines the url where the data is located
  78486. * @param scene defines the current scene
  78487. * @param size defines the size of the textures
  78488. * @param format defines the format of the data
  78489. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  78490. * @param noMipmap defines if the engine should avoid generating the mip levels
  78491. * @param callback defines a callback used to extract texture data from loaded data
  78492. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  78493. * @param onLoad defines a callback called when texture is loaded
  78494. * @param onError defines a callback called if there is an error
  78495. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  78496. * @param invertY defines if data must be stored with Y axis inverted
  78497. * @returns the cube texture as an InternalTexture
  78498. */
  78499. 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;
  78500. /**
  78501. * Creates a new raw 3D texture
  78502. * @param data defines the data used to create the texture
  78503. * @param width defines the width of the texture
  78504. * @param height defines the height of the texture
  78505. * @param depth defines the depth of the texture
  78506. * @param format defines the format of the texture
  78507. * @param generateMipMaps defines if the engine must generate mip levels
  78508. * @param invertY defines if data must be stored with Y axis inverted
  78509. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  78510. * @param compression defines the compressed used (can be null)
  78511. * @param textureType defines the compressed used (can be null)
  78512. * @returns a new raw 3D texture (stored in an InternalTexture)
  78513. */
  78514. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  78515. /**
  78516. * Update a raw 3D texture
  78517. * @param texture defines the texture to update
  78518. * @param data defines the data to store
  78519. * @param format defines the data format
  78520. * @param invertY defines if data must be stored with Y axis inverted
  78521. */
  78522. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  78523. /**
  78524. * Update a raw 3D texture
  78525. * @param texture defines the texture to update
  78526. * @param data defines the data to store
  78527. * @param format defines the data format
  78528. * @param invertY defines if data must be stored with Y axis inverted
  78529. * @param compression defines the used compression (can be null)
  78530. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  78531. */
  78532. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  78533. }
  78534. }
  78535. declare module BABYLON {
  78536. /**
  78537. * Raw texture can help creating a texture directly from an array of data.
  78538. * This can be super useful if you either get the data from an uncompressed source or
  78539. * if you wish to create your texture pixel by pixel.
  78540. */
  78541. export class RawTexture extends Texture {
  78542. /**
  78543. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  78544. */
  78545. format: number;
  78546. private _engine;
  78547. /**
  78548. * Instantiates a new RawTexture.
  78549. * Raw texture can help creating a texture directly from an array of data.
  78550. * This can be super useful if you either get the data from an uncompressed source or
  78551. * if you wish to create your texture pixel by pixel.
  78552. * @param data define the array of data to use to create the texture
  78553. * @param width define the width of the texture
  78554. * @param height define the height of the texture
  78555. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  78556. * @param scene define the scene the texture belongs to
  78557. * @param generateMipMaps define whether mip maps should be generated or not
  78558. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78559. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78560. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  78561. */
  78562. constructor(data: ArrayBufferView, width: number, height: number,
  78563. /**
  78564. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  78565. */
  78566. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  78567. /**
  78568. * Updates the texture underlying data.
  78569. * @param data Define the new data of the texture
  78570. */
  78571. update(data: ArrayBufferView): void;
  78572. /**
  78573. * Creates a luminance texture from some data.
  78574. * @param data Define the texture data
  78575. * @param width Define the width of the texture
  78576. * @param height Define the height of the texture
  78577. * @param scene Define the scene the texture belongs to
  78578. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78579. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78580. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78581. * @returns the luminance texture
  78582. */
  78583. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  78584. /**
  78585. * Creates a luminance alpha texture from some data.
  78586. * @param data Define the texture data
  78587. * @param width Define the width of the texture
  78588. * @param height Define the height of the texture
  78589. * @param scene Define the scene the texture belongs to
  78590. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78591. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78592. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78593. * @returns the luminance alpha texture
  78594. */
  78595. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  78596. /**
  78597. * Creates an alpha texture from some data.
  78598. * @param data Define the texture data
  78599. * @param width Define the width of the texture
  78600. * @param height Define the height of the texture
  78601. * @param scene Define the scene the texture belongs to
  78602. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78603. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78604. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78605. * @returns the alpha texture
  78606. */
  78607. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  78608. /**
  78609. * Creates a RGB texture from some data.
  78610. * @param data Define the texture data
  78611. * @param width Define the width of the texture
  78612. * @param height Define the height of the texture
  78613. * @param scene Define the scene the texture belongs to
  78614. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78615. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78616. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78617. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  78618. * @returns the RGB alpha texture
  78619. */
  78620. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  78621. /**
  78622. * Creates a RGBA texture from some data.
  78623. * @param data Define the texture data
  78624. * @param width Define the width of the texture
  78625. * @param height Define the height of the texture
  78626. * @param scene Define the scene the texture belongs to
  78627. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78628. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78629. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78630. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  78631. * @returns the RGBA texture
  78632. */
  78633. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  78634. /**
  78635. * Creates a R texture from some data.
  78636. * @param data Define the texture data
  78637. * @param width Define the width of the texture
  78638. * @param height Define the height of the texture
  78639. * @param scene Define the scene the texture belongs to
  78640. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78641. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78642. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78643. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  78644. * @returns the R texture
  78645. */
  78646. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  78647. }
  78648. }
  78649. declare module BABYLON {
  78650. /**
  78651. * Defines a runtime animation
  78652. */
  78653. export class RuntimeAnimation {
  78654. private _events;
  78655. /**
  78656. * The current frame of the runtime animation
  78657. */
  78658. private _currentFrame;
  78659. /**
  78660. * The animation used by the runtime animation
  78661. */
  78662. private _animation;
  78663. /**
  78664. * The target of the runtime animation
  78665. */
  78666. private _target;
  78667. /**
  78668. * The initiating animatable
  78669. */
  78670. private _host;
  78671. /**
  78672. * The original value of the runtime animation
  78673. */
  78674. private _originalValue;
  78675. /**
  78676. * The original blend value of the runtime animation
  78677. */
  78678. private _originalBlendValue;
  78679. /**
  78680. * The offsets cache of the runtime animation
  78681. */
  78682. private _offsetsCache;
  78683. /**
  78684. * The high limits cache of the runtime animation
  78685. */
  78686. private _highLimitsCache;
  78687. /**
  78688. * Specifies if the runtime animation has been stopped
  78689. */
  78690. private _stopped;
  78691. /**
  78692. * The blending factor of the runtime animation
  78693. */
  78694. private _blendingFactor;
  78695. /**
  78696. * The BabylonJS scene
  78697. */
  78698. private _scene;
  78699. /**
  78700. * The current value of the runtime animation
  78701. */
  78702. private _currentValue;
  78703. /** @hidden */
  78704. _animationState: _IAnimationState;
  78705. /**
  78706. * The active target of the runtime animation
  78707. */
  78708. private _activeTargets;
  78709. private _currentActiveTarget;
  78710. private _directTarget;
  78711. /**
  78712. * The target path of the runtime animation
  78713. */
  78714. private _targetPath;
  78715. /**
  78716. * The weight of the runtime animation
  78717. */
  78718. private _weight;
  78719. /**
  78720. * The ratio offset of the runtime animation
  78721. */
  78722. private _ratioOffset;
  78723. /**
  78724. * The previous delay of the runtime animation
  78725. */
  78726. private _previousDelay;
  78727. /**
  78728. * The previous ratio of the runtime animation
  78729. */
  78730. private _previousRatio;
  78731. private _enableBlending;
  78732. private _keys;
  78733. private _minFrame;
  78734. private _maxFrame;
  78735. private _minValue;
  78736. private _maxValue;
  78737. private _targetIsArray;
  78738. /**
  78739. * Gets the current frame of the runtime animation
  78740. */
  78741. readonly currentFrame: number;
  78742. /**
  78743. * Gets the weight of the runtime animation
  78744. */
  78745. readonly weight: number;
  78746. /**
  78747. * Gets the current value of the runtime animation
  78748. */
  78749. readonly currentValue: any;
  78750. /**
  78751. * Gets the target path of the runtime animation
  78752. */
  78753. readonly targetPath: string;
  78754. /**
  78755. * Gets the actual target of the runtime animation
  78756. */
  78757. readonly target: any;
  78758. /** @hidden */
  78759. _onLoop: () => void;
  78760. /**
  78761. * Create a new RuntimeAnimation object
  78762. * @param target defines the target of the animation
  78763. * @param animation defines the source animation object
  78764. * @param scene defines the hosting scene
  78765. * @param host defines the initiating Animatable
  78766. */
  78767. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  78768. private _preparePath;
  78769. /**
  78770. * Gets the animation from the runtime animation
  78771. */
  78772. readonly animation: Animation;
  78773. /**
  78774. * Resets the runtime animation to the beginning
  78775. * @param restoreOriginal defines whether to restore the target property to the original value
  78776. */
  78777. reset(restoreOriginal?: boolean): void;
  78778. /**
  78779. * Specifies if the runtime animation is stopped
  78780. * @returns Boolean specifying if the runtime animation is stopped
  78781. */
  78782. isStopped(): boolean;
  78783. /**
  78784. * Disposes of the runtime animation
  78785. */
  78786. dispose(): void;
  78787. /**
  78788. * Apply the interpolated value to the target
  78789. * @param currentValue defines the value computed by the animation
  78790. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  78791. */
  78792. setValue(currentValue: any, weight: number): void;
  78793. private _getOriginalValues;
  78794. private _setValue;
  78795. /**
  78796. * Gets the loop pmode of the runtime animation
  78797. * @returns Loop Mode
  78798. */
  78799. private _getCorrectLoopMode;
  78800. /**
  78801. * Move the current animation to a given frame
  78802. * @param frame defines the frame to move to
  78803. */
  78804. goToFrame(frame: number): void;
  78805. /**
  78806. * @hidden Internal use only
  78807. */
  78808. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  78809. /**
  78810. * Execute the current animation
  78811. * @param delay defines the delay to add to the current frame
  78812. * @param from defines the lower bound of the animation range
  78813. * @param to defines the upper bound of the animation range
  78814. * @param loop defines if the current animation must loop
  78815. * @param speedRatio defines the current speed ratio
  78816. * @param weight defines the weight of the animation (default is -1 so no weight)
  78817. * @param onLoop optional callback called when animation loops
  78818. * @returns a boolean indicating if the animation is running
  78819. */
  78820. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  78821. }
  78822. }
  78823. declare module BABYLON {
  78824. /**
  78825. * Class used to store an actual running animation
  78826. */
  78827. export class Animatable {
  78828. /** defines the target object */
  78829. target: any;
  78830. /** defines the starting frame number (default is 0) */
  78831. fromFrame: number;
  78832. /** defines the ending frame number (default is 100) */
  78833. toFrame: number;
  78834. /** defines if the animation must loop (default is false) */
  78835. loopAnimation: boolean;
  78836. /** defines a callback to call when animation ends if it is not looping */
  78837. onAnimationEnd?: (() => void) | null | undefined;
  78838. /** defines a callback to call when animation loops */
  78839. onAnimationLoop?: (() => void) | null | undefined;
  78840. private _localDelayOffset;
  78841. private _pausedDelay;
  78842. private _runtimeAnimations;
  78843. private _paused;
  78844. private _scene;
  78845. private _speedRatio;
  78846. private _weight;
  78847. private _syncRoot;
  78848. /**
  78849. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  78850. * This will only apply for non looping animation (default is true)
  78851. */
  78852. disposeOnEnd: boolean;
  78853. /**
  78854. * Gets a boolean indicating if the animation has started
  78855. */
  78856. animationStarted: boolean;
  78857. /**
  78858. * Observer raised when the animation ends
  78859. */
  78860. onAnimationEndObservable: Observable<Animatable>;
  78861. /**
  78862. * Observer raised when the animation loops
  78863. */
  78864. onAnimationLoopObservable: Observable<Animatable>;
  78865. /**
  78866. * Gets the root Animatable used to synchronize and normalize animations
  78867. */
  78868. readonly syncRoot: Nullable<Animatable>;
  78869. /**
  78870. * Gets the current frame of the first RuntimeAnimation
  78871. * Used to synchronize Animatables
  78872. */
  78873. readonly masterFrame: number;
  78874. /**
  78875. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  78876. */
  78877. weight: number;
  78878. /**
  78879. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  78880. */
  78881. speedRatio: number;
  78882. /**
  78883. * Creates a new Animatable
  78884. * @param scene defines the hosting scene
  78885. * @param target defines the target object
  78886. * @param fromFrame defines the starting frame number (default is 0)
  78887. * @param toFrame defines the ending frame number (default is 100)
  78888. * @param loopAnimation defines if the animation must loop (default is false)
  78889. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  78890. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  78891. * @param animations defines a group of animation to add to the new Animatable
  78892. * @param onAnimationLoop defines a callback to call when animation loops
  78893. */
  78894. constructor(scene: Scene,
  78895. /** defines the target object */
  78896. target: any,
  78897. /** defines the starting frame number (default is 0) */
  78898. fromFrame?: number,
  78899. /** defines the ending frame number (default is 100) */
  78900. toFrame?: number,
  78901. /** defines if the animation must loop (default is false) */
  78902. loopAnimation?: boolean, speedRatio?: number,
  78903. /** defines a callback to call when animation ends if it is not looping */
  78904. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  78905. /** defines a callback to call when animation loops */
  78906. onAnimationLoop?: (() => void) | null | undefined);
  78907. /**
  78908. * Synchronize and normalize current Animatable with a source Animatable
  78909. * This is useful when using animation weights and when animations are not of the same length
  78910. * @param root defines the root Animatable to synchronize with
  78911. * @returns the current Animatable
  78912. */
  78913. syncWith(root: Animatable): Animatable;
  78914. /**
  78915. * Gets the list of runtime animations
  78916. * @returns an array of RuntimeAnimation
  78917. */
  78918. getAnimations(): RuntimeAnimation[];
  78919. /**
  78920. * Adds more animations to the current animatable
  78921. * @param target defines the target of the animations
  78922. * @param animations defines the new animations to add
  78923. */
  78924. appendAnimations(target: any, animations: Animation[]): void;
  78925. /**
  78926. * Gets the source animation for a specific property
  78927. * @param property defines the propertyu to look for
  78928. * @returns null or the source animation for the given property
  78929. */
  78930. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  78931. /**
  78932. * Gets the runtime animation for a specific property
  78933. * @param property defines the propertyu to look for
  78934. * @returns null or the runtime animation for the given property
  78935. */
  78936. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  78937. /**
  78938. * Resets the animatable to its original state
  78939. */
  78940. reset(): void;
  78941. /**
  78942. * Allows the animatable to blend with current running animations
  78943. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  78944. * @param blendingSpeed defines the blending speed to use
  78945. */
  78946. enableBlending(blendingSpeed: number): void;
  78947. /**
  78948. * Disable animation blending
  78949. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  78950. */
  78951. disableBlending(): void;
  78952. /**
  78953. * Jump directly to a given frame
  78954. * @param frame defines the frame to jump to
  78955. */
  78956. goToFrame(frame: number): void;
  78957. /**
  78958. * Pause the animation
  78959. */
  78960. pause(): void;
  78961. /**
  78962. * Restart the animation
  78963. */
  78964. restart(): void;
  78965. private _raiseOnAnimationEnd;
  78966. /**
  78967. * Stop and delete the current animation
  78968. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  78969. * @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)
  78970. */
  78971. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  78972. /**
  78973. * Wait asynchronously for the animation to end
  78974. * @returns a promise which will be fullfilled when the animation ends
  78975. */
  78976. waitAsync(): Promise<Animatable>;
  78977. /** @hidden */
  78978. _animate(delay: number): boolean;
  78979. }
  78980. interface Scene {
  78981. /** @hidden */
  78982. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  78983. /** @hidden */
  78984. _processLateAnimationBindingsForMatrices(holder: {
  78985. totalWeight: number;
  78986. animations: RuntimeAnimation[];
  78987. originalValue: Matrix;
  78988. }): any;
  78989. /** @hidden */
  78990. _processLateAnimationBindingsForQuaternions(holder: {
  78991. totalWeight: number;
  78992. animations: RuntimeAnimation[];
  78993. originalValue: Quaternion;
  78994. }, refQuaternion: Quaternion): Quaternion;
  78995. /** @hidden */
  78996. _processLateAnimationBindings(): void;
  78997. /**
  78998. * Will start the animation sequence of a given target
  78999. * @param target defines the target
  79000. * @param from defines from which frame should animation start
  79001. * @param to defines until which frame should animation run.
  79002. * @param weight defines the weight to apply to the animation (1.0 by default)
  79003. * @param loop defines if the animation loops
  79004. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  79005. * @param onAnimationEnd defines the function to be executed when the animation ends
  79006. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  79007. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  79008. * @param onAnimationLoop defines the callback to call when an animation loops
  79009. * @returns the animatable object created for this animation
  79010. */
  79011. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  79012. /**
  79013. * Will start the animation sequence of a given target
  79014. * @param target defines the target
  79015. * @param from defines from which frame should animation start
  79016. * @param to defines until which frame should animation run.
  79017. * @param loop defines if the animation loops
  79018. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  79019. * @param onAnimationEnd defines the function to be executed when the animation ends
  79020. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  79021. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  79022. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  79023. * @param onAnimationLoop defines the callback to call when an animation loops
  79024. * @returns the animatable object created for this animation
  79025. */
  79026. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  79027. /**
  79028. * Will start the animation sequence of a given target and its hierarchy
  79029. * @param target defines the target
  79030. * @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.
  79031. * @param from defines from which frame should animation start
  79032. * @param to defines until which frame should animation run.
  79033. * @param loop defines if the animation loops
  79034. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  79035. * @param onAnimationEnd defines the function to be executed when the animation ends
  79036. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  79037. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  79038. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  79039. * @param onAnimationLoop defines the callback to call when an animation loops
  79040. * @returns the list of created animatables
  79041. */
  79042. 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[];
  79043. /**
  79044. * Begin a new animation on a given node
  79045. * @param target defines the target where the animation will take place
  79046. * @param animations defines the list of animations to start
  79047. * @param from defines the initial value
  79048. * @param to defines the final value
  79049. * @param loop defines if you want animation to loop (off by default)
  79050. * @param speedRatio defines the speed ratio to apply to all animations
  79051. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  79052. * @param onAnimationLoop defines the callback to call when an animation loops
  79053. * @returns the list of created animatables
  79054. */
  79055. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  79056. /**
  79057. * Begin a new animation on a given node and its hierarchy
  79058. * @param target defines the root node where the animation will take place
  79059. * @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.
  79060. * @param animations defines the list of animations to start
  79061. * @param from defines the initial value
  79062. * @param to defines the final value
  79063. * @param loop defines if you want animation to loop (off by default)
  79064. * @param speedRatio defines the speed ratio to apply to all animations
  79065. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  79066. * @param onAnimationLoop defines the callback to call when an animation loops
  79067. * @returns the list of animatables created for all nodes
  79068. */
  79069. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  79070. /**
  79071. * Gets the animatable associated with a specific target
  79072. * @param target defines the target of the animatable
  79073. * @returns the required animatable if found
  79074. */
  79075. getAnimatableByTarget(target: any): Nullable<Animatable>;
  79076. /**
  79077. * Gets all animatables associated with a given target
  79078. * @param target defines the target to look animatables for
  79079. * @returns an array of Animatables
  79080. */
  79081. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  79082. /**
  79083. * Stops and removes all animations that have been applied to the scene
  79084. */
  79085. stopAllAnimations(): void;
  79086. }
  79087. interface Bone {
  79088. /**
  79089. * Copy an animation range from another bone
  79090. * @param source defines the source bone
  79091. * @param rangeName defines the range name to copy
  79092. * @param frameOffset defines the frame offset
  79093. * @param rescaleAsRequired defines if rescaling must be applied if required
  79094. * @param skelDimensionsRatio defines the scaling ratio
  79095. * @returns true if operation was successful
  79096. */
  79097. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  79098. }
  79099. }
  79100. declare module BABYLON {
  79101. /**
  79102. * Class used to handle skinning animations
  79103. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  79104. */
  79105. export class Skeleton implements IAnimatable {
  79106. /** defines the skeleton name */
  79107. name: string;
  79108. /** defines the skeleton Id */
  79109. id: string;
  79110. /**
  79111. * Defines the list of child bones
  79112. */
  79113. bones: Bone[];
  79114. /**
  79115. * Defines an estimate of the dimension of the skeleton at rest
  79116. */
  79117. dimensionsAtRest: Vector3;
  79118. /**
  79119. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  79120. */
  79121. needInitialSkinMatrix: boolean;
  79122. /**
  79123. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  79124. */
  79125. overrideMesh: Nullable<AbstractMesh>;
  79126. /**
  79127. * Gets the list of animations attached to this skeleton
  79128. */
  79129. animations: Array<Animation>;
  79130. private _scene;
  79131. private _isDirty;
  79132. private _transformMatrices;
  79133. private _transformMatrixTexture;
  79134. private _meshesWithPoseMatrix;
  79135. private _animatables;
  79136. private _identity;
  79137. private _synchronizedWithMesh;
  79138. private _ranges;
  79139. private _lastAbsoluteTransformsUpdateId;
  79140. private _canUseTextureForBones;
  79141. private _uniqueId;
  79142. /** @hidden */
  79143. _numBonesWithLinkedTransformNode: number;
  79144. /** @hidden */
  79145. _hasWaitingData: Nullable<boolean>;
  79146. /**
  79147. * Specifies if the skeleton should be serialized
  79148. */
  79149. doNotSerialize: boolean;
  79150. private _useTextureToStoreBoneMatrices;
  79151. /**
  79152. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  79153. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  79154. */
  79155. useTextureToStoreBoneMatrices: boolean;
  79156. private _animationPropertiesOverride;
  79157. /**
  79158. * Gets or sets the animation properties override
  79159. */
  79160. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  79161. /**
  79162. * List of inspectable custom properties (used by the Inspector)
  79163. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  79164. */
  79165. inspectableCustomProperties: IInspectable[];
  79166. /**
  79167. * An observable triggered before computing the skeleton's matrices
  79168. */
  79169. onBeforeComputeObservable: Observable<Skeleton>;
  79170. /**
  79171. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  79172. */
  79173. readonly isUsingTextureForMatrices: boolean;
  79174. /**
  79175. * Gets the unique ID of this skeleton
  79176. */
  79177. readonly uniqueId: number;
  79178. /**
  79179. * Creates a new skeleton
  79180. * @param name defines the skeleton name
  79181. * @param id defines the skeleton Id
  79182. * @param scene defines the hosting scene
  79183. */
  79184. constructor(
  79185. /** defines the skeleton name */
  79186. name: string,
  79187. /** defines the skeleton Id */
  79188. id: string, scene: Scene);
  79189. /**
  79190. * Gets the current object class name.
  79191. * @return the class name
  79192. */
  79193. getClassName(): string;
  79194. /**
  79195. * Returns an array containing the root bones
  79196. * @returns an array containing the root bones
  79197. */
  79198. getChildren(): Array<Bone>;
  79199. /**
  79200. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  79201. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  79202. * @returns a Float32Array containing matrices data
  79203. */
  79204. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  79205. /**
  79206. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  79207. * @returns a raw texture containing the data
  79208. */
  79209. getTransformMatrixTexture(): Nullable<RawTexture>;
  79210. /**
  79211. * Gets the current hosting scene
  79212. * @returns a scene object
  79213. */
  79214. getScene(): Scene;
  79215. /**
  79216. * Gets a string representing the current skeleton data
  79217. * @param fullDetails defines a boolean indicating if we want a verbose version
  79218. * @returns a string representing the current skeleton data
  79219. */
  79220. toString(fullDetails?: boolean): string;
  79221. /**
  79222. * Get bone's index searching by name
  79223. * @param name defines bone's name to search for
  79224. * @return the indice of the bone. Returns -1 if not found
  79225. */
  79226. getBoneIndexByName(name: string): number;
  79227. /**
  79228. * Creater a new animation range
  79229. * @param name defines the name of the range
  79230. * @param from defines the start key
  79231. * @param to defines the end key
  79232. */
  79233. createAnimationRange(name: string, from: number, to: number): void;
  79234. /**
  79235. * Delete a specific animation range
  79236. * @param name defines the name of the range
  79237. * @param deleteFrames defines if frames must be removed as well
  79238. */
  79239. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  79240. /**
  79241. * Gets a specific animation range
  79242. * @param name defines the name of the range to look for
  79243. * @returns the requested animation range or null if not found
  79244. */
  79245. getAnimationRange(name: string): Nullable<AnimationRange>;
  79246. /**
  79247. * Gets the list of all animation ranges defined on this skeleton
  79248. * @returns an array
  79249. */
  79250. getAnimationRanges(): Nullable<AnimationRange>[];
  79251. /**
  79252. * Copy animation range from a source skeleton.
  79253. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  79254. * @param source defines the source skeleton
  79255. * @param name defines the name of the range to copy
  79256. * @param rescaleAsRequired defines if rescaling must be applied if required
  79257. * @returns true if operation was successful
  79258. */
  79259. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  79260. /**
  79261. * Forces the skeleton to go to rest pose
  79262. */
  79263. returnToRest(): void;
  79264. private _getHighestAnimationFrame;
  79265. /**
  79266. * Begin a specific animation range
  79267. * @param name defines the name of the range to start
  79268. * @param loop defines if looping must be turned on (false by default)
  79269. * @param speedRatio defines the speed ratio to apply (1 by default)
  79270. * @param onAnimationEnd defines a callback which will be called when animation will end
  79271. * @returns a new animatable
  79272. */
  79273. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  79274. /** @hidden */
  79275. _markAsDirty(): void;
  79276. /** @hidden */
  79277. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  79278. /** @hidden */
  79279. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  79280. private _computeTransformMatrices;
  79281. /**
  79282. * Build all resources required to render a skeleton
  79283. */
  79284. prepare(): void;
  79285. /**
  79286. * Gets the list of animatables currently running for this skeleton
  79287. * @returns an array of animatables
  79288. */
  79289. getAnimatables(): IAnimatable[];
  79290. /**
  79291. * Clone the current skeleton
  79292. * @param name defines the name of the new skeleton
  79293. * @param id defines the id of the new skeleton
  79294. * @returns the new skeleton
  79295. */
  79296. clone(name: string, id: string): Skeleton;
  79297. /**
  79298. * Enable animation blending for this skeleton
  79299. * @param blendingSpeed defines the blending speed to apply
  79300. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  79301. */
  79302. enableBlending(blendingSpeed?: number): void;
  79303. /**
  79304. * Releases all resources associated with the current skeleton
  79305. */
  79306. dispose(): void;
  79307. /**
  79308. * Serialize the skeleton in a JSON object
  79309. * @returns a JSON object
  79310. */
  79311. serialize(): any;
  79312. /**
  79313. * Creates a new skeleton from serialized data
  79314. * @param parsedSkeleton defines the serialized data
  79315. * @param scene defines the hosting scene
  79316. * @returns a new skeleton
  79317. */
  79318. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  79319. /**
  79320. * Compute all node absolute transforms
  79321. * @param forceUpdate defines if computation must be done even if cache is up to date
  79322. */
  79323. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  79324. /**
  79325. * Gets the root pose matrix
  79326. * @returns a matrix
  79327. */
  79328. getPoseMatrix(): Nullable<Matrix>;
  79329. /**
  79330. * Sorts bones per internal index
  79331. */
  79332. sortBones(): void;
  79333. private _sortBones;
  79334. }
  79335. }
  79336. declare module BABYLON {
  79337. /**
  79338. * Defines a target to use with MorphTargetManager
  79339. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  79340. */
  79341. export class MorphTarget implements IAnimatable {
  79342. /** defines the name of the target */
  79343. name: string;
  79344. /**
  79345. * Gets or sets the list of animations
  79346. */
  79347. animations: Animation[];
  79348. private _scene;
  79349. private _positions;
  79350. private _normals;
  79351. private _tangents;
  79352. private _influence;
  79353. /**
  79354. * Observable raised when the influence changes
  79355. */
  79356. onInfluenceChanged: Observable<boolean>;
  79357. /** @hidden */
  79358. _onDataLayoutChanged: Observable<void>;
  79359. /**
  79360. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  79361. */
  79362. influence: number;
  79363. /**
  79364. * Gets or sets the id of the morph Target
  79365. */
  79366. id: string;
  79367. private _animationPropertiesOverride;
  79368. /**
  79369. * Gets or sets the animation properties override
  79370. */
  79371. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  79372. /**
  79373. * Creates a new MorphTarget
  79374. * @param name defines the name of the target
  79375. * @param influence defines the influence to use
  79376. * @param scene defines the scene the morphtarget belongs to
  79377. */
  79378. constructor(
  79379. /** defines the name of the target */
  79380. name: string, influence?: number, scene?: Nullable<Scene>);
  79381. /**
  79382. * Gets a boolean defining if the target contains position data
  79383. */
  79384. readonly hasPositions: boolean;
  79385. /**
  79386. * Gets a boolean defining if the target contains normal data
  79387. */
  79388. readonly hasNormals: boolean;
  79389. /**
  79390. * Gets a boolean defining if the target contains tangent data
  79391. */
  79392. readonly hasTangents: boolean;
  79393. /**
  79394. * Affects position data to this target
  79395. * @param data defines the position data to use
  79396. */
  79397. setPositions(data: Nullable<FloatArray>): void;
  79398. /**
  79399. * Gets the position data stored in this target
  79400. * @returns a FloatArray containing the position data (or null if not present)
  79401. */
  79402. getPositions(): Nullable<FloatArray>;
  79403. /**
  79404. * Affects normal data to this target
  79405. * @param data defines the normal data to use
  79406. */
  79407. setNormals(data: Nullable<FloatArray>): void;
  79408. /**
  79409. * Gets the normal data stored in this target
  79410. * @returns a FloatArray containing the normal data (or null if not present)
  79411. */
  79412. getNormals(): Nullable<FloatArray>;
  79413. /**
  79414. * Affects tangent data to this target
  79415. * @param data defines the tangent data to use
  79416. */
  79417. setTangents(data: Nullable<FloatArray>): void;
  79418. /**
  79419. * Gets the tangent data stored in this target
  79420. * @returns a FloatArray containing the tangent data (or null if not present)
  79421. */
  79422. getTangents(): Nullable<FloatArray>;
  79423. /**
  79424. * Serializes the current target into a Serialization object
  79425. * @returns the serialized object
  79426. */
  79427. serialize(): any;
  79428. /**
  79429. * Returns the string "MorphTarget"
  79430. * @returns "MorphTarget"
  79431. */
  79432. getClassName(): string;
  79433. /**
  79434. * Creates a new target from serialized data
  79435. * @param serializationObject defines the serialized data to use
  79436. * @returns a new MorphTarget
  79437. */
  79438. static Parse(serializationObject: any): MorphTarget;
  79439. /**
  79440. * Creates a MorphTarget from mesh data
  79441. * @param mesh defines the source mesh
  79442. * @param name defines the name to use for the new target
  79443. * @param influence defines the influence to attach to the target
  79444. * @returns a new MorphTarget
  79445. */
  79446. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  79447. }
  79448. }
  79449. declare module BABYLON {
  79450. /**
  79451. * This class is used to deform meshes using morphing between different targets
  79452. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  79453. */
  79454. export class MorphTargetManager {
  79455. private _targets;
  79456. private _targetInfluenceChangedObservers;
  79457. private _targetDataLayoutChangedObservers;
  79458. private _activeTargets;
  79459. private _scene;
  79460. private _influences;
  79461. private _supportsNormals;
  79462. private _supportsTangents;
  79463. private _vertexCount;
  79464. private _uniqueId;
  79465. private _tempInfluences;
  79466. /**
  79467. * Creates a new MorphTargetManager
  79468. * @param scene defines the current scene
  79469. */
  79470. constructor(scene?: Nullable<Scene>);
  79471. /**
  79472. * Gets the unique ID of this manager
  79473. */
  79474. readonly uniqueId: number;
  79475. /**
  79476. * Gets the number of vertices handled by this manager
  79477. */
  79478. readonly vertexCount: number;
  79479. /**
  79480. * Gets a boolean indicating if this manager supports morphing of normals
  79481. */
  79482. readonly supportsNormals: boolean;
  79483. /**
  79484. * Gets a boolean indicating if this manager supports morphing of tangents
  79485. */
  79486. readonly supportsTangents: boolean;
  79487. /**
  79488. * Gets the number of targets stored in this manager
  79489. */
  79490. readonly numTargets: number;
  79491. /**
  79492. * Gets the number of influencers (ie. the number of targets with influences > 0)
  79493. */
  79494. readonly numInfluencers: number;
  79495. /**
  79496. * Gets the list of influences (one per target)
  79497. */
  79498. readonly influences: Float32Array;
  79499. /**
  79500. * Gets the active target at specified index. An active target is a target with an influence > 0
  79501. * @param index defines the index to check
  79502. * @returns the requested target
  79503. */
  79504. getActiveTarget(index: number): MorphTarget;
  79505. /**
  79506. * Gets the target at specified index
  79507. * @param index defines the index to check
  79508. * @returns the requested target
  79509. */
  79510. getTarget(index: number): MorphTarget;
  79511. /**
  79512. * Add a new target to this manager
  79513. * @param target defines the target to add
  79514. */
  79515. addTarget(target: MorphTarget): void;
  79516. /**
  79517. * Removes a target from the manager
  79518. * @param target defines the target to remove
  79519. */
  79520. removeTarget(target: MorphTarget): void;
  79521. /**
  79522. * Serializes the current manager into a Serialization object
  79523. * @returns the serialized object
  79524. */
  79525. serialize(): any;
  79526. private _syncActiveTargets;
  79527. /**
  79528. * Syncrhonize the targets with all the meshes using this morph target manager
  79529. */
  79530. synchronize(): void;
  79531. /**
  79532. * Creates a new MorphTargetManager from serialized data
  79533. * @param serializationObject defines the serialized data
  79534. * @param scene defines the hosting scene
  79535. * @returns the new MorphTargetManager
  79536. */
  79537. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  79538. }
  79539. }
  79540. declare module BABYLON {
  79541. /**
  79542. * Class used to represent a specific level of detail of a mesh
  79543. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  79544. */
  79545. export class MeshLODLevel {
  79546. /** Defines the distance where this level should star being displayed */
  79547. distance: number;
  79548. /** Defines the mesh to use to render this level */
  79549. mesh: Nullable<Mesh>;
  79550. /**
  79551. * Creates a new LOD level
  79552. * @param distance defines the distance where this level should star being displayed
  79553. * @param mesh defines the mesh to use to render this level
  79554. */
  79555. constructor(
  79556. /** Defines the distance where this level should star being displayed */
  79557. distance: number,
  79558. /** Defines the mesh to use to render this level */
  79559. mesh: Nullable<Mesh>);
  79560. }
  79561. }
  79562. declare module BABYLON {
  79563. /**
  79564. * Mesh representing the gorund
  79565. */
  79566. export class GroundMesh extends Mesh {
  79567. /** If octree should be generated */
  79568. generateOctree: boolean;
  79569. private _heightQuads;
  79570. /** @hidden */
  79571. _subdivisionsX: number;
  79572. /** @hidden */
  79573. _subdivisionsY: number;
  79574. /** @hidden */
  79575. _width: number;
  79576. /** @hidden */
  79577. _height: number;
  79578. /** @hidden */
  79579. _minX: number;
  79580. /** @hidden */
  79581. _maxX: number;
  79582. /** @hidden */
  79583. _minZ: number;
  79584. /** @hidden */
  79585. _maxZ: number;
  79586. constructor(name: string, scene: Scene);
  79587. /**
  79588. * "GroundMesh"
  79589. * @returns "GroundMesh"
  79590. */
  79591. getClassName(): string;
  79592. /**
  79593. * The minimum of x and y subdivisions
  79594. */
  79595. readonly subdivisions: number;
  79596. /**
  79597. * X subdivisions
  79598. */
  79599. readonly subdivisionsX: number;
  79600. /**
  79601. * Y subdivisions
  79602. */
  79603. readonly subdivisionsY: number;
  79604. /**
  79605. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  79606. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  79607. * @param chunksCount the number of subdivisions for x and y
  79608. * @param octreeBlocksSize (Default: 32)
  79609. */
  79610. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  79611. /**
  79612. * Returns a height (y) value in the Worl system :
  79613. * the ground altitude at the coordinates (x, z) expressed in the World system.
  79614. * @param x x coordinate
  79615. * @param z z coordinate
  79616. * @returns the ground y position if (x, z) are outside the ground surface.
  79617. */
  79618. getHeightAtCoordinates(x: number, z: number): number;
  79619. /**
  79620. * Returns a normalized vector (Vector3) orthogonal to the ground
  79621. * at the ground coordinates (x, z) expressed in the World system.
  79622. * @param x x coordinate
  79623. * @param z z coordinate
  79624. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  79625. */
  79626. getNormalAtCoordinates(x: number, z: number): Vector3;
  79627. /**
  79628. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  79629. * at the ground coordinates (x, z) expressed in the World system.
  79630. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  79631. * @param x x coordinate
  79632. * @param z z coordinate
  79633. * @param ref vector to store the result
  79634. * @returns the GroundMesh.
  79635. */
  79636. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  79637. /**
  79638. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  79639. * if the ground has been updated.
  79640. * This can be used in the render loop.
  79641. * @returns the GroundMesh.
  79642. */
  79643. updateCoordinateHeights(): GroundMesh;
  79644. private _getFacetAt;
  79645. private _initHeightQuads;
  79646. private _computeHeightQuads;
  79647. /**
  79648. * Serializes this ground mesh
  79649. * @param serializationObject object to write serialization to
  79650. */
  79651. serialize(serializationObject: any): void;
  79652. /**
  79653. * Parses a serialized ground mesh
  79654. * @param parsedMesh the serialized mesh
  79655. * @param scene the scene to create the ground mesh in
  79656. * @returns the created ground mesh
  79657. */
  79658. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  79659. }
  79660. }
  79661. declare module BABYLON {
  79662. /**
  79663. * Interface for Physics-Joint data
  79664. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79665. */
  79666. export interface PhysicsJointData {
  79667. /**
  79668. * The main pivot of the joint
  79669. */
  79670. mainPivot?: Vector3;
  79671. /**
  79672. * The connected pivot of the joint
  79673. */
  79674. connectedPivot?: Vector3;
  79675. /**
  79676. * The main axis of the joint
  79677. */
  79678. mainAxis?: Vector3;
  79679. /**
  79680. * The connected axis of the joint
  79681. */
  79682. connectedAxis?: Vector3;
  79683. /**
  79684. * The collision of the joint
  79685. */
  79686. collision?: boolean;
  79687. /**
  79688. * Native Oimo/Cannon/Energy data
  79689. */
  79690. nativeParams?: any;
  79691. }
  79692. /**
  79693. * This is a holder class for the physics joint created by the physics plugin
  79694. * It holds a set of functions to control the underlying joint
  79695. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79696. */
  79697. export class PhysicsJoint {
  79698. /**
  79699. * The type of the physics joint
  79700. */
  79701. type: number;
  79702. /**
  79703. * The data for the physics joint
  79704. */
  79705. jointData: PhysicsJointData;
  79706. private _physicsJoint;
  79707. protected _physicsPlugin: IPhysicsEnginePlugin;
  79708. /**
  79709. * Initializes the physics joint
  79710. * @param type The type of the physics joint
  79711. * @param jointData The data for the physics joint
  79712. */
  79713. constructor(
  79714. /**
  79715. * The type of the physics joint
  79716. */
  79717. type: number,
  79718. /**
  79719. * The data for the physics joint
  79720. */
  79721. jointData: PhysicsJointData);
  79722. /**
  79723. * Gets the physics joint
  79724. */
  79725. /**
  79726. * Sets the physics joint
  79727. */
  79728. physicsJoint: any;
  79729. /**
  79730. * Sets the physics plugin
  79731. */
  79732. physicsPlugin: IPhysicsEnginePlugin;
  79733. /**
  79734. * Execute a function that is physics-plugin specific.
  79735. * @param {Function} func the function that will be executed.
  79736. * It accepts two parameters: the physics world and the physics joint
  79737. */
  79738. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  79739. /**
  79740. * Distance-Joint type
  79741. */
  79742. static DistanceJoint: number;
  79743. /**
  79744. * Hinge-Joint type
  79745. */
  79746. static HingeJoint: number;
  79747. /**
  79748. * Ball-and-Socket joint type
  79749. */
  79750. static BallAndSocketJoint: number;
  79751. /**
  79752. * Wheel-Joint type
  79753. */
  79754. static WheelJoint: number;
  79755. /**
  79756. * Slider-Joint type
  79757. */
  79758. static SliderJoint: number;
  79759. /**
  79760. * Prismatic-Joint type
  79761. */
  79762. static PrismaticJoint: number;
  79763. /**
  79764. * Universal-Joint type
  79765. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  79766. */
  79767. static UniversalJoint: number;
  79768. /**
  79769. * Hinge-Joint 2 type
  79770. */
  79771. static Hinge2Joint: number;
  79772. /**
  79773. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  79774. */
  79775. static PointToPointJoint: number;
  79776. /**
  79777. * Spring-Joint type
  79778. */
  79779. static SpringJoint: number;
  79780. /**
  79781. * Lock-Joint type
  79782. */
  79783. static LockJoint: number;
  79784. }
  79785. /**
  79786. * A class representing a physics distance joint
  79787. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79788. */
  79789. export class DistanceJoint extends PhysicsJoint {
  79790. /**
  79791. *
  79792. * @param jointData The data for the Distance-Joint
  79793. */
  79794. constructor(jointData: DistanceJointData);
  79795. /**
  79796. * Update the predefined distance.
  79797. * @param maxDistance The maximum preferred distance
  79798. * @param minDistance The minimum preferred distance
  79799. */
  79800. updateDistance(maxDistance: number, minDistance?: number): void;
  79801. }
  79802. /**
  79803. * Represents a Motor-Enabled Joint
  79804. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79805. */
  79806. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  79807. /**
  79808. * Initializes the Motor-Enabled Joint
  79809. * @param type The type of the joint
  79810. * @param jointData The physica joint data for the joint
  79811. */
  79812. constructor(type: number, jointData: PhysicsJointData);
  79813. /**
  79814. * Set the motor values.
  79815. * Attention, this function is plugin specific. Engines won't react 100% the same.
  79816. * @param force the force to apply
  79817. * @param maxForce max force for this motor.
  79818. */
  79819. setMotor(force?: number, maxForce?: number): void;
  79820. /**
  79821. * Set the motor's limits.
  79822. * Attention, this function is plugin specific. Engines won't react 100% the same.
  79823. * @param upperLimit The upper limit of the motor
  79824. * @param lowerLimit The lower limit of the motor
  79825. */
  79826. setLimit(upperLimit: number, lowerLimit?: number): void;
  79827. }
  79828. /**
  79829. * This class represents a single physics Hinge-Joint
  79830. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79831. */
  79832. export class HingeJoint extends MotorEnabledJoint {
  79833. /**
  79834. * Initializes the Hinge-Joint
  79835. * @param jointData The joint data for the Hinge-Joint
  79836. */
  79837. constructor(jointData: PhysicsJointData);
  79838. /**
  79839. * Set the motor values.
  79840. * Attention, this function is plugin specific. Engines won't react 100% the same.
  79841. * @param {number} force the force to apply
  79842. * @param {number} maxForce max force for this motor.
  79843. */
  79844. setMotor(force?: number, maxForce?: number): void;
  79845. /**
  79846. * Set the motor's limits.
  79847. * Attention, this function is plugin specific. Engines won't react 100% the same.
  79848. * @param upperLimit The upper limit of the motor
  79849. * @param lowerLimit The lower limit of the motor
  79850. */
  79851. setLimit(upperLimit: number, lowerLimit?: number): void;
  79852. }
  79853. /**
  79854. * This class represents a dual hinge physics joint (same as wheel joint)
  79855. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79856. */
  79857. export class Hinge2Joint extends MotorEnabledJoint {
  79858. /**
  79859. * Initializes the Hinge2-Joint
  79860. * @param jointData The joint data for the Hinge2-Joint
  79861. */
  79862. constructor(jointData: PhysicsJointData);
  79863. /**
  79864. * Set the motor values.
  79865. * Attention, this function is plugin specific. Engines won't react 100% the same.
  79866. * @param {number} targetSpeed the speed the motor is to reach
  79867. * @param {number} maxForce max force for this motor.
  79868. * @param {motorIndex} the motor's index, 0 or 1.
  79869. */
  79870. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  79871. /**
  79872. * Set the motor limits.
  79873. * Attention, this function is plugin specific. Engines won't react 100% the same.
  79874. * @param {number} upperLimit the upper limit
  79875. * @param {number} lowerLimit lower limit
  79876. * @param {motorIndex} the motor's index, 0 or 1.
  79877. */
  79878. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  79879. }
  79880. /**
  79881. * Interface for a motor enabled joint
  79882. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79883. */
  79884. export interface IMotorEnabledJoint {
  79885. /**
  79886. * Physics joint
  79887. */
  79888. physicsJoint: any;
  79889. /**
  79890. * Sets the motor of the motor-enabled joint
  79891. * @param force The force of the motor
  79892. * @param maxForce The maximum force of the motor
  79893. * @param motorIndex The index of the motor
  79894. */
  79895. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  79896. /**
  79897. * Sets the limit of the motor
  79898. * @param upperLimit The upper limit of the motor
  79899. * @param lowerLimit The lower limit of the motor
  79900. * @param motorIndex The index of the motor
  79901. */
  79902. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  79903. }
  79904. /**
  79905. * Joint data for a Distance-Joint
  79906. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79907. */
  79908. export interface DistanceJointData extends PhysicsJointData {
  79909. /**
  79910. * Max distance the 2 joint objects can be apart
  79911. */
  79912. maxDistance: number;
  79913. }
  79914. /**
  79915. * Joint data from a spring joint
  79916. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79917. */
  79918. export interface SpringJointData extends PhysicsJointData {
  79919. /**
  79920. * Length of the spring
  79921. */
  79922. length: number;
  79923. /**
  79924. * Stiffness of the spring
  79925. */
  79926. stiffness: number;
  79927. /**
  79928. * Damping of the spring
  79929. */
  79930. damping: number;
  79931. /** this callback will be called when applying the force to the impostors. */
  79932. forceApplicationCallback: () => void;
  79933. }
  79934. }
  79935. declare module BABYLON {
  79936. /**
  79937. * Holds the data for the raycast result
  79938. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79939. */
  79940. export class PhysicsRaycastResult {
  79941. private _hasHit;
  79942. private _hitDistance;
  79943. private _hitNormalWorld;
  79944. private _hitPointWorld;
  79945. private _rayFromWorld;
  79946. private _rayToWorld;
  79947. /**
  79948. * Gets if there was a hit
  79949. */
  79950. readonly hasHit: boolean;
  79951. /**
  79952. * Gets the distance from the hit
  79953. */
  79954. readonly hitDistance: number;
  79955. /**
  79956. * Gets the hit normal/direction in the world
  79957. */
  79958. readonly hitNormalWorld: Vector3;
  79959. /**
  79960. * Gets the hit point in the world
  79961. */
  79962. readonly hitPointWorld: Vector3;
  79963. /**
  79964. * Gets the ray "start point" of the ray in the world
  79965. */
  79966. readonly rayFromWorld: Vector3;
  79967. /**
  79968. * Gets the ray "end point" of the ray in the world
  79969. */
  79970. readonly rayToWorld: Vector3;
  79971. /**
  79972. * Sets the hit data (normal & point in world space)
  79973. * @param hitNormalWorld defines the normal in world space
  79974. * @param hitPointWorld defines the point in world space
  79975. */
  79976. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  79977. /**
  79978. * Sets the distance from the start point to the hit point
  79979. * @param distance
  79980. */
  79981. setHitDistance(distance: number): void;
  79982. /**
  79983. * Calculates the distance manually
  79984. */
  79985. calculateHitDistance(): void;
  79986. /**
  79987. * Resets all the values to default
  79988. * @param from The from point on world space
  79989. * @param to The to point on world space
  79990. */
  79991. reset(from?: Vector3, to?: Vector3): void;
  79992. }
  79993. /**
  79994. * Interface for the size containing width and height
  79995. */
  79996. interface IXYZ {
  79997. /**
  79998. * X
  79999. */
  80000. x: number;
  80001. /**
  80002. * Y
  80003. */
  80004. y: number;
  80005. /**
  80006. * Z
  80007. */
  80008. z: number;
  80009. }
  80010. }
  80011. declare module BABYLON {
  80012. /**
  80013. * Interface used to describe a physics joint
  80014. */
  80015. export interface PhysicsImpostorJoint {
  80016. /** Defines the main impostor to which the joint is linked */
  80017. mainImpostor: PhysicsImpostor;
  80018. /** Defines the impostor that is connected to the main impostor using this joint */
  80019. connectedImpostor: PhysicsImpostor;
  80020. /** Defines the joint itself */
  80021. joint: PhysicsJoint;
  80022. }
  80023. /** @hidden */
  80024. export interface IPhysicsEnginePlugin {
  80025. world: any;
  80026. name: string;
  80027. setGravity(gravity: Vector3): void;
  80028. setTimeStep(timeStep: number): void;
  80029. getTimeStep(): number;
  80030. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  80031. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  80032. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  80033. generatePhysicsBody(impostor: PhysicsImpostor): void;
  80034. removePhysicsBody(impostor: PhysicsImpostor): void;
  80035. generateJoint(joint: PhysicsImpostorJoint): void;
  80036. removeJoint(joint: PhysicsImpostorJoint): void;
  80037. isSupported(): boolean;
  80038. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  80039. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  80040. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  80041. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  80042. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  80043. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  80044. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  80045. getBodyMass(impostor: PhysicsImpostor): number;
  80046. getBodyFriction(impostor: PhysicsImpostor): number;
  80047. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  80048. getBodyRestitution(impostor: PhysicsImpostor): number;
  80049. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  80050. getBodyPressure?(impostor: PhysicsImpostor): number;
  80051. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  80052. getBodyStiffness?(impostor: PhysicsImpostor): number;
  80053. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  80054. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  80055. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  80056. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  80057. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  80058. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  80059. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  80060. sleepBody(impostor: PhysicsImpostor): void;
  80061. wakeUpBody(impostor: PhysicsImpostor): void;
  80062. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  80063. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  80064. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  80065. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  80066. getRadius(impostor: PhysicsImpostor): number;
  80067. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  80068. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  80069. dispose(): void;
  80070. }
  80071. /**
  80072. * Interface used to define a physics engine
  80073. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  80074. */
  80075. export interface IPhysicsEngine {
  80076. /**
  80077. * Gets the gravity vector used by the simulation
  80078. */
  80079. gravity: Vector3;
  80080. /**
  80081. * Sets the gravity vector used by the simulation
  80082. * @param gravity defines the gravity vector to use
  80083. */
  80084. setGravity(gravity: Vector3): void;
  80085. /**
  80086. * Set the time step of the physics engine.
  80087. * Default is 1/60.
  80088. * To slow it down, enter 1/600 for example.
  80089. * To speed it up, 1/30
  80090. * @param newTimeStep the new timestep to apply to this world.
  80091. */
  80092. setTimeStep(newTimeStep: number): void;
  80093. /**
  80094. * Get the time step of the physics engine.
  80095. * @returns the current time step
  80096. */
  80097. getTimeStep(): number;
  80098. /**
  80099. * Release all resources
  80100. */
  80101. dispose(): void;
  80102. /**
  80103. * Gets the name of the current physics plugin
  80104. * @returns the name of the plugin
  80105. */
  80106. getPhysicsPluginName(): string;
  80107. /**
  80108. * Adding a new impostor for the impostor tracking.
  80109. * This will be done by the impostor itself.
  80110. * @param impostor the impostor to add
  80111. */
  80112. addImpostor(impostor: PhysicsImpostor): void;
  80113. /**
  80114. * Remove an impostor from the engine.
  80115. * This impostor and its mesh will not longer be updated by the physics engine.
  80116. * @param impostor the impostor to remove
  80117. */
  80118. removeImpostor(impostor: PhysicsImpostor): void;
  80119. /**
  80120. * Add a joint to the physics engine
  80121. * @param mainImpostor defines the main impostor to which the joint is added.
  80122. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  80123. * @param joint defines the joint that will connect both impostors.
  80124. */
  80125. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  80126. /**
  80127. * Removes a joint from the simulation
  80128. * @param mainImpostor defines the impostor used with the joint
  80129. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  80130. * @param joint defines the joint to remove
  80131. */
  80132. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  80133. /**
  80134. * Gets the current plugin used to run the simulation
  80135. * @returns current plugin
  80136. */
  80137. getPhysicsPlugin(): IPhysicsEnginePlugin;
  80138. /**
  80139. * Gets the list of physic impostors
  80140. * @returns an array of PhysicsImpostor
  80141. */
  80142. getImpostors(): Array<PhysicsImpostor>;
  80143. /**
  80144. * Gets the impostor for a physics enabled object
  80145. * @param object defines the object impersonated by the impostor
  80146. * @returns the PhysicsImpostor or null if not found
  80147. */
  80148. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  80149. /**
  80150. * Gets the impostor for a physics body object
  80151. * @param body defines physics body used by the impostor
  80152. * @returns the PhysicsImpostor or null if not found
  80153. */
  80154. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  80155. /**
  80156. * Does a raycast in the physics world
  80157. * @param from when should the ray start?
  80158. * @param to when should the ray end?
  80159. * @returns PhysicsRaycastResult
  80160. */
  80161. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  80162. /**
  80163. * Called by the scene. No need to call it.
  80164. * @param delta defines the timespam between frames
  80165. */
  80166. _step(delta: number): void;
  80167. }
  80168. }
  80169. declare module BABYLON {
  80170. /**
  80171. * The interface for the physics imposter parameters
  80172. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  80173. */
  80174. export interface PhysicsImpostorParameters {
  80175. /**
  80176. * The mass of the physics imposter
  80177. */
  80178. mass: number;
  80179. /**
  80180. * The friction of the physics imposter
  80181. */
  80182. friction?: number;
  80183. /**
  80184. * The coefficient of restitution of the physics imposter
  80185. */
  80186. restitution?: number;
  80187. /**
  80188. * The native options of the physics imposter
  80189. */
  80190. nativeOptions?: any;
  80191. /**
  80192. * Specifies if the parent should be ignored
  80193. */
  80194. ignoreParent?: boolean;
  80195. /**
  80196. * Specifies if bi-directional transformations should be disabled
  80197. */
  80198. disableBidirectionalTransformation?: boolean;
  80199. /**
  80200. * The pressure inside the physics imposter, soft object only
  80201. */
  80202. pressure?: number;
  80203. /**
  80204. * The stiffness the physics imposter, soft object only
  80205. */
  80206. stiffness?: number;
  80207. /**
  80208. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  80209. */
  80210. velocityIterations?: number;
  80211. /**
  80212. * The number of iterations used in maintaining consistent vertex positions, soft object only
  80213. */
  80214. positionIterations?: number;
  80215. /**
  80216. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  80217. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  80218. * Add to fix multiple points
  80219. */
  80220. fixedPoints?: number;
  80221. /**
  80222. * The collision margin around a soft object
  80223. */
  80224. margin?: number;
  80225. /**
  80226. * The collision margin around a soft object
  80227. */
  80228. damping?: number;
  80229. /**
  80230. * The path for a rope based on an extrusion
  80231. */
  80232. path?: any;
  80233. /**
  80234. * The shape of an extrusion used for a rope based on an extrusion
  80235. */
  80236. shape?: any;
  80237. }
  80238. /**
  80239. * Interface for a physics-enabled object
  80240. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  80241. */
  80242. export interface IPhysicsEnabledObject {
  80243. /**
  80244. * The position of the physics-enabled object
  80245. */
  80246. position: Vector3;
  80247. /**
  80248. * The rotation of the physics-enabled object
  80249. */
  80250. rotationQuaternion: Nullable<Quaternion>;
  80251. /**
  80252. * The scale of the physics-enabled object
  80253. */
  80254. scaling: Vector3;
  80255. /**
  80256. * The rotation of the physics-enabled object
  80257. */
  80258. rotation?: Vector3;
  80259. /**
  80260. * The parent of the physics-enabled object
  80261. */
  80262. parent?: any;
  80263. /**
  80264. * The bounding info of the physics-enabled object
  80265. * @returns The bounding info of the physics-enabled object
  80266. */
  80267. getBoundingInfo(): BoundingInfo;
  80268. /**
  80269. * Computes the world matrix
  80270. * @param force Specifies if the world matrix should be computed by force
  80271. * @returns A world matrix
  80272. */
  80273. computeWorldMatrix(force: boolean): Matrix;
  80274. /**
  80275. * Gets the world matrix
  80276. * @returns A world matrix
  80277. */
  80278. getWorldMatrix?(): Matrix;
  80279. /**
  80280. * Gets the child meshes
  80281. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  80282. * @returns An array of abstract meshes
  80283. */
  80284. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  80285. /**
  80286. * Gets the vertex data
  80287. * @param kind The type of vertex data
  80288. * @returns A nullable array of numbers, or a float32 array
  80289. */
  80290. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  80291. /**
  80292. * Gets the indices from the mesh
  80293. * @returns A nullable array of index arrays
  80294. */
  80295. getIndices?(): Nullable<IndicesArray>;
  80296. /**
  80297. * Gets the scene from the mesh
  80298. * @returns the indices array or null
  80299. */
  80300. getScene?(): Scene;
  80301. /**
  80302. * Gets the absolute position from the mesh
  80303. * @returns the absolute position
  80304. */
  80305. getAbsolutePosition(): Vector3;
  80306. /**
  80307. * Gets the absolute pivot point from the mesh
  80308. * @returns the absolute pivot point
  80309. */
  80310. getAbsolutePivotPoint(): Vector3;
  80311. /**
  80312. * Rotates the mesh
  80313. * @param axis The axis of rotation
  80314. * @param amount The amount of rotation
  80315. * @param space The space of the rotation
  80316. * @returns The rotation transform node
  80317. */
  80318. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  80319. /**
  80320. * Translates the mesh
  80321. * @param axis The axis of translation
  80322. * @param distance The distance of translation
  80323. * @param space The space of the translation
  80324. * @returns The transform node
  80325. */
  80326. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  80327. /**
  80328. * Sets the absolute position of the mesh
  80329. * @param absolutePosition The absolute position of the mesh
  80330. * @returns The transform node
  80331. */
  80332. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  80333. /**
  80334. * Gets the class name of the mesh
  80335. * @returns The class name
  80336. */
  80337. getClassName(): string;
  80338. }
  80339. /**
  80340. * Represents a physics imposter
  80341. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  80342. */
  80343. export class PhysicsImpostor {
  80344. /**
  80345. * The physics-enabled object used as the physics imposter
  80346. */
  80347. object: IPhysicsEnabledObject;
  80348. /**
  80349. * The type of the physics imposter
  80350. */
  80351. type: number;
  80352. private _options;
  80353. private _scene?;
  80354. /**
  80355. * The default object size of the imposter
  80356. */
  80357. static DEFAULT_OBJECT_SIZE: Vector3;
  80358. /**
  80359. * The identity quaternion of the imposter
  80360. */
  80361. static IDENTITY_QUATERNION: Quaternion;
  80362. /** @hidden */
  80363. _pluginData: any;
  80364. private _physicsEngine;
  80365. private _physicsBody;
  80366. private _bodyUpdateRequired;
  80367. private _onBeforePhysicsStepCallbacks;
  80368. private _onAfterPhysicsStepCallbacks;
  80369. /** @hidden */
  80370. _onPhysicsCollideCallbacks: Array<{
  80371. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  80372. otherImpostors: Array<PhysicsImpostor>;
  80373. }>;
  80374. private _deltaPosition;
  80375. private _deltaRotation;
  80376. private _deltaRotationConjugated;
  80377. /** hidden */
  80378. _isFromLine: boolean;
  80379. private _parent;
  80380. private _isDisposed;
  80381. private static _tmpVecs;
  80382. private static _tmpQuat;
  80383. /**
  80384. * Specifies if the physics imposter is disposed
  80385. */
  80386. readonly isDisposed: boolean;
  80387. /**
  80388. * Gets the mass of the physics imposter
  80389. */
  80390. mass: number;
  80391. /**
  80392. * Gets the coefficient of friction
  80393. */
  80394. /**
  80395. * Sets the coefficient of friction
  80396. */
  80397. friction: number;
  80398. /**
  80399. * Gets the coefficient of restitution
  80400. */
  80401. /**
  80402. * Sets the coefficient of restitution
  80403. */
  80404. restitution: number;
  80405. /**
  80406. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  80407. */
  80408. /**
  80409. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  80410. */
  80411. pressure: number;
  80412. /**
  80413. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  80414. */
  80415. /**
  80416. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  80417. */
  80418. stiffness: number;
  80419. /**
  80420. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  80421. */
  80422. /**
  80423. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  80424. */
  80425. velocityIterations: number;
  80426. /**
  80427. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  80428. */
  80429. /**
  80430. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  80431. */
  80432. positionIterations: number;
  80433. /**
  80434. * The unique id of the physics imposter
  80435. * set by the physics engine when adding this impostor to the array
  80436. */
  80437. uniqueId: number;
  80438. /**
  80439. * @hidden
  80440. */
  80441. soft: boolean;
  80442. /**
  80443. * @hidden
  80444. */
  80445. segments: number;
  80446. private _joints;
  80447. /**
  80448. * Initializes the physics imposter
  80449. * @param object The physics-enabled object used as the physics imposter
  80450. * @param type The type of the physics imposter
  80451. * @param _options The options for the physics imposter
  80452. * @param _scene The Babylon scene
  80453. */
  80454. constructor(
  80455. /**
  80456. * The physics-enabled object used as the physics imposter
  80457. */
  80458. object: IPhysicsEnabledObject,
  80459. /**
  80460. * The type of the physics imposter
  80461. */
  80462. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  80463. /**
  80464. * This function will completly initialize this impostor.
  80465. * It will create a new body - but only if this mesh has no parent.
  80466. * If it has, this impostor will not be used other than to define the impostor
  80467. * of the child mesh.
  80468. * @hidden
  80469. */
  80470. _init(): void;
  80471. private _getPhysicsParent;
  80472. /**
  80473. * Should a new body be generated.
  80474. * @returns boolean specifying if body initialization is required
  80475. */
  80476. isBodyInitRequired(): boolean;
  80477. /**
  80478. * Sets the updated scaling
  80479. * @param updated Specifies if the scaling is updated
  80480. */
  80481. setScalingUpdated(): void;
  80482. /**
  80483. * Force a regeneration of this or the parent's impostor's body.
  80484. * Use under cautious - This will remove all joints already implemented.
  80485. */
  80486. forceUpdate(): void;
  80487. /**
  80488. * Gets the body that holds this impostor. Either its own, or its parent.
  80489. */
  80490. /**
  80491. * Set the physics body. Used mainly by the physics engine/plugin
  80492. */
  80493. physicsBody: any;
  80494. /**
  80495. * Get the parent of the physics imposter
  80496. * @returns Physics imposter or null
  80497. */
  80498. /**
  80499. * Sets the parent of the physics imposter
  80500. */
  80501. parent: Nullable<PhysicsImpostor>;
  80502. /**
  80503. * Resets the update flags
  80504. */
  80505. resetUpdateFlags(): void;
  80506. /**
  80507. * Gets the object extend size
  80508. * @returns the object extend size
  80509. */
  80510. getObjectExtendSize(): Vector3;
  80511. /**
  80512. * Gets the object center
  80513. * @returns The object center
  80514. */
  80515. getObjectCenter(): Vector3;
  80516. /**
  80517. * Get a specific parametes from the options parameter
  80518. * @param paramName The object parameter name
  80519. * @returns The object parameter
  80520. */
  80521. getParam(paramName: string): any;
  80522. /**
  80523. * Sets a specific parameter in the options given to the physics plugin
  80524. * @param paramName The parameter name
  80525. * @param value The value of the parameter
  80526. */
  80527. setParam(paramName: string, value: number): void;
  80528. /**
  80529. * Specifically change the body's mass option. Won't recreate the physics body object
  80530. * @param mass The mass of the physics imposter
  80531. */
  80532. setMass(mass: number): void;
  80533. /**
  80534. * Gets the linear velocity
  80535. * @returns linear velocity or null
  80536. */
  80537. getLinearVelocity(): Nullable<Vector3>;
  80538. /**
  80539. * Sets the linear velocity
  80540. * @param velocity linear velocity or null
  80541. */
  80542. setLinearVelocity(velocity: Nullable<Vector3>): void;
  80543. /**
  80544. * Gets the angular velocity
  80545. * @returns angular velocity or null
  80546. */
  80547. getAngularVelocity(): Nullable<Vector3>;
  80548. /**
  80549. * Sets the angular velocity
  80550. * @param velocity The velocity or null
  80551. */
  80552. setAngularVelocity(velocity: Nullable<Vector3>): void;
  80553. /**
  80554. * Execute a function with the physics plugin native code
  80555. * Provide a function the will have two variables - the world object and the physics body object
  80556. * @param func The function to execute with the physics plugin native code
  80557. */
  80558. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  80559. /**
  80560. * Register a function that will be executed before the physics world is stepping forward
  80561. * @param func The function to execute before the physics world is stepped forward
  80562. */
  80563. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  80564. /**
  80565. * Unregister a function that will be executed before the physics world is stepping forward
  80566. * @param func The function to execute before the physics world is stepped forward
  80567. */
  80568. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  80569. /**
  80570. * Register a function that will be executed after the physics step
  80571. * @param func The function to execute after physics step
  80572. */
  80573. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  80574. /**
  80575. * Unregisters a function that will be executed after the physics step
  80576. * @param func The function to execute after physics step
  80577. */
  80578. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  80579. /**
  80580. * register a function that will be executed when this impostor collides against a different body
  80581. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  80582. * @param func Callback that is executed on collision
  80583. */
  80584. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  80585. /**
  80586. * Unregisters the physics imposter on contact
  80587. * @param collideAgainst The physics object to collide against
  80588. * @param func Callback to execute on collision
  80589. */
  80590. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  80591. private _tmpQuat;
  80592. private _tmpQuat2;
  80593. /**
  80594. * Get the parent rotation
  80595. * @returns The parent rotation
  80596. */
  80597. getParentsRotation(): Quaternion;
  80598. /**
  80599. * this function is executed by the physics engine.
  80600. */
  80601. beforeStep: () => void;
  80602. /**
  80603. * this function is executed by the physics engine
  80604. */
  80605. afterStep: () => void;
  80606. /**
  80607. * Legacy collision detection event support
  80608. */
  80609. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  80610. /**
  80611. * event and body object due to cannon's event-based architecture.
  80612. */
  80613. onCollide: (e: {
  80614. body: any;
  80615. }) => void;
  80616. /**
  80617. * Apply a force
  80618. * @param force The force to apply
  80619. * @param contactPoint The contact point for the force
  80620. * @returns The physics imposter
  80621. */
  80622. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  80623. /**
  80624. * Apply an impulse
  80625. * @param force The impulse force
  80626. * @param contactPoint The contact point for the impulse force
  80627. * @returns The physics imposter
  80628. */
  80629. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  80630. /**
  80631. * A help function to create a joint
  80632. * @param otherImpostor A physics imposter used to create a joint
  80633. * @param jointType The type of joint
  80634. * @param jointData The data for the joint
  80635. * @returns The physics imposter
  80636. */
  80637. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  80638. /**
  80639. * Add a joint to this impostor with a different impostor
  80640. * @param otherImpostor A physics imposter used to add a joint
  80641. * @param joint The joint to add
  80642. * @returns The physics imposter
  80643. */
  80644. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  80645. /**
  80646. * Add an anchor to a cloth impostor
  80647. * @param otherImpostor rigid impostor to anchor to
  80648. * @param width ratio across width from 0 to 1
  80649. * @param height ratio up height from 0 to 1
  80650. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  80651. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  80652. * @returns impostor the soft imposter
  80653. */
  80654. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  80655. /**
  80656. * Add a hook to a rope impostor
  80657. * @param otherImpostor rigid impostor to anchor to
  80658. * @param length ratio across rope from 0 to 1
  80659. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  80660. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  80661. * @returns impostor the rope imposter
  80662. */
  80663. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  80664. /**
  80665. * Will keep this body still, in a sleep mode.
  80666. * @returns the physics imposter
  80667. */
  80668. sleep(): PhysicsImpostor;
  80669. /**
  80670. * Wake the body up.
  80671. * @returns The physics imposter
  80672. */
  80673. wakeUp(): PhysicsImpostor;
  80674. /**
  80675. * Clones the physics imposter
  80676. * @param newObject The physics imposter clones to this physics-enabled object
  80677. * @returns A nullable physics imposter
  80678. */
  80679. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  80680. /**
  80681. * Disposes the physics imposter
  80682. */
  80683. dispose(): void;
  80684. /**
  80685. * Sets the delta position
  80686. * @param position The delta position amount
  80687. */
  80688. setDeltaPosition(position: Vector3): void;
  80689. /**
  80690. * Sets the delta rotation
  80691. * @param rotation The delta rotation amount
  80692. */
  80693. setDeltaRotation(rotation: Quaternion): void;
  80694. /**
  80695. * Gets the box size of the physics imposter and stores the result in the input parameter
  80696. * @param result Stores the box size
  80697. * @returns The physics imposter
  80698. */
  80699. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  80700. /**
  80701. * Gets the radius of the physics imposter
  80702. * @returns Radius of the physics imposter
  80703. */
  80704. getRadius(): number;
  80705. /**
  80706. * Sync a bone with this impostor
  80707. * @param bone The bone to sync to the impostor.
  80708. * @param boneMesh The mesh that the bone is influencing.
  80709. * @param jointPivot The pivot of the joint / bone in local space.
  80710. * @param distToJoint Optional distance from the impostor to the joint.
  80711. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  80712. */
  80713. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  80714. /**
  80715. * Sync impostor to a bone
  80716. * @param bone The bone that the impostor will be synced to.
  80717. * @param boneMesh The mesh that the bone is influencing.
  80718. * @param jointPivot The pivot of the joint / bone in local space.
  80719. * @param distToJoint Optional distance from the impostor to the joint.
  80720. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  80721. * @param boneAxis Optional vector3 axis the bone is aligned with
  80722. */
  80723. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  80724. /**
  80725. * No-Imposter type
  80726. */
  80727. static NoImpostor: number;
  80728. /**
  80729. * Sphere-Imposter type
  80730. */
  80731. static SphereImpostor: number;
  80732. /**
  80733. * Box-Imposter type
  80734. */
  80735. static BoxImpostor: number;
  80736. /**
  80737. * Plane-Imposter type
  80738. */
  80739. static PlaneImpostor: number;
  80740. /**
  80741. * Mesh-imposter type
  80742. */
  80743. static MeshImpostor: number;
  80744. /**
  80745. * Cylinder-Imposter type
  80746. */
  80747. static CylinderImpostor: number;
  80748. /**
  80749. * Particle-Imposter type
  80750. */
  80751. static ParticleImpostor: number;
  80752. /**
  80753. * Heightmap-Imposter type
  80754. */
  80755. static HeightmapImpostor: number;
  80756. /**
  80757. * ConvexHull-Impostor type (Ammo.js plugin only)
  80758. */
  80759. static ConvexHullImpostor: number;
  80760. /**
  80761. * Rope-Imposter type
  80762. */
  80763. static RopeImpostor: number;
  80764. /**
  80765. * Cloth-Imposter type
  80766. */
  80767. static ClothImpostor: number;
  80768. /**
  80769. * Softbody-Imposter type
  80770. */
  80771. static SoftbodyImpostor: number;
  80772. }
  80773. }
  80774. declare module BABYLON {
  80775. /**
  80776. * @hidden
  80777. **/
  80778. export class _CreationDataStorage {
  80779. closePath?: boolean;
  80780. closeArray?: boolean;
  80781. idx: number[];
  80782. dashSize: number;
  80783. gapSize: number;
  80784. path3D: Path3D;
  80785. pathArray: Vector3[][];
  80786. arc: number;
  80787. radius: number;
  80788. cap: number;
  80789. tessellation: number;
  80790. }
  80791. /**
  80792. * @hidden
  80793. **/
  80794. class _InstanceDataStorage {
  80795. visibleInstances: any;
  80796. batchCache: _InstancesBatch;
  80797. instancesBufferSize: number;
  80798. instancesBuffer: Nullable<Buffer>;
  80799. instancesData: Float32Array;
  80800. overridenInstanceCount: number;
  80801. isFrozen: boolean;
  80802. previousBatch: _InstancesBatch;
  80803. hardwareInstancedRendering: boolean;
  80804. sideOrientation: number;
  80805. }
  80806. /**
  80807. * @hidden
  80808. **/
  80809. export class _InstancesBatch {
  80810. mustReturn: boolean;
  80811. visibleInstances: Nullable<InstancedMesh[]>[];
  80812. renderSelf: boolean[];
  80813. hardwareInstancedRendering: boolean[];
  80814. }
  80815. /**
  80816. * Class used to represent renderable models
  80817. */
  80818. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  80819. /**
  80820. * Mesh side orientation : usually the external or front surface
  80821. */
  80822. static readonly FRONTSIDE: number;
  80823. /**
  80824. * Mesh side orientation : usually the internal or back surface
  80825. */
  80826. static readonly BACKSIDE: number;
  80827. /**
  80828. * Mesh side orientation : both internal and external or front and back surfaces
  80829. */
  80830. static readonly DOUBLESIDE: number;
  80831. /**
  80832. * Mesh side orientation : by default, `FRONTSIDE`
  80833. */
  80834. static readonly DEFAULTSIDE: number;
  80835. /**
  80836. * Mesh cap setting : no cap
  80837. */
  80838. static readonly NO_CAP: number;
  80839. /**
  80840. * Mesh cap setting : one cap at the beginning of the mesh
  80841. */
  80842. static readonly CAP_START: number;
  80843. /**
  80844. * Mesh cap setting : one cap at the end of the mesh
  80845. */
  80846. static readonly CAP_END: number;
  80847. /**
  80848. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  80849. */
  80850. static readonly CAP_ALL: number;
  80851. /**
  80852. * Gets the default side orientation.
  80853. * @param orientation the orientation to value to attempt to get
  80854. * @returns the default orientation
  80855. * @hidden
  80856. */
  80857. static _GetDefaultSideOrientation(orientation?: number): number;
  80858. private _internalMeshDataInfo;
  80859. /**
  80860. * An event triggered before rendering the mesh
  80861. */
  80862. readonly onBeforeRenderObservable: Observable<Mesh>;
  80863. /**
  80864. * An event triggered before binding the mesh
  80865. */
  80866. readonly onBeforeBindObservable: Observable<Mesh>;
  80867. /**
  80868. * An event triggered after rendering the mesh
  80869. */
  80870. readonly onAfterRenderObservable: Observable<Mesh>;
  80871. /**
  80872. * An event triggered before drawing the mesh
  80873. */
  80874. readonly onBeforeDrawObservable: Observable<Mesh>;
  80875. private _onBeforeDrawObserver;
  80876. /**
  80877. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  80878. */
  80879. onBeforeDraw: () => void;
  80880. /**
  80881. * Gets the delay loading state of the mesh (when delay loading is turned on)
  80882. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  80883. */
  80884. delayLoadState: number;
  80885. /**
  80886. * Gets the list of instances created from this mesh
  80887. * it is not supposed to be modified manually.
  80888. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  80889. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  80890. */
  80891. instances: InstancedMesh[];
  80892. /**
  80893. * Gets the file containing delay loading data for this mesh
  80894. */
  80895. delayLoadingFile: string;
  80896. /** @hidden */
  80897. _binaryInfo: any;
  80898. /**
  80899. * User defined function used to change how LOD level selection is done
  80900. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  80901. */
  80902. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  80903. /**
  80904. * Gets or sets the morph target manager
  80905. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  80906. */
  80907. morphTargetManager: Nullable<MorphTargetManager>;
  80908. /** @hidden */
  80909. _creationDataStorage: Nullable<_CreationDataStorage>;
  80910. /** @hidden */
  80911. _geometry: Nullable<Geometry>;
  80912. /** @hidden */
  80913. _delayInfo: Array<string>;
  80914. /** @hidden */
  80915. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  80916. /** @hidden */
  80917. _instanceDataStorage: _InstanceDataStorage;
  80918. private _effectiveMaterial;
  80919. /** @hidden */
  80920. _shouldGenerateFlatShading: boolean;
  80921. /** @hidden */
  80922. _originalBuilderSideOrientation: number;
  80923. /**
  80924. * Use this property to change the original side orientation defined at construction time
  80925. */
  80926. overrideMaterialSideOrientation: Nullable<number>;
  80927. /**
  80928. * Gets the source mesh (the one used to clone this one from)
  80929. */
  80930. readonly source: Nullable<Mesh>;
  80931. /**
  80932. * Gets or sets a boolean indicating that this mesh does not use index buffer
  80933. */
  80934. isUnIndexed: boolean;
  80935. /**
  80936. * @constructor
  80937. * @param name The value used by scene.getMeshByName() to do a lookup.
  80938. * @param scene The scene to add this mesh to.
  80939. * @param parent The parent of this mesh, if it has one
  80940. * @param source An optional Mesh from which geometry is shared, cloned.
  80941. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  80942. * When false, achieved by calling a clone(), also passing False.
  80943. * This will make creation of children, recursive.
  80944. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  80945. */
  80946. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  80947. /**
  80948. * Gets the class name
  80949. * @returns the string "Mesh".
  80950. */
  80951. getClassName(): string;
  80952. /** @hidden */
  80953. readonly _isMesh: boolean;
  80954. /**
  80955. * Returns a description of this mesh
  80956. * @param fullDetails define if full details about this mesh must be used
  80957. * @returns a descriptive string representing this mesh
  80958. */
  80959. toString(fullDetails?: boolean): string;
  80960. /** @hidden */
  80961. _unBindEffect(): void;
  80962. /**
  80963. * Gets a boolean indicating if this mesh has LOD
  80964. */
  80965. readonly hasLODLevels: boolean;
  80966. /**
  80967. * Gets the list of MeshLODLevel associated with the current mesh
  80968. * @returns an array of MeshLODLevel
  80969. */
  80970. getLODLevels(): MeshLODLevel[];
  80971. private _sortLODLevels;
  80972. /**
  80973. * Add a mesh as LOD level triggered at the given distance.
  80974. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  80975. * @param distance The distance from the center of the object to show this level
  80976. * @param mesh The mesh to be added as LOD level (can be null)
  80977. * @return This mesh (for chaining)
  80978. */
  80979. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  80980. /**
  80981. * Returns the LOD level mesh at the passed distance or null if not found.
  80982. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  80983. * @param distance The distance from the center of the object to show this level
  80984. * @returns a Mesh or `null`
  80985. */
  80986. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  80987. /**
  80988. * Remove a mesh from the LOD array
  80989. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  80990. * @param mesh defines the mesh to be removed
  80991. * @return This mesh (for chaining)
  80992. */
  80993. removeLODLevel(mesh: Mesh): Mesh;
  80994. /**
  80995. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  80996. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  80997. * @param camera defines the camera to use to compute distance
  80998. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  80999. * @return This mesh (for chaining)
  81000. */
  81001. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  81002. /**
  81003. * Gets the mesh internal Geometry object
  81004. */
  81005. readonly geometry: Nullable<Geometry>;
  81006. /**
  81007. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  81008. * @returns the total number of vertices
  81009. */
  81010. getTotalVertices(): number;
  81011. /**
  81012. * Returns the content of an associated vertex buffer
  81013. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  81014. * - VertexBuffer.PositionKind
  81015. * - VertexBuffer.UVKind
  81016. * - VertexBuffer.UV2Kind
  81017. * - VertexBuffer.UV3Kind
  81018. * - VertexBuffer.UV4Kind
  81019. * - VertexBuffer.UV5Kind
  81020. * - VertexBuffer.UV6Kind
  81021. * - VertexBuffer.ColorKind
  81022. * - VertexBuffer.MatricesIndicesKind
  81023. * - VertexBuffer.MatricesIndicesExtraKind
  81024. * - VertexBuffer.MatricesWeightsKind
  81025. * - VertexBuffer.MatricesWeightsExtraKind
  81026. * @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
  81027. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  81028. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  81029. */
  81030. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  81031. /**
  81032. * Returns the mesh VertexBuffer object from the requested `kind`
  81033. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  81034. * - VertexBuffer.PositionKind
  81035. * - VertexBuffer.UVKind
  81036. * - VertexBuffer.UV2Kind
  81037. * - VertexBuffer.UV3Kind
  81038. * - VertexBuffer.UV4Kind
  81039. * - VertexBuffer.UV5Kind
  81040. * - VertexBuffer.UV6Kind
  81041. * - VertexBuffer.ColorKind
  81042. * - VertexBuffer.MatricesIndicesKind
  81043. * - VertexBuffer.MatricesIndicesExtraKind
  81044. * - VertexBuffer.MatricesWeightsKind
  81045. * - VertexBuffer.MatricesWeightsExtraKind
  81046. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  81047. */
  81048. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  81049. /**
  81050. * Tests if a specific vertex buffer is associated with this mesh
  81051. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  81052. * - VertexBuffer.PositionKind
  81053. * - VertexBuffer.UVKind
  81054. * - VertexBuffer.UV2Kind
  81055. * - VertexBuffer.UV3Kind
  81056. * - VertexBuffer.UV4Kind
  81057. * - VertexBuffer.UV5Kind
  81058. * - VertexBuffer.UV6Kind
  81059. * - VertexBuffer.ColorKind
  81060. * - VertexBuffer.MatricesIndicesKind
  81061. * - VertexBuffer.MatricesIndicesExtraKind
  81062. * - VertexBuffer.MatricesWeightsKind
  81063. * - VertexBuffer.MatricesWeightsExtraKind
  81064. * @returns a boolean
  81065. */
  81066. isVerticesDataPresent(kind: string): boolean;
  81067. /**
  81068. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  81069. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  81070. * - VertexBuffer.PositionKind
  81071. * - VertexBuffer.UVKind
  81072. * - VertexBuffer.UV2Kind
  81073. * - VertexBuffer.UV3Kind
  81074. * - VertexBuffer.UV4Kind
  81075. * - VertexBuffer.UV5Kind
  81076. * - VertexBuffer.UV6Kind
  81077. * - VertexBuffer.ColorKind
  81078. * - VertexBuffer.MatricesIndicesKind
  81079. * - VertexBuffer.MatricesIndicesExtraKind
  81080. * - VertexBuffer.MatricesWeightsKind
  81081. * - VertexBuffer.MatricesWeightsExtraKind
  81082. * @returns a boolean
  81083. */
  81084. isVertexBufferUpdatable(kind: string): boolean;
  81085. /**
  81086. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  81087. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  81088. * - VertexBuffer.PositionKind
  81089. * - VertexBuffer.UVKind
  81090. * - VertexBuffer.UV2Kind
  81091. * - VertexBuffer.UV3Kind
  81092. * - VertexBuffer.UV4Kind
  81093. * - VertexBuffer.UV5Kind
  81094. * - VertexBuffer.UV6Kind
  81095. * - VertexBuffer.ColorKind
  81096. * - VertexBuffer.MatricesIndicesKind
  81097. * - VertexBuffer.MatricesIndicesExtraKind
  81098. * - VertexBuffer.MatricesWeightsKind
  81099. * - VertexBuffer.MatricesWeightsExtraKind
  81100. * @returns an array of strings
  81101. */
  81102. getVerticesDataKinds(): string[];
  81103. /**
  81104. * Returns a positive integer : the total number of indices in this mesh geometry.
  81105. * @returns the numner of indices or zero if the mesh has no geometry.
  81106. */
  81107. getTotalIndices(): number;
  81108. /**
  81109. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  81110. * @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.
  81111. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  81112. * @returns the indices array or an empty array if the mesh has no geometry
  81113. */
  81114. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  81115. readonly isBlocked: boolean;
  81116. /**
  81117. * Determine if the current mesh is ready to be rendered
  81118. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  81119. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  81120. * @returns true if all associated assets are ready (material, textures, shaders)
  81121. */
  81122. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  81123. /**
  81124. * 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.
  81125. */
  81126. readonly areNormalsFrozen: boolean;
  81127. /**
  81128. * 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.
  81129. * @returns the current mesh
  81130. */
  81131. freezeNormals(): Mesh;
  81132. /**
  81133. * 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
  81134. * @returns the current mesh
  81135. */
  81136. unfreezeNormals(): Mesh;
  81137. /**
  81138. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  81139. */
  81140. overridenInstanceCount: number;
  81141. /** @hidden */
  81142. _preActivate(): Mesh;
  81143. /** @hidden */
  81144. _preActivateForIntermediateRendering(renderId: number): Mesh;
  81145. /** @hidden */
  81146. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  81147. /**
  81148. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  81149. * This means the mesh underlying bounding box and sphere are recomputed.
  81150. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  81151. * @returns the current mesh
  81152. */
  81153. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  81154. /** @hidden */
  81155. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  81156. /**
  81157. * This function will subdivide the mesh into multiple submeshes
  81158. * @param count defines the expected number of submeshes
  81159. */
  81160. subdivide(count: number): void;
  81161. /**
  81162. * Copy a FloatArray into a specific associated vertex buffer
  81163. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  81164. * - VertexBuffer.PositionKind
  81165. * - VertexBuffer.UVKind
  81166. * - VertexBuffer.UV2Kind
  81167. * - VertexBuffer.UV3Kind
  81168. * - VertexBuffer.UV4Kind
  81169. * - VertexBuffer.UV5Kind
  81170. * - VertexBuffer.UV6Kind
  81171. * - VertexBuffer.ColorKind
  81172. * - VertexBuffer.MatricesIndicesKind
  81173. * - VertexBuffer.MatricesIndicesExtraKind
  81174. * - VertexBuffer.MatricesWeightsKind
  81175. * - VertexBuffer.MatricesWeightsExtraKind
  81176. * @param data defines the data source
  81177. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  81178. * @param stride defines the data stride size (can be null)
  81179. * @returns the current mesh
  81180. */
  81181. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  81182. /**
  81183. * Flags an associated vertex buffer as updatable
  81184. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  81185. * - VertexBuffer.PositionKind
  81186. * - VertexBuffer.UVKind
  81187. * - VertexBuffer.UV2Kind
  81188. * - VertexBuffer.UV3Kind
  81189. * - VertexBuffer.UV4Kind
  81190. * - VertexBuffer.UV5Kind
  81191. * - VertexBuffer.UV6Kind
  81192. * - VertexBuffer.ColorKind
  81193. * - VertexBuffer.MatricesIndicesKind
  81194. * - VertexBuffer.MatricesIndicesExtraKind
  81195. * - VertexBuffer.MatricesWeightsKind
  81196. * - VertexBuffer.MatricesWeightsExtraKind
  81197. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  81198. */
  81199. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  81200. /**
  81201. * Sets the mesh global Vertex Buffer
  81202. * @param buffer defines the buffer to use
  81203. * @returns the current mesh
  81204. */
  81205. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  81206. /**
  81207. * Update a specific associated vertex buffer
  81208. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  81209. * - VertexBuffer.PositionKind
  81210. * - VertexBuffer.UVKind
  81211. * - VertexBuffer.UV2Kind
  81212. * - VertexBuffer.UV3Kind
  81213. * - VertexBuffer.UV4Kind
  81214. * - VertexBuffer.UV5Kind
  81215. * - VertexBuffer.UV6Kind
  81216. * - VertexBuffer.ColorKind
  81217. * - VertexBuffer.MatricesIndicesKind
  81218. * - VertexBuffer.MatricesIndicesExtraKind
  81219. * - VertexBuffer.MatricesWeightsKind
  81220. * - VertexBuffer.MatricesWeightsExtraKind
  81221. * @param data defines the data source
  81222. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  81223. * @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)
  81224. * @returns the current mesh
  81225. */
  81226. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  81227. /**
  81228. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  81229. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  81230. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  81231. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  81232. * @returns the current mesh
  81233. */
  81234. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  81235. /**
  81236. * Creates a un-shared specific occurence of the geometry for the mesh.
  81237. * @returns the current mesh
  81238. */
  81239. makeGeometryUnique(): Mesh;
  81240. /**
  81241. * Set the index buffer of this mesh
  81242. * @param indices defines the source data
  81243. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  81244. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  81245. * @returns the current mesh
  81246. */
  81247. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  81248. /**
  81249. * Update the current index buffer
  81250. * @param indices defines the source data
  81251. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  81252. * @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)
  81253. * @returns the current mesh
  81254. */
  81255. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  81256. /**
  81257. * Invert the geometry to move from a right handed system to a left handed one.
  81258. * @returns the current mesh
  81259. */
  81260. toLeftHanded(): Mesh;
  81261. /** @hidden */
  81262. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  81263. /** @hidden */
  81264. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  81265. /**
  81266. * Registers for this mesh a javascript function called just before the rendering process
  81267. * @param func defines the function to call before rendering this mesh
  81268. * @returns the current mesh
  81269. */
  81270. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  81271. /**
  81272. * Disposes a previously registered javascript function called before the rendering
  81273. * @param func defines the function to remove
  81274. * @returns the current mesh
  81275. */
  81276. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  81277. /**
  81278. * Registers for this mesh a javascript function called just after the rendering is complete
  81279. * @param func defines the function to call after rendering this mesh
  81280. * @returns the current mesh
  81281. */
  81282. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  81283. /**
  81284. * Disposes a previously registered javascript function called after the rendering.
  81285. * @param func defines the function to remove
  81286. * @returns the current mesh
  81287. */
  81288. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  81289. /** @hidden */
  81290. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  81291. /** @hidden */
  81292. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  81293. /** @hidden */
  81294. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  81295. /** @hidden */
  81296. _freeze(): void;
  81297. /** @hidden */
  81298. _unFreeze(): void;
  81299. /**
  81300. * 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
  81301. * @param subMesh defines the subMesh to render
  81302. * @param enableAlphaMode defines if alpha mode can be changed
  81303. * @returns the current mesh
  81304. */
  81305. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  81306. private _onBeforeDraw;
  81307. /**
  81308. * Renormalize the mesh and patch it up if there are no weights
  81309. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  81310. * However in the case of zero weights then we set just a single influence to 1.
  81311. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  81312. */
  81313. cleanMatrixWeights(): void;
  81314. private normalizeSkinFourWeights;
  81315. private normalizeSkinWeightsAndExtra;
  81316. /**
  81317. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  81318. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  81319. * the user know there was an issue with importing the mesh
  81320. * @returns a validation object with skinned, valid and report string
  81321. */
  81322. validateSkinning(): {
  81323. skinned: boolean;
  81324. valid: boolean;
  81325. report: string;
  81326. };
  81327. /** @hidden */
  81328. _checkDelayState(): Mesh;
  81329. private _queueLoad;
  81330. /**
  81331. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  81332. * A mesh is in the frustum if its bounding box intersects the frustum
  81333. * @param frustumPlanes defines the frustum to test
  81334. * @returns true if the mesh is in the frustum planes
  81335. */
  81336. isInFrustum(frustumPlanes: Plane[]): boolean;
  81337. /**
  81338. * Sets the mesh material by the material or multiMaterial `id` property
  81339. * @param id is a string identifying the material or the multiMaterial
  81340. * @returns the current mesh
  81341. */
  81342. setMaterialByID(id: string): Mesh;
  81343. /**
  81344. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  81345. * @returns an array of IAnimatable
  81346. */
  81347. getAnimatables(): IAnimatable[];
  81348. /**
  81349. * Modifies the mesh geometry according to the passed transformation matrix.
  81350. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  81351. * The mesh normals are modified using the same transformation.
  81352. * Note that, under the hood, this method sets a new VertexBuffer each call.
  81353. * @param transform defines the transform matrix to use
  81354. * @see http://doc.babylonjs.com/resources/baking_transformations
  81355. * @returns the current mesh
  81356. */
  81357. bakeTransformIntoVertices(transform: Matrix): Mesh;
  81358. /**
  81359. * Modifies the mesh geometry according to its own current World Matrix.
  81360. * The mesh World Matrix is then reset.
  81361. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  81362. * Note that, under the hood, this method sets a new VertexBuffer each call.
  81363. * @see http://doc.babylonjs.com/resources/baking_transformations
  81364. * @returns the current mesh
  81365. */
  81366. bakeCurrentTransformIntoVertices(): Mesh;
  81367. /** @hidden */
  81368. readonly _positions: Nullable<Vector3[]>;
  81369. /** @hidden */
  81370. _resetPointsArrayCache(): Mesh;
  81371. /** @hidden */
  81372. _generatePointsArray(): boolean;
  81373. /**
  81374. * Returns a new Mesh object generated from the current mesh properties.
  81375. * This method must not get confused with createInstance()
  81376. * @param name is a string, the name given to the new mesh
  81377. * @param newParent can be any Node object (default `null`)
  81378. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  81379. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  81380. * @returns a new mesh
  81381. */
  81382. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  81383. /**
  81384. * Releases resources associated with this mesh.
  81385. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  81386. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  81387. */
  81388. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  81389. /**
  81390. * Modifies the mesh geometry according to a displacement map.
  81391. * 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.
  81392. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  81393. * @param url is a string, the URL from the image file is to be downloaded.
  81394. * @param minHeight is the lower limit of the displacement.
  81395. * @param maxHeight is the upper limit of the displacement.
  81396. * @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.
  81397. * @param uvOffset is an optional vector2 used to offset UV.
  81398. * @param uvScale is an optional vector2 used to scale UV.
  81399. * @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.
  81400. * @returns the Mesh.
  81401. */
  81402. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  81403. /**
  81404. * Modifies the mesh geometry according to a displacementMap buffer.
  81405. * 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.
  81406. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  81407. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  81408. * @param heightMapWidth is the width of the buffer image.
  81409. * @param heightMapHeight is the height of the buffer image.
  81410. * @param minHeight is the lower limit of the displacement.
  81411. * @param maxHeight is the upper limit of the displacement.
  81412. * @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.
  81413. * @param uvOffset is an optional vector2 used to offset UV.
  81414. * @param uvScale is an optional vector2 used to scale UV.
  81415. * @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.
  81416. * @returns the Mesh.
  81417. */
  81418. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  81419. /**
  81420. * Modify the mesh to get a flat shading rendering.
  81421. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  81422. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  81423. * @returns current mesh
  81424. */
  81425. convertToFlatShadedMesh(): Mesh;
  81426. /**
  81427. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  81428. * In other words, more vertices, no more indices and a single bigger VBO.
  81429. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  81430. * @returns current mesh
  81431. */
  81432. convertToUnIndexedMesh(): Mesh;
  81433. /**
  81434. * Inverses facet orientations.
  81435. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  81436. * @param flipNormals will also inverts the normals
  81437. * @returns current mesh
  81438. */
  81439. flipFaces(flipNormals?: boolean): Mesh;
  81440. /**
  81441. * Increase the number of facets and hence vertices in a mesh
  81442. * Vertex normals are interpolated from existing vertex normals
  81443. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  81444. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  81445. */
  81446. increaseVertices(numberPerEdge: number): void;
  81447. /**
  81448. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  81449. * This will undo any application of covertToFlatShadedMesh
  81450. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  81451. */
  81452. forceSharedVertices(): void;
  81453. /** @hidden */
  81454. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  81455. /** @hidden */
  81456. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  81457. /**
  81458. * Creates a new InstancedMesh object from the mesh model.
  81459. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  81460. * @param name defines the name of the new instance
  81461. * @returns a new InstancedMesh
  81462. */
  81463. createInstance(name: string): InstancedMesh;
  81464. /**
  81465. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  81466. * After this call, all the mesh instances have the same submeshes than the current mesh.
  81467. * @returns the current mesh
  81468. */
  81469. synchronizeInstances(): Mesh;
  81470. /**
  81471. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  81472. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  81473. * This should be used together with the simplification to avoid disappearing triangles.
  81474. * @param successCallback an optional success callback to be called after the optimization finished.
  81475. * @returns the current mesh
  81476. */
  81477. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  81478. /**
  81479. * Serialize current mesh
  81480. * @param serializationObject defines the object which will receive the serialization data
  81481. */
  81482. serialize(serializationObject: any): void;
  81483. /** @hidden */
  81484. _syncGeometryWithMorphTargetManager(): void;
  81485. /** @hidden */
  81486. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  81487. /**
  81488. * Returns a new Mesh object parsed from the source provided.
  81489. * @param parsedMesh is the source
  81490. * @param scene defines the hosting scene
  81491. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  81492. * @returns a new Mesh
  81493. */
  81494. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  81495. /**
  81496. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  81497. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  81498. * @param name defines the name of the mesh to create
  81499. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  81500. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  81501. * @param closePath creates a seam between the first and the last points of each path of the path array
  81502. * @param offset is taken in account only if the `pathArray` is containing a single path
  81503. * @param scene defines the hosting scene
  81504. * @param updatable defines if the mesh must be flagged as updatable
  81505. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81506. * @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)
  81507. * @returns a new Mesh
  81508. */
  81509. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  81510. /**
  81511. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  81512. * @param name defines the name of the mesh to create
  81513. * @param radius sets the radius size (float) of the polygon (default 0.5)
  81514. * @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
  81515. * @param scene defines the hosting scene
  81516. * @param updatable defines if the mesh must be flagged as updatable
  81517. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81518. * @returns a new Mesh
  81519. */
  81520. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  81521. /**
  81522. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  81523. * @param name defines the name of the mesh to create
  81524. * @param size sets the size (float) of each box side (default 1)
  81525. * @param scene defines the hosting scene
  81526. * @param updatable defines if the mesh must be flagged as updatable
  81527. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81528. * @returns a new Mesh
  81529. */
  81530. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  81531. /**
  81532. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  81533. * @param name defines the name of the mesh to create
  81534. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  81535. * @param diameter sets the diameter size (float) of the sphere (default 1)
  81536. * @param scene defines the hosting scene
  81537. * @param updatable defines if the mesh must be flagged as updatable
  81538. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81539. * @returns a new Mesh
  81540. */
  81541. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  81542. /**
  81543. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  81544. * @param name defines the name of the mesh to create
  81545. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  81546. * @param diameter sets the diameter size (float) of the sphere (default 1)
  81547. * @param scene defines the hosting scene
  81548. * @returns a new Mesh
  81549. */
  81550. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  81551. /**
  81552. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  81553. * @param name defines the name of the mesh to create
  81554. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  81555. * @param diameterTop set the top cap diameter (floats, default 1)
  81556. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  81557. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  81558. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  81559. * @param scene defines the hosting scene
  81560. * @param updatable defines if the mesh must be flagged as updatable
  81561. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81562. * @returns a new Mesh
  81563. */
  81564. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  81565. /**
  81566. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  81567. * @param name defines the name of the mesh to create
  81568. * @param diameter sets the diameter size (float) of the torus (default 1)
  81569. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  81570. * @param tessellation sets the number of torus sides (postive integer, default 16)
  81571. * @param scene defines the hosting scene
  81572. * @param updatable defines if the mesh must be flagged as updatable
  81573. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81574. * @returns a new Mesh
  81575. */
  81576. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  81577. /**
  81578. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  81579. * @param name defines the name of the mesh to create
  81580. * @param radius sets the global radius size (float) of the torus knot (default 2)
  81581. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  81582. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  81583. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  81584. * @param p the number of windings on X axis (positive integers, default 2)
  81585. * @param q the number of windings on Y axis (positive integers, default 3)
  81586. * @param scene defines the hosting scene
  81587. * @param updatable defines if the mesh must be flagged as updatable
  81588. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81589. * @returns a new Mesh
  81590. */
  81591. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  81592. /**
  81593. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  81594. * @param name defines the name of the mesh to create
  81595. * @param points is an array successive Vector3
  81596. * @param scene defines the hosting scene
  81597. * @param updatable defines if the mesh must be flagged as updatable
  81598. * @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).
  81599. * @returns a new Mesh
  81600. */
  81601. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  81602. /**
  81603. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  81604. * @param name defines the name of the mesh to create
  81605. * @param points is an array successive Vector3
  81606. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  81607. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  81608. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  81609. * @param scene defines the hosting scene
  81610. * @param updatable defines if the mesh must be flagged as updatable
  81611. * @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)
  81612. * @returns a new Mesh
  81613. */
  81614. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  81615. /**
  81616. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  81617. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  81618. * 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.
  81619. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81620. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  81621. * Remember you can only change the shape positions, not their number when updating a polygon.
  81622. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  81623. * @param name defines the name of the mesh to create
  81624. * @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
  81625. * @param scene defines the hosting scene
  81626. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  81627. * @param updatable defines if the mesh must be flagged as updatable
  81628. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81629. * @param earcutInjection can be used to inject your own earcut reference
  81630. * @returns a new Mesh
  81631. */
  81632. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  81633. /**
  81634. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  81635. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  81636. * @param name defines the name of the mesh to create
  81637. * @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
  81638. * @param depth defines the height of extrusion
  81639. * @param scene defines the hosting scene
  81640. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  81641. * @param updatable defines if the mesh must be flagged as updatable
  81642. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81643. * @param earcutInjection can be used to inject your own earcut reference
  81644. * @returns a new Mesh
  81645. */
  81646. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  81647. /**
  81648. * Creates an extruded shape mesh.
  81649. * 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
  81650. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  81651. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  81652. * @param name defines the name of the mesh to create
  81653. * @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
  81654. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  81655. * @param scale is the value to scale the shape
  81656. * @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
  81657. * @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
  81658. * @param scene defines the hosting scene
  81659. * @param updatable defines if the mesh must be flagged as updatable
  81660. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81661. * @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)
  81662. * @returns a new Mesh
  81663. */
  81664. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  81665. /**
  81666. * Creates an custom extruded shape mesh.
  81667. * The custom extrusion is a parametric shape.
  81668. * It has no predefined shape. Its final shape will depend on the input parameters.
  81669. * Please consider using the same method from the MeshBuilder class instead
  81670. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  81671. * @param name defines the name of the mesh to create
  81672. * @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
  81673. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  81674. * @param scaleFunction is a custom Javascript function called on each path point
  81675. * @param rotationFunction is a custom Javascript function called on each path point
  81676. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  81677. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  81678. * @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
  81679. * @param scene defines the hosting scene
  81680. * @param updatable defines if the mesh must be flagged as updatable
  81681. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81682. * @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)
  81683. * @returns a new Mesh
  81684. */
  81685. 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;
  81686. /**
  81687. * Creates lathe mesh.
  81688. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  81689. * Please consider using the same method from the MeshBuilder class instead
  81690. * @param name defines the name of the mesh to create
  81691. * @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
  81692. * @param radius is the radius value of the lathe
  81693. * @param tessellation is the side number of the lathe.
  81694. * @param scene defines the hosting scene
  81695. * @param updatable defines if the mesh must be flagged as updatable
  81696. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81697. * @returns a new Mesh
  81698. */
  81699. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  81700. /**
  81701. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  81702. * @param name defines the name of the mesh to create
  81703. * @param size sets the size (float) of both sides of the plane at once (default 1)
  81704. * @param scene defines the hosting scene
  81705. * @param updatable defines if the mesh must be flagged as updatable
  81706. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81707. * @returns a new Mesh
  81708. */
  81709. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  81710. /**
  81711. * Creates a ground mesh.
  81712. * Please consider using the same method from the MeshBuilder class instead
  81713. * @param name defines the name of the mesh to create
  81714. * @param width set the width of the ground
  81715. * @param height set the height of the ground
  81716. * @param subdivisions sets the number of subdivisions per side
  81717. * @param scene defines the hosting scene
  81718. * @param updatable defines if the mesh must be flagged as updatable
  81719. * @returns a new Mesh
  81720. */
  81721. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  81722. /**
  81723. * Creates a tiled ground mesh.
  81724. * Please consider using the same method from the MeshBuilder class instead
  81725. * @param name defines the name of the mesh to create
  81726. * @param xmin set the ground minimum X coordinate
  81727. * @param zmin set the ground minimum Y coordinate
  81728. * @param xmax set the ground maximum X coordinate
  81729. * @param zmax set the ground maximum Z coordinate
  81730. * @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
  81731. * @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
  81732. * @param scene defines the hosting scene
  81733. * @param updatable defines if the mesh must be flagged as updatable
  81734. * @returns a new Mesh
  81735. */
  81736. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  81737. w: number;
  81738. h: number;
  81739. }, precision: {
  81740. w: number;
  81741. h: number;
  81742. }, scene: Scene, updatable?: boolean): Mesh;
  81743. /**
  81744. * Creates a ground mesh from a height map.
  81745. * Please consider using the same method from the MeshBuilder class instead
  81746. * @see http://doc.babylonjs.com/babylon101/height_map
  81747. * @param name defines the name of the mesh to create
  81748. * @param url sets the URL of the height map image resource
  81749. * @param width set the ground width size
  81750. * @param height set the ground height size
  81751. * @param subdivisions sets the number of subdivision per side
  81752. * @param minHeight is the minimum altitude on the ground
  81753. * @param maxHeight is the maximum altitude on the ground
  81754. * @param scene defines the hosting scene
  81755. * @param updatable defines if the mesh must be flagged as updatable
  81756. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  81757. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  81758. * @returns a new Mesh
  81759. */
  81760. 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;
  81761. /**
  81762. * Creates a tube mesh.
  81763. * The tube is a parametric shape.
  81764. * It has no predefined shape. Its final shape will depend on the input parameters.
  81765. * Please consider using the same method from the MeshBuilder class instead
  81766. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  81767. * @param name defines the name of the mesh to create
  81768. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  81769. * @param radius sets the tube radius size
  81770. * @param tessellation is the number of sides on the tubular surface
  81771. * @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
  81772. * @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
  81773. * @param scene defines the hosting scene
  81774. * @param updatable defines if the mesh must be flagged as updatable
  81775. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81776. * @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)
  81777. * @returns a new Mesh
  81778. */
  81779. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  81780. (i: number, distance: number): number;
  81781. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  81782. /**
  81783. * Creates a polyhedron mesh.
  81784. * Please consider using the same method from the MeshBuilder class instead.
  81785. * * 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
  81786. * * The parameter `size` (positive float, default 1) sets the polygon size
  81787. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  81788. * * 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`
  81789. * * 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
  81790. * * 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)`)
  81791. * * 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
  81792. * * 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
  81793. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81794. * * If you create a double-sided mesh, you can choose what parts of 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
  81795. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  81796. * @param name defines the name of the mesh to create
  81797. * @param options defines the options used to create the mesh
  81798. * @param scene defines the hosting scene
  81799. * @returns a new Mesh
  81800. */
  81801. static CreatePolyhedron(name: string, options: {
  81802. type?: number;
  81803. size?: number;
  81804. sizeX?: number;
  81805. sizeY?: number;
  81806. sizeZ?: number;
  81807. custom?: any;
  81808. faceUV?: Vector4[];
  81809. faceColors?: Color4[];
  81810. updatable?: boolean;
  81811. sideOrientation?: number;
  81812. }, scene: Scene): Mesh;
  81813. /**
  81814. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  81815. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  81816. * * 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`)
  81817. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  81818. * * 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
  81819. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81820. * * If you create a double-sided mesh, you can choose what parts of 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
  81821. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  81822. * @param name defines the name of the mesh
  81823. * @param options defines the options used to create the mesh
  81824. * @param scene defines the hosting scene
  81825. * @returns a new Mesh
  81826. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  81827. */
  81828. static CreateIcoSphere(name: string, options: {
  81829. radius?: number;
  81830. flat?: boolean;
  81831. subdivisions?: number;
  81832. sideOrientation?: number;
  81833. updatable?: boolean;
  81834. }, scene: Scene): Mesh;
  81835. /**
  81836. * Creates a decal mesh.
  81837. * Please consider using the same method from the MeshBuilder class instead.
  81838. * A decal is a mesh usually applied as a model onto the surface of another mesh
  81839. * @param name defines the name of the mesh
  81840. * @param sourceMesh defines the mesh receiving the decal
  81841. * @param position sets the position of the decal in world coordinates
  81842. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  81843. * @param size sets the decal scaling
  81844. * @param angle sets the angle to rotate the decal
  81845. * @returns a new Mesh
  81846. */
  81847. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  81848. /**
  81849. * Prepare internal position array for software CPU skinning
  81850. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  81851. */
  81852. setPositionsForCPUSkinning(): Float32Array;
  81853. /**
  81854. * Prepare internal normal array for software CPU skinning
  81855. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  81856. */
  81857. setNormalsForCPUSkinning(): Float32Array;
  81858. /**
  81859. * Updates the vertex buffer by applying transformation from the bones
  81860. * @param skeleton defines the skeleton to apply to current mesh
  81861. * @returns the current mesh
  81862. */
  81863. applySkeleton(skeleton: Skeleton): Mesh;
  81864. /**
  81865. * 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
  81866. * @param meshes defines the list of meshes to scan
  81867. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  81868. */
  81869. static MinMax(meshes: AbstractMesh[]): {
  81870. min: Vector3;
  81871. max: Vector3;
  81872. };
  81873. /**
  81874. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  81875. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  81876. * @returns a vector3
  81877. */
  81878. static Center(meshesOrMinMaxVector: {
  81879. min: Vector3;
  81880. max: Vector3;
  81881. } | AbstractMesh[]): Vector3;
  81882. /**
  81883. * Merge the array of meshes into a single mesh for performance reasons.
  81884. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  81885. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  81886. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  81887. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  81888. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  81889. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  81890. * @returns a new mesh
  81891. */
  81892. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  81893. /** @hidden */
  81894. addInstance(instance: InstancedMesh): void;
  81895. /** @hidden */
  81896. removeInstance(instance: InstancedMesh): void;
  81897. }
  81898. }
  81899. declare module BABYLON {
  81900. /**
  81901. * Base class for the main features of a material in Babylon.js
  81902. */
  81903. export class Material implements IAnimatable {
  81904. /**
  81905. * Returns the triangle fill mode
  81906. */
  81907. static readonly TriangleFillMode: number;
  81908. /**
  81909. * Returns the wireframe mode
  81910. */
  81911. static readonly WireFrameFillMode: number;
  81912. /**
  81913. * Returns the point fill mode
  81914. */
  81915. static readonly PointFillMode: number;
  81916. /**
  81917. * Returns the point list draw mode
  81918. */
  81919. static readonly PointListDrawMode: number;
  81920. /**
  81921. * Returns the line list draw mode
  81922. */
  81923. static readonly LineListDrawMode: number;
  81924. /**
  81925. * Returns the line loop draw mode
  81926. */
  81927. static readonly LineLoopDrawMode: number;
  81928. /**
  81929. * Returns the line strip draw mode
  81930. */
  81931. static readonly LineStripDrawMode: number;
  81932. /**
  81933. * Returns the triangle strip draw mode
  81934. */
  81935. static readonly TriangleStripDrawMode: number;
  81936. /**
  81937. * Returns the triangle fan draw mode
  81938. */
  81939. static readonly TriangleFanDrawMode: number;
  81940. /**
  81941. * Stores the clock-wise side orientation
  81942. */
  81943. static readonly ClockWiseSideOrientation: number;
  81944. /**
  81945. * Stores the counter clock-wise side orientation
  81946. */
  81947. static readonly CounterClockWiseSideOrientation: number;
  81948. /**
  81949. * The dirty texture flag value
  81950. */
  81951. static readonly TextureDirtyFlag: number;
  81952. /**
  81953. * The dirty light flag value
  81954. */
  81955. static readonly LightDirtyFlag: number;
  81956. /**
  81957. * The dirty fresnel flag value
  81958. */
  81959. static readonly FresnelDirtyFlag: number;
  81960. /**
  81961. * The dirty attribute flag value
  81962. */
  81963. static readonly AttributesDirtyFlag: number;
  81964. /**
  81965. * The dirty misc flag value
  81966. */
  81967. static readonly MiscDirtyFlag: number;
  81968. /**
  81969. * The all dirty flag value
  81970. */
  81971. static readonly AllDirtyFlag: number;
  81972. /**
  81973. * The ID of the material
  81974. */
  81975. id: string;
  81976. /**
  81977. * Gets or sets the unique id of the material
  81978. */
  81979. uniqueId: number;
  81980. /**
  81981. * The name of the material
  81982. */
  81983. name: string;
  81984. /**
  81985. * Gets or sets user defined metadata
  81986. */
  81987. metadata: any;
  81988. /**
  81989. * For internal use only. Please do not use.
  81990. */
  81991. reservedDataStore: any;
  81992. /**
  81993. * Specifies if the ready state should be checked on each call
  81994. */
  81995. checkReadyOnEveryCall: boolean;
  81996. /**
  81997. * Specifies if the ready state should be checked once
  81998. */
  81999. checkReadyOnlyOnce: boolean;
  82000. /**
  82001. * The state of the material
  82002. */
  82003. state: string;
  82004. /**
  82005. * The alpha value of the material
  82006. */
  82007. protected _alpha: number;
  82008. /**
  82009. * List of inspectable custom properties (used by the Inspector)
  82010. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  82011. */
  82012. inspectableCustomProperties: IInspectable[];
  82013. /**
  82014. * Sets the alpha value of the material
  82015. */
  82016. /**
  82017. * Gets the alpha value of the material
  82018. */
  82019. alpha: number;
  82020. /**
  82021. * Specifies if back face culling is enabled
  82022. */
  82023. protected _backFaceCulling: boolean;
  82024. /**
  82025. * Sets the back-face culling state
  82026. */
  82027. /**
  82028. * Gets the back-face culling state
  82029. */
  82030. backFaceCulling: boolean;
  82031. /**
  82032. * Stores the value for side orientation
  82033. */
  82034. sideOrientation: number;
  82035. /**
  82036. * Callback triggered when the material is compiled
  82037. */
  82038. onCompiled: Nullable<(effect: Effect) => void>;
  82039. /**
  82040. * Callback triggered when an error occurs
  82041. */
  82042. onError: Nullable<(effect: Effect, errors: string) => void>;
  82043. /**
  82044. * Callback triggered to get the render target textures
  82045. */
  82046. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  82047. /**
  82048. * Gets a boolean indicating that current material needs to register RTT
  82049. */
  82050. readonly hasRenderTargetTextures: boolean;
  82051. /**
  82052. * Specifies if the material should be serialized
  82053. */
  82054. doNotSerialize: boolean;
  82055. /**
  82056. * @hidden
  82057. */
  82058. _storeEffectOnSubMeshes: boolean;
  82059. /**
  82060. * Stores the animations for the material
  82061. */
  82062. animations: Nullable<Array<Animation>>;
  82063. /**
  82064. * An event triggered when the material is disposed
  82065. */
  82066. onDisposeObservable: Observable<Material>;
  82067. /**
  82068. * An observer which watches for dispose events
  82069. */
  82070. private _onDisposeObserver;
  82071. private _onUnBindObservable;
  82072. /**
  82073. * Called during a dispose event
  82074. */
  82075. onDispose: () => void;
  82076. private _onBindObservable;
  82077. /**
  82078. * An event triggered when the material is bound
  82079. */
  82080. readonly onBindObservable: Observable<AbstractMesh>;
  82081. /**
  82082. * An observer which watches for bind events
  82083. */
  82084. private _onBindObserver;
  82085. /**
  82086. * Called during a bind event
  82087. */
  82088. onBind: (Mesh: AbstractMesh) => void;
  82089. /**
  82090. * An event triggered when the material is unbound
  82091. */
  82092. readonly onUnBindObservable: Observable<Material>;
  82093. /**
  82094. * Stores the value of the alpha mode
  82095. */
  82096. private _alphaMode;
  82097. /**
  82098. * Sets the value of the alpha mode.
  82099. *
  82100. * | Value | Type | Description |
  82101. * | --- | --- | --- |
  82102. * | 0 | ALPHA_DISABLE | |
  82103. * | 1 | ALPHA_ADD | |
  82104. * | 2 | ALPHA_COMBINE | |
  82105. * | 3 | ALPHA_SUBTRACT | |
  82106. * | 4 | ALPHA_MULTIPLY | |
  82107. * | 5 | ALPHA_MAXIMIZED | |
  82108. * | 6 | ALPHA_ONEONE | |
  82109. * | 7 | ALPHA_PREMULTIPLIED | |
  82110. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  82111. * | 9 | ALPHA_INTERPOLATE | |
  82112. * | 10 | ALPHA_SCREENMODE | |
  82113. *
  82114. */
  82115. /**
  82116. * Gets the value of the alpha mode
  82117. */
  82118. alphaMode: number;
  82119. /**
  82120. * Stores the state of the need depth pre-pass value
  82121. */
  82122. private _needDepthPrePass;
  82123. /**
  82124. * Sets the need depth pre-pass value
  82125. */
  82126. /**
  82127. * Gets the depth pre-pass value
  82128. */
  82129. needDepthPrePass: boolean;
  82130. /**
  82131. * Specifies if depth writing should be disabled
  82132. */
  82133. disableDepthWrite: boolean;
  82134. /**
  82135. * Specifies if depth writing should be forced
  82136. */
  82137. forceDepthWrite: boolean;
  82138. /**
  82139. * Specifies if there should be a separate pass for culling
  82140. */
  82141. separateCullingPass: boolean;
  82142. /**
  82143. * Stores the state specifing if fog should be enabled
  82144. */
  82145. private _fogEnabled;
  82146. /**
  82147. * Sets the state for enabling fog
  82148. */
  82149. /**
  82150. * Gets the value of the fog enabled state
  82151. */
  82152. fogEnabled: boolean;
  82153. /**
  82154. * Stores the size of points
  82155. */
  82156. pointSize: number;
  82157. /**
  82158. * Stores the z offset value
  82159. */
  82160. zOffset: number;
  82161. /**
  82162. * Gets a value specifying if wireframe mode is enabled
  82163. */
  82164. /**
  82165. * Sets the state of wireframe mode
  82166. */
  82167. wireframe: boolean;
  82168. /**
  82169. * Gets the value specifying if point clouds are enabled
  82170. */
  82171. /**
  82172. * Sets the state of point cloud mode
  82173. */
  82174. pointsCloud: boolean;
  82175. /**
  82176. * Gets the material fill mode
  82177. */
  82178. /**
  82179. * Sets the material fill mode
  82180. */
  82181. fillMode: number;
  82182. /**
  82183. * @hidden
  82184. * Stores the effects for the material
  82185. */
  82186. _effect: Nullable<Effect>;
  82187. /**
  82188. * @hidden
  82189. * Specifies if the material was previously ready
  82190. */
  82191. _wasPreviouslyReady: boolean;
  82192. /**
  82193. * Specifies if uniform buffers should be used
  82194. */
  82195. private _useUBO;
  82196. /**
  82197. * Stores a reference to the scene
  82198. */
  82199. private _scene;
  82200. /**
  82201. * Stores the fill mode state
  82202. */
  82203. private _fillMode;
  82204. /**
  82205. * Specifies if the depth write state should be cached
  82206. */
  82207. private _cachedDepthWriteState;
  82208. /**
  82209. * Stores the uniform buffer
  82210. */
  82211. protected _uniformBuffer: UniformBuffer;
  82212. /** @hidden */
  82213. _indexInSceneMaterialArray: number;
  82214. /** @hidden */
  82215. meshMap: Nullable<{
  82216. [id: string]: AbstractMesh | undefined;
  82217. }>;
  82218. /**
  82219. * Creates a material instance
  82220. * @param name defines the name of the material
  82221. * @param scene defines the scene to reference
  82222. * @param doNotAdd specifies if the material should be added to the scene
  82223. */
  82224. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  82225. /**
  82226. * Returns a string representation of the current material
  82227. * @param fullDetails defines a boolean indicating which levels of logging is desired
  82228. * @returns a string with material information
  82229. */
  82230. toString(fullDetails?: boolean): string;
  82231. /**
  82232. * Gets the class name of the material
  82233. * @returns a string with the class name of the material
  82234. */
  82235. getClassName(): string;
  82236. /**
  82237. * Specifies if updates for the material been locked
  82238. */
  82239. readonly isFrozen: boolean;
  82240. /**
  82241. * Locks updates for the material
  82242. */
  82243. freeze(): void;
  82244. /**
  82245. * Unlocks updates for the material
  82246. */
  82247. unfreeze(): void;
  82248. /**
  82249. * Specifies if the material is ready to be used
  82250. * @param mesh defines the mesh to check
  82251. * @param useInstances specifies if instances should be used
  82252. * @returns a boolean indicating if the material is ready to be used
  82253. */
  82254. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  82255. /**
  82256. * Specifies that the submesh is ready to be used
  82257. * @param mesh defines the mesh to check
  82258. * @param subMesh defines which submesh to check
  82259. * @param useInstances specifies that instances should be used
  82260. * @returns a boolean indicating that the submesh is ready or not
  82261. */
  82262. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  82263. /**
  82264. * Returns the material effect
  82265. * @returns the effect associated with the material
  82266. */
  82267. getEffect(): Nullable<Effect>;
  82268. /**
  82269. * Returns the current scene
  82270. * @returns a Scene
  82271. */
  82272. getScene(): Scene;
  82273. /**
  82274. * Specifies if the material will require alpha blending
  82275. * @returns a boolean specifying if alpha blending is needed
  82276. */
  82277. needAlphaBlending(): boolean;
  82278. /**
  82279. * Specifies if the mesh will require alpha blending
  82280. * @param mesh defines the mesh to check
  82281. * @returns a boolean specifying if alpha blending is needed for the mesh
  82282. */
  82283. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  82284. /**
  82285. * Specifies if this material should be rendered in alpha test mode
  82286. * @returns a boolean specifying if an alpha test is needed.
  82287. */
  82288. needAlphaTesting(): boolean;
  82289. /**
  82290. * Gets the texture used for the alpha test
  82291. * @returns the texture to use for alpha testing
  82292. */
  82293. getAlphaTestTexture(): Nullable<BaseTexture>;
  82294. /**
  82295. * Marks the material to indicate that it needs to be re-calculated
  82296. */
  82297. markDirty(): void;
  82298. /** @hidden */
  82299. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  82300. /**
  82301. * Binds the material to the mesh
  82302. * @param world defines the world transformation matrix
  82303. * @param mesh defines the mesh to bind the material to
  82304. */
  82305. bind(world: Matrix, mesh?: Mesh): void;
  82306. /**
  82307. * Binds the submesh to the material
  82308. * @param world defines the world transformation matrix
  82309. * @param mesh defines the mesh containing the submesh
  82310. * @param subMesh defines the submesh to bind the material to
  82311. */
  82312. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  82313. /**
  82314. * Binds the world matrix to the material
  82315. * @param world defines the world transformation matrix
  82316. */
  82317. bindOnlyWorldMatrix(world: Matrix): void;
  82318. /**
  82319. * Binds the scene's uniform buffer to the effect.
  82320. * @param effect defines the effect to bind to the scene uniform buffer
  82321. * @param sceneUbo defines the uniform buffer storing scene data
  82322. */
  82323. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  82324. /**
  82325. * Binds the view matrix to the effect
  82326. * @param effect defines the effect to bind the view matrix to
  82327. */
  82328. bindView(effect: Effect): void;
  82329. /**
  82330. * Binds the view projection matrix to the effect
  82331. * @param effect defines the effect to bind the view projection matrix to
  82332. */
  82333. bindViewProjection(effect: Effect): void;
  82334. /**
  82335. * Specifies if material alpha testing should be turned on for the mesh
  82336. * @param mesh defines the mesh to check
  82337. */
  82338. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  82339. /**
  82340. * Processes to execute after binding the material to a mesh
  82341. * @param mesh defines the rendered mesh
  82342. */
  82343. protected _afterBind(mesh?: Mesh): void;
  82344. /**
  82345. * Unbinds the material from the mesh
  82346. */
  82347. unbind(): void;
  82348. /**
  82349. * Gets the active textures from the material
  82350. * @returns an array of textures
  82351. */
  82352. getActiveTextures(): BaseTexture[];
  82353. /**
  82354. * Specifies if the material uses a texture
  82355. * @param texture defines the texture to check against the material
  82356. * @returns a boolean specifying if the material uses the texture
  82357. */
  82358. hasTexture(texture: BaseTexture): boolean;
  82359. /**
  82360. * Makes a duplicate of the material, and gives it a new name
  82361. * @param name defines the new name for the duplicated material
  82362. * @returns the cloned material
  82363. */
  82364. clone(name: string): Nullable<Material>;
  82365. /**
  82366. * Gets the meshes bound to the material
  82367. * @returns an array of meshes bound to the material
  82368. */
  82369. getBindedMeshes(): AbstractMesh[];
  82370. /**
  82371. * Force shader compilation
  82372. * @param mesh defines the mesh associated with this material
  82373. * @param onCompiled defines a function to execute once the material is compiled
  82374. * @param options defines the options to configure the compilation
  82375. */
  82376. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  82377. clipPlane: boolean;
  82378. }>): void;
  82379. /**
  82380. * Force shader compilation
  82381. * @param mesh defines the mesh that will use this material
  82382. * @param options defines additional options for compiling the shaders
  82383. * @returns a promise that resolves when the compilation completes
  82384. */
  82385. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  82386. clipPlane: boolean;
  82387. }>): Promise<void>;
  82388. private static readonly _ImageProcessingDirtyCallBack;
  82389. private static readonly _TextureDirtyCallBack;
  82390. private static readonly _FresnelDirtyCallBack;
  82391. private static readonly _MiscDirtyCallBack;
  82392. private static readonly _LightsDirtyCallBack;
  82393. private static readonly _AttributeDirtyCallBack;
  82394. private static _FresnelAndMiscDirtyCallBack;
  82395. private static _TextureAndMiscDirtyCallBack;
  82396. private static readonly _DirtyCallbackArray;
  82397. private static readonly _RunDirtyCallBacks;
  82398. /**
  82399. * Marks a define in the material to indicate that it needs to be re-computed
  82400. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  82401. */
  82402. markAsDirty(flag: number): void;
  82403. /**
  82404. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  82405. * @param func defines a function which checks material defines against the submeshes
  82406. */
  82407. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  82408. /**
  82409. * Indicates that image processing needs to be re-calculated for all submeshes
  82410. */
  82411. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  82412. /**
  82413. * Indicates that textures need to be re-calculated for all submeshes
  82414. */
  82415. protected _markAllSubMeshesAsTexturesDirty(): void;
  82416. /**
  82417. * Indicates that fresnel needs to be re-calculated for all submeshes
  82418. */
  82419. protected _markAllSubMeshesAsFresnelDirty(): void;
  82420. /**
  82421. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  82422. */
  82423. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  82424. /**
  82425. * Indicates that lights need to be re-calculated for all submeshes
  82426. */
  82427. protected _markAllSubMeshesAsLightsDirty(): void;
  82428. /**
  82429. * Indicates that attributes need to be re-calculated for all submeshes
  82430. */
  82431. protected _markAllSubMeshesAsAttributesDirty(): void;
  82432. /**
  82433. * Indicates that misc needs to be re-calculated for all submeshes
  82434. */
  82435. protected _markAllSubMeshesAsMiscDirty(): void;
  82436. /**
  82437. * Indicates that textures and misc need to be re-calculated for all submeshes
  82438. */
  82439. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  82440. /**
  82441. * Disposes the material
  82442. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  82443. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  82444. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  82445. */
  82446. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  82447. /** @hidden */
  82448. private releaseVertexArrayObject;
  82449. /**
  82450. * Serializes this material
  82451. * @returns the serialized material object
  82452. */
  82453. serialize(): any;
  82454. /**
  82455. * Creates a material from parsed material data
  82456. * @param parsedMaterial defines parsed material data
  82457. * @param scene defines the hosting scene
  82458. * @param rootUrl defines the root URL to use to load textures
  82459. * @returns a new material
  82460. */
  82461. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  82462. }
  82463. }
  82464. declare module BABYLON {
  82465. /**
  82466. * Base class for submeshes
  82467. */
  82468. export class BaseSubMesh {
  82469. /** @hidden */
  82470. _materialDefines: Nullable<MaterialDefines>;
  82471. /** @hidden */
  82472. _materialEffect: Nullable<Effect>;
  82473. /**
  82474. * Gets associated effect
  82475. */
  82476. readonly effect: Nullable<Effect>;
  82477. /**
  82478. * Sets associated effect (effect used to render this submesh)
  82479. * @param effect defines the effect to associate with
  82480. * @param defines defines the set of defines used to compile this effect
  82481. */
  82482. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  82483. }
  82484. /**
  82485. * Defines a subdivision inside a mesh
  82486. */
  82487. export class SubMesh extends BaseSubMesh implements ICullable {
  82488. /** the material index to use */
  82489. materialIndex: number;
  82490. /** vertex index start */
  82491. verticesStart: number;
  82492. /** vertices count */
  82493. verticesCount: number;
  82494. /** index start */
  82495. indexStart: number;
  82496. /** indices count */
  82497. indexCount: number;
  82498. /** @hidden */
  82499. _linesIndexCount: number;
  82500. private _mesh;
  82501. private _renderingMesh;
  82502. private _boundingInfo;
  82503. private _linesIndexBuffer;
  82504. /** @hidden */
  82505. _lastColliderWorldVertices: Nullable<Vector3[]>;
  82506. /** @hidden */
  82507. _trianglePlanes: Plane[];
  82508. /** @hidden */
  82509. _lastColliderTransformMatrix: Nullable<Matrix>;
  82510. /** @hidden */
  82511. _renderId: number;
  82512. /** @hidden */
  82513. _alphaIndex: number;
  82514. /** @hidden */
  82515. _distanceToCamera: number;
  82516. /** @hidden */
  82517. _id: number;
  82518. private _currentMaterial;
  82519. /**
  82520. * Add a new submesh to a mesh
  82521. * @param materialIndex defines the material index to use
  82522. * @param verticesStart defines vertex index start
  82523. * @param verticesCount defines vertices count
  82524. * @param indexStart defines index start
  82525. * @param indexCount defines indices count
  82526. * @param mesh defines the parent mesh
  82527. * @param renderingMesh defines an optional rendering mesh
  82528. * @param createBoundingBox defines if bounding box should be created for this submesh
  82529. * @returns the new submesh
  82530. */
  82531. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  82532. /**
  82533. * Creates a new submesh
  82534. * @param materialIndex defines the material index to use
  82535. * @param verticesStart defines vertex index start
  82536. * @param verticesCount defines vertices count
  82537. * @param indexStart defines index start
  82538. * @param indexCount defines indices count
  82539. * @param mesh defines the parent mesh
  82540. * @param renderingMesh defines an optional rendering mesh
  82541. * @param createBoundingBox defines if bounding box should be created for this submesh
  82542. */
  82543. constructor(
  82544. /** the material index to use */
  82545. materialIndex: number,
  82546. /** vertex index start */
  82547. verticesStart: number,
  82548. /** vertices count */
  82549. verticesCount: number,
  82550. /** index start */
  82551. indexStart: number,
  82552. /** indices count */
  82553. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  82554. /**
  82555. * Returns true if this submesh covers the entire parent mesh
  82556. * @ignorenaming
  82557. */
  82558. readonly IsGlobal: boolean;
  82559. /**
  82560. * Returns the submesh BoudingInfo object
  82561. * @returns current bounding info (or mesh's one if the submesh is global)
  82562. */
  82563. getBoundingInfo(): BoundingInfo;
  82564. /**
  82565. * Sets the submesh BoundingInfo
  82566. * @param boundingInfo defines the new bounding info to use
  82567. * @returns the SubMesh
  82568. */
  82569. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  82570. /**
  82571. * Returns the mesh of the current submesh
  82572. * @return the parent mesh
  82573. */
  82574. getMesh(): AbstractMesh;
  82575. /**
  82576. * Returns the rendering mesh of the submesh
  82577. * @returns the rendering mesh (could be different from parent mesh)
  82578. */
  82579. getRenderingMesh(): Mesh;
  82580. /**
  82581. * Returns the submesh material
  82582. * @returns null or the current material
  82583. */
  82584. getMaterial(): Nullable<Material>;
  82585. /**
  82586. * Sets a new updated BoundingInfo object to the submesh
  82587. * @param data defines an optional position array to use to determine the bounding info
  82588. * @returns the SubMesh
  82589. */
  82590. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  82591. /** @hidden */
  82592. _checkCollision(collider: Collider): boolean;
  82593. /**
  82594. * Updates the submesh BoundingInfo
  82595. * @param world defines the world matrix to use to update the bounding info
  82596. * @returns the submesh
  82597. */
  82598. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  82599. /**
  82600. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  82601. * @param frustumPlanes defines the frustum planes
  82602. * @returns true if the submesh is intersecting with the frustum
  82603. */
  82604. isInFrustum(frustumPlanes: Plane[]): boolean;
  82605. /**
  82606. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  82607. * @param frustumPlanes defines the frustum planes
  82608. * @returns true if the submesh is inside the frustum
  82609. */
  82610. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  82611. /**
  82612. * Renders the submesh
  82613. * @param enableAlphaMode defines if alpha needs to be used
  82614. * @returns the submesh
  82615. */
  82616. render(enableAlphaMode: boolean): SubMesh;
  82617. /**
  82618. * @hidden
  82619. */
  82620. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  82621. /**
  82622. * Checks if the submesh intersects with a ray
  82623. * @param ray defines the ray to test
  82624. * @returns true is the passed ray intersects the submesh bounding box
  82625. */
  82626. canIntersects(ray: Ray): boolean;
  82627. /**
  82628. * Intersects current submesh with a ray
  82629. * @param ray defines the ray to test
  82630. * @param positions defines mesh's positions array
  82631. * @param indices defines mesh's indices array
  82632. * @param fastCheck defines if only bounding info should be used
  82633. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  82634. * @returns intersection info or null if no intersection
  82635. */
  82636. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  82637. /** @hidden */
  82638. private _intersectLines;
  82639. /** @hidden */
  82640. private _intersectUnIndexedLines;
  82641. /** @hidden */
  82642. private _intersectTriangles;
  82643. /** @hidden */
  82644. private _intersectUnIndexedTriangles;
  82645. /** @hidden */
  82646. _rebuild(): void;
  82647. /**
  82648. * Creates a new submesh from the passed mesh
  82649. * @param newMesh defines the new hosting mesh
  82650. * @param newRenderingMesh defines an optional rendering mesh
  82651. * @returns the new submesh
  82652. */
  82653. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  82654. /**
  82655. * Release associated resources
  82656. */
  82657. dispose(): void;
  82658. /**
  82659. * Gets the class name
  82660. * @returns the string "SubMesh".
  82661. */
  82662. getClassName(): string;
  82663. /**
  82664. * Creates a new submesh from indices data
  82665. * @param materialIndex the index of the main mesh material
  82666. * @param startIndex the index where to start the copy in the mesh indices array
  82667. * @param indexCount the number of indices to copy then from the startIndex
  82668. * @param mesh the main mesh to create the submesh from
  82669. * @param renderingMesh the optional rendering mesh
  82670. * @returns a new submesh
  82671. */
  82672. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  82673. }
  82674. }
  82675. declare module BABYLON {
  82676. /**
  82677. * Class used to store geometry data (vertex buffers + index buffer)
  82678. */
  82679. export class Geometry implements IGetSetVerticesData {
  82680. /**
  82681. * Gets or sets the ID of the geometry
  82682. */
  82683. id: string;
  82684. /**
  82685. * Gets or sets the unique ID of the geometry
  82686. */
  82687. uniqueId: number;
  82688. /**
  82689. * Gets the delay loading state of the geometry (none by default which means not delayed)
  82690. */
  82691. delayLoadState: number;
  82692. /**
  82693. * Gets the file containing the data to load when running in delay load state
  82694. */
  82695. delayLoadingFile: Nullable<string>;
  82696. /**
  82697. * Callback called when the geometry is updated
  82698. */
  82699. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  82700. private _scene;
  82701. private _engine;
  82702. private _meshes;
  82703. private _totalVertices;
  82704. /** @hidden */
  82705. _indices: IndicesArray;
  82706. /** @hidden */
  82707. _vertexBuffers: {
  82708. [key: string]: VertexBuffer;
  82709. };
  82710. private _isDisposed;
  82711. private _extend;
  82712. private _boundingBias;
  82713. /** @hidden */
  82714. _delayInfo: Array<string>;
  82715. private _indexBuffer;
  82716. private _indexBufferIsUpdatable;
  82717. /** @hidden */
  82718. _boundingInfo: Nullable<BoundingInfo>;
  82719. /** @hidden */
  82720. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  82721. /** @hidden */
  82722. _softwareSkinningFrameId: number;
  82723. private _vertexArrayObjects;
  82724. private _updatable;
  82725. /** @hidden */
  82726. _positions: Nullable<Vector3[]>;
  82727. /**
  82728. * 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
  82729. */
  82730. /**
  82731. * 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
  82732. */
  82733. boundingBias: Vector2;
  82734. /**
  82735. * Static function used to attach a new empty geometry to a mesh
  82736. * @param mesh defines the mesh to attach the geometry to
  82737. * @returns the new Geometry
  82738. */
  82739. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  82740. /**
  82741. * Creates a new geometry
  82742. * @param id defines the unique ID
  82743. * @param scene defines the hosting scene
  82744. * @param vertexData defines the VertexData used to get geometry data
  82745. * @param updatable defines if geometry must be updatable (false by default)
  82746. * @param mesh defines the mesh that will be associated with the geometry
  82747. */
  82748. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  82749. /**
  82750. * Gets the current extend of the geometry
  82751. */
  82752. readonly extend: {
  82753. minimum: Vector3;
  82754. maximum: Vector3;
  82755. };
  82756. /**
  82757. * Gets the hosting scene
  82758. * @returns the hosting Scene
  82759. */
  82760. getScene(): Scene;
  82761. /**
  82762. * Gets the hosting engine
  82763. * @returns the hosting Engine
  82764. */
  82765. getEngine(): Engine;
  82766. /**
  82767. * Defines if the geometry is ready to use
  82768. * @returns true if the geometry is ready to be used
  82769. */
  82770. isReady(): boolean;
  82771. /**
  82772. * Gets a value indicating that the geometry should not be serialized
  82773. */
  82774. readonly doNotSerialize: boolean;
  82775. /** @hidden */
  82776. _rebuild(): void;
  82777. /**
  82778. * Affects all geometry data in one call
  82779. * @param vertexData defines the geometry data
  82780. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  82781. */
  82782. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  82783. /**
  82784. * Set specific vertex data
  82785. * @param kind defines the data kind (Position, normal, etc...)
  82786. * @param data defines the vertex data to use
  82787. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  82788. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  82789. */
  82790. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  82791. /**
  82792. * Removes a specific vertex data
  82793. * @param kind defines the data kind (Position, normal, etc...)
  82794. */
  82795. removeVerticesData(kind: string): void;
  82796. /**
  82797. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  82798. * @param buffer defines the vertex buffer to use
  82799. * @param totalVertices defines the total number of vertices for position kind (could be null)
  82800. */
  82801. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  82802. /**
  82803. * Update a specific vertex buffer
  82804. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  82805. * It will do nothing if the buffer is not updatable
  82806. * @param kind defines the data kind (Position, normal, etc...)
  82807. * @param data defines the data to use
  82808. * @param offset defines the offset in the target buffer where to store the data
  82809. * @param useBytes set to true if the offset is in bytes
  82810. */
  82811. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  82812. /**
  82813. * Update a specific vertex buffer
  82814. * This function will create a new buffer if the current one is not updatable
  82815. * @param kind defines the data kind (Position, normal, etc...)
  82816. * @param data defines the data to use
  82817. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  82818. */
  82819. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  82820. private _updateBoundingInfo;
  82821. /** @hidden */
  82822. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  82823. /**
  82824. * Gets total number of vertices
  82825. * @returns the total number of vertices
  82826. */
  82827. getTotalVertices(): number;
  82828. /**
  82829. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  82830. * @param kind defines the data kind (Position, normal, etc...)
  82831. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  82832. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  82833. * @returns a float array containing vertex data
  82834. */
  82835. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  82836. /**
  82837. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  82838. * @param kind defines the data kind (Position, normal, etc...)
  82839. * @returns true if the vertex buffer with the specified kind is updatable
  82840. */
  82841. isVertexBufferUpdatable(kind: string): boolean;
  82842. /**
  82843. * Gets a specific vertex buffer
  82844. * @param kind defines the data kind (Position, normal, etc...)
  82845. * @returns a VertexBuffer
  82846. */
  82847. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  82848. /**
  82849. * Returns all vertex buffers
  82850. * @return an object holding all vertex buffers indexed by kind
  82851. */
  82852. getVertexBuffers(): Nullable<{
  82853. [key: string]: VertexBuffer;
  82854. }>;
  82855. /**
  82856. * Gets a boolean indicating if specific vertex buffer is present
  82857. * @param kind defines the data kind (Position, normal, etc...)
  82858. * @returns true if data is present
  82859. */
  82860. isVerticesDataPresent(kind: string): boolean;
  82861. /**
  82862. * Gets a list of all attached data kinds (Position, normal, etc...)
  82863. * @returns a list of string containing all kinds
  82864. */
  82865. getVerticesDataKinds(): string[];
  82866. /**
  82867. * Update index buffer
  82868. * @param indices defines the indices to store in the index buffer
  82869. * @param offset defines the offset in the target buffer where to store the data
  82870. * @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)
  82871. */
  82872. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  82873. /**
  82874. * Creates a new index buffer
  82875. * @param indices defines the indices to store in the index buffer
  82876. * @param totalVertices defines the total number of vertices (could be null)
  82877. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  82878. */
  82879. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  82880. /**
  82881. * Return the total number of indices
  82882. * @returns the total number of indices
  82883. */
  82884. getTotalIndices(): number;
  82885. /**
  82886. * Gets the index buffer array
  82887. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  82888. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  82889. * @returns the index buffer array
  82890. */
  82891. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  82892. /**
  82893. * Gets the index buffer
  82894. * @return the index buffer
  82895. */
  82896. getIndexBuffer(): Nullable<DataBuffer>;
  82897. /** @hidden */
  82898. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  82899. /**
  82900. * Release the associated resources for a specific mesh
  82901. * @param mesh defines the source mesh
  82902. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  82903. */
  82904. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  82905. /**
  82906. * Apply current geometry to a given mesh
  82907. * @param mesh defines the mesh to apply geometry to
  82908. */
  82909. applyToMesh(mesh: Mesh): void;
  82910. private _updateExtend;
  82911. private _applyToMesh;
  82912. private notifyUpdate;
  82913. /**
  82914. * Load the geometry if it was flagged as delay loaded
  82915. * @param scene defines the hosting scene
  82916. * @param onLoaded defines a callback called when the geometry is loaded
  82917. */
  82918. load(scene: Scene, onLoaded?: () => void): void;
  82919. private _queueLoad;
  82920. /**
  82921. * Invert the geometry to move from a right handed system to a left handed one.
  82922. */
  82923. toLeftHanded(): void;
  82924. /** @hidden */
  82925. _resetPointsArrayCache(): void;
  82926. /** @hidden */
  82927. _generatePointsArray(): boolean;
  82928. /**
  82929. * Gets a value indicating if the geometry is disposed
  82930. * @returns true if the geometry was disposed
  82931. */
  82932. isDisposed(): boolean;
  82933. private _disposeVertexArrayObjects;
  82934. /**
  82935. * Free all associated resources
  82936. */
  82937. dispose(): void;
  82938. /**
  82939. * Clone the current geometry into a new geometry
  82940. * @param id defines the unique ID of the new geometry
  82941. * @returns a new geometry object
  82942. */
  82943. copy(id: string): Geometry;
  82944. /**
  82945. * Serialize the current geometry info (and not the vertices data) into a JSON object
  82946. * @return a JSON representation of the current geometry data (without the vertices data)
  82947. */
  82948. serialize(): any;
  82949. private toNumberArray;
  82950. /**
  82951. * Serialize all vertices data into a JSON oject
  82952. * @returns a JSON representation of the current geometry data
  82953. */
  82954. serializeVerticeData(): any;
  82955. /**
  82956. * Extracts a clone of a mesh geometry
  82957. * @param mesh defines the source mesh
  82958. * @param id defines the unique ID of the new geometry object
  82959. * @returns the new geometry object
  82960. */
  82961. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  82962. /**
  82963. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  82964. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  82965. * Be aware Math.random() could cause collisions, but:
  82966. * "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"
  82967. * @returns a string containing a new GUID
  82968. */
  82969. static RandomId(): string;
  82970. /** @hidden */
  82971. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  82972. private static _CleanMatricesWeights;
  82973. /**
  82974. * Create a new geometry from persisted data (Using .babylon file format)
  82975. * @param parsedVertexData defines the persisted data
  82976. * @param scene defines the hosting scene
  82977. * @param rootUrl defines the root url to use to load assets (like delayed data)
  82978. * @returns the new geometry object
  82979. */
  82980. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  82981. }
  82982. }
  82983. declare module BABYLON {
  82984. /**
  82985. * Define an interface for all classes that will get and set the data on vertices
  82986. */
  82987. export interface IGetSetVerticesData {
  82988. /**
  82989. * Gets a boolean indicating if specific vertex data is present
  82990. * @param kind defines the vertex data kind to use
  82991. * @returns true is data kind is present
  82992. */
  82993. isVerticesDataPresent(kind: string): boolean;
  82994. /**
  82995. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  82996. * @param kind defines the data kind (Position, normal, etc...)
  82997. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  82998. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  82999. * @returns a float array containing vertex data
  83000. */
  83001. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  83002. /**
  83003. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  83004. * @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.
  83005. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  83006. * @returns the indices array or an empty array if the mesh has no geometry
  83007. */
  83008. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  83009. /**
  83010. * Set specific vertex data
  83011. * @param kind defines the data kind (Position, normal, etc...)
  83012. * @param data defines the vertex data to use
  83013. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  83014. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  83015. */
  83016. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  83017. /**
  83018. * Update a specific associated vertex buffer
  83019. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  83020. * - VertexBuffer.PositionKind
  83021. * - VertexBuffer.UVKind
  83022. * - VertexBuffer.UV2Kind
  83023. * - VertexBuffer.UV3Kind
  83024. * - VertexBuffer.UV4Kind
  83025. * - VertexBuffer.UV5Kind
  83026. * - VertexBuffer.UV6Kind
  83027. * - VertexBuffer.ColorKind
  83028. * - VertexBuffer.MatricesIndicesKind
  83029. * - VertexBuffer.MatricesIndicesExtraKind
  83030. * - VertexBuffer.MatricesWeightsKind
  83031. * - VertexBuffer.MatricesWeightsExtraKind
  83032. * @param data defines the data source
  83033. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  83034. * @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)
  83035. */
  83036. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  83037. /**
  83038. * Creates a new index buffer
  83039. * @param indices defines the indices to store in the index buffer
  83040. * @param totalVertices defines the total number of vertices (could be null)
  83041. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  83042. */
  83043. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  83044. }
  83045. /**
  83046. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  83047. */
  83048. export class VertexData {
  83049. /**
  83050. * Mesh side orientation : usually the external or front surface
  83051. */
  83052. static readonly FRONTSIDE: number;
  83053. /**
  83054. * Mesh side orientation : usually the internal or back surface
  83055. */
  83056. static readonly BACKSIDE: number;
  83057. /**
  83058. * Mesh side orientation : both internal and external or front and back surfaces
  83059. */
  83060. static readonly DOUBLESIDE: number;
  83061. /**
  83062. * Mesh side orientation : by default, `FRONTSIDE`
  83063. */
  83064. static readonly DEFAULTSIDE: number;
  83065. /**
  83066. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  83067. */
  83068. positions: Nullable<FloatArray>;
  83069. /**
  83070. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  83071. */
  83072. normals: Nullable<FloatArray>;
  83073. /**
  83074. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  83075. */
  83076. tangents: Nullable<FloatArray>;
  83077. /**
  83078. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  83079. */
  83080. uvs: Nullable<FloatArray>;
  83081. /**
  83082. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  83083. */
  83084. uvs2: Nullable<FloatArray>;
  83085. /**
  83086. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  83087. */
  83088. uvs3: Nullable<FloatArray>;
  83089. /**
  83090. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  83091. */
  83092. uvs4: Nullable<FloatArray>;
  83093. /**
  83094. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  83095. */
  83096. uvs5: Nullable<FloatArray>;
  83097. /**
  83098. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  83099. */
  83100. uvs6: Nullable<FloatArray>;
  83101. /**
  83102. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  83103. */
  83104. colors: Nullable<FloatArray>;
  83105. /**
  83106. * 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).
  83107. */
  83108. matricesIndices: Nullable<FloatArray>;
  83109. /**
  83110. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  83111. */
  83112. matricesWeights: Nullable<FloatArray>;
  83113. /**
  83114. * An array extending the number of possible indices
  83115. */
  83116. matricesIndicesExtra: Nullable<FloatArray>;
  83117. /**
  83118. * An array extending the number of possible weights when the number of indices is extended
  83119. */
  83120. matricesWeightsExtra: Nullable<FloatArray>;
  83121. /**
  83122. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  83123. */
  83124. indices: Nullable<IndicesArray>;
  83125. /**
  83126. * Uses the passed data array to set the set the values for the specified kind of data
  83127. * @param data a linear array of floating numbers
  83128. * @param kind the type of data that is being set, eg positions, colors etc
  83129. */
  83130. set(data: FloatArray, kind: string): void;
  83131. /**
  83132. * Associates the vertexData to the passed Mesh.
  83133. * Sets it as updatable or not (default `false`)
  83134. * @param mesh the mesh the vertexData is applied to
  83135. * @param updatable when used and having the value true allows new data to update the vertexData
  83136. * @returns the VertexData
  83137. */
  83138. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  83139. /**
  83140. * Associates the vertexData to the passed Geometry.
  83141. * Sets it as updatable or not (default `false`)
  83142. * @param geometry the geometry the vertexData is applied to
  83143. * @param updatable when used and having the value true allows new data to update the vertexData
  83144. * @returns VertexData
  83145. */
  83146. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  83147. /**
  83148. * Updates the associated mesh
  83149. * @param mesh the mesh to be updated
  83150. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  83151. * @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
  83152. * @returns VertexData
  83153. */
  83154. updateMesh(mesh: Mesh): VertexData;
  83155. /**
  83156. * Updates the associated geometry
  83157. * @param geometry the geometry to be updated
  83158. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  83159. * @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
  83160. * @returns VertexData.
  83161. */
  83162. updateGeometry(geometry: Geometry): VertexData;
  83163. private _applyTo;
  83164. private _update;
  83165. /**
  83166. * Transforms each position and each normal of the vertexData according to the passed Matrix
  83167. * @param matrix the transforming matrix
  83168. * @returns the VertexData
  83169. */
  83170. transform(matrix: Matrix): VertexData;
  83171. /**
  83172. * Merges the passed VertexData into the current one
  83173. * @param other the VertexData to be merged into the current one
  83174. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  83175. * @returns the modified VertexData
  83176. */
  83177. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  83178. private _mergeElement;
  83179. private _validate;
  83180. /**
  83181. * Serializes the VertexData
  83182. * @returns a serialized object
  83183. */
  83184. serialize(): any;
  83185. /**
  83186. * Extracts the vertexData from a mesh
  83187. * @param mesh the mesh from which to extract the VertexData
  83188. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  83189. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  83190. * @returns the object VertexData associated to the passed mesh
  83191. */
  83192. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  83193. /**
  83194. * Extracts the vertexData from the geometry
  83195. * @param geometry the geometry from which to extract the VertexData
  83196. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  83197. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  83198. * @returns the object VertexData associated to the passed mesh
  83199. */
  83200. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  83201. private static _ExtractFrom;
  83202. /**
  83203. * Creates the VertexData for a Ribbon
  83204. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  83205. * * pathArray array of paths, each of which an array of successive Vector3
  83206. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  83207. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  83208. * * 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
  83209. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83210. * * 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)
  83211. * * 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)
  83212. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  83213. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  83214. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  83215. * @returns the VertexData of the ribbon
  83216. */
  83217. static CreateRibbon(options: {
  83218. pathArray: Vector3[][];
  83219. closeArray?: boolean;
  83220. closePath?: boolean;
  83221. offset?: number;
  83222. sideOrientation?: number;
  83223. frontUVs?: Vector4;
  83224. backUVs?: Vector4;
  83225. invertUV?: boolean;
  83226. uvs?: Vector2[];
  83227. colors?: Color4[];
  83228. }): VertexData;
  83229. /**
  83230. * Creates the VertexData for a box
  83231. * @param options an object used to set the following optional parameters for the box, required but can be empty
  83232. * * size sets the width, height and depth of the box to the value of size, optional default 1
  83233. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  83234. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  83235. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  83236. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  83237. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  83238. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83239. * * 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)
  83240. * * 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)
  83241. * @returns the VertexData of the box
  83242. */
  83243. static CreateBox(options: {
  83244. size?: number;
  83245. width?: number;
  83246. height?: number;
  83247. depth?: number;
  83248. faceUV?: Vector4[];
  83249. faceColors?: Color4[];
  83250. sideOrientation?: number;
  83251. frontUVs?: Vector4;
  83252. backUVs?: Vector4;
  83253. }): VertexData;
  83254. /**
  83255. * Creates the VertexData for an ellipsoid, defaults to a sphere
  83256. * @param options an object used to set the following optional parameters for the box, required but can be empty
  83257. * * segments sets the number of horizontal strips optional, default 32
  83258. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  83259. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  83260. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  83261. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  83262. * * 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
  83263. * * 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
  83264. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83265. * * 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)
  83266. * * 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)
  83267. * @returns the VertexData of the ellipsoid
  83268. */
  83269. static CreateSphere(options: {
  83270. segments?: number;
  83271. diameter?: number;
  83272. diameterX?: number;
  83273. diameterY?: number;
  83274. diameterZ?: number;
  83275. arc?: number;
  83276. slice?: number;
  83277. sideOrientation?: number;
  83278. frontUVs?: Vector4;
  83279. backUVs?: Vector4;
  83280. }): VertexData;
  83281. /**
  83282. * Creates the VertexData for a cylinder, cone or prism
  83283. * @param options an object used to set the following optional parameters for the box, required but can be empty
  83284. * * height sets the height (y direction) of the cylinder, optional, default 2
  83285. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  83286. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  83287. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  83288. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  83289. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  83290. * * 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
  83291. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  83292. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  83293. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  83294. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  83295. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83296. * * 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)
  83297. * * 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)
  83298. * @returns the VertexData of the cylinder, cone or prism
  83299. */
  83300. static CreateCylinder(options: {
  83301. height?: number;
  83302. diameterTop?: number;
  83303. diameterBottom?: number;
  83304. diameter?: number;
  83305. tessellation?: number;
  83306. subdivisions?: number;
  83307. arc?: number;
  83308. faceColors?: Color4[];
  83309. faceUV?: Vector4[];
  83310. hasRings?: boolean;
  83311. enclose?: boolean;
  83312. sideOrientation?: number;
  83313. frontUVs?: Vector4;
  83314. backUVs?: Vector4;
  83315. }): VertexData;
  83316. /**
  83317. * Creates the VertexData for a torus
  83318. * @param options an object used to set the following optional parameters for the box, required but can be empty
  83319. * * diameter the diameter of the torus, optional default 1
  83320. * * thickness the diameter of the tube forming the torus, optional default 0.5
  83321. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  83322. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83323. * * 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)
  83324. * * 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)
  83325. * @returns the VertexData of the torus
  83326. */
  83327. static CreateTorus(options: {
  83328. diameter?: number;
  83329. thickness?: number;
  83330. tessellation?: number;
  83331. sideOrientation?: number;
  83332. frontUVs?: Vector4;
  83333. backUVs?: Vector4;
  83334. }): VertexData;
  83335. /**
  83336. * Creates the VertexData of the LineSystem
  83337. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  83338. * - lines an array of lines, each line being an array of successive Vector3
  83339. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  83340. * @returns the VertexData of the LineSystem
  83341. */
  83342. static CreateLineSystem(options: {
  83343. lines: Vector3[][];
  83344. colors?: Nullable<Color4[][]>;
  83345. }): VertexData;
  83346. /**
  83347. * Create the VertexData for a DashedLines
  83348. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  83349. * - points an array successive Vector3
  83350. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  83351. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  83352. * - dashNb the intended total number of dashes, optional, default 200
  83353. * @returns the VertexData for the DashedLines
  83354. */
  83355. static CreateDashedLines(options: {
  83356. points: Vector3[];
  83357. dashSize?: number;
  83358. gapSize?: number;
  83359. dashNb?: number;
  83360. }): VertexData;
  83361. /**
  83362. * Creates the VertexData for a Ground
  83363. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  83364. * - width the width (x direction) of the ground, optional, default 1
  83365. * - height the height (z direction) of the ground, optional, default 1
  83366. * - subdivisions the number of subdivisions per side, optional, default 1
  83367. * @returns the VertexData of the Ground
  83368. */
  83369. static CreateGround(options: {
  83370. width?: number;
  83371. height?: number;
  83372. subdivisions?: number;
  83373. subdivisionsX?: number;
  83374. subdivisionsY?: number;
  83375. }): VertexData;
  83376. /**
  83377. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  83378. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  83379. * * xmin the ground minimum X coordinate, optional, default -1
  83380. * * zmin the ground minimum Z coordinate, optional, default -1
  83381. * * xmax the ground maximum X coordinate, optional, default 1
  83382. * * zmax the ground maximum Z coordinate, optional, default 1
  83383. * * 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}
  83384. * * 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}
  83385. * @returns the VertexData of the TiledGround
  83386. */
  83387. static CreateTiledGround(options: {
  83388. xmin: number;
  83389. zmin: number;
  83390. xmax: number;
  83391. zmax: number;
  83392. subdivisions?: {
  83393. w: number;
  83394. h: number;
  83395. };
  83396. precision?: {
  83397. w: number;
  83398. h: number;
  83399. };
  83400. }): VertexData;
  83401. /**
  83402. * Creates the VertexData of the Ground designed from a heightmap
  83403. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  83404. * * width the width (x direction) of the ground
  83405. * * height the height (z direction) of the ground
  83406. * * subdivisions the number of subdivisions per side
  83407. * * minHeight the minimum altitude on the ground, optional, default 0
  83408. * * maxHeight the maximum altitude on the ground, optional default 1
  83409. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  83410. * * buffer the array holding the image color data
  83411. * * bufferWidth the width of image
  83412. * * bufferHeight the height of image
  83413. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  83414. * @returns the VertexData of the Ground designed from a heightmap
  83415. */
  83416. static CreateGroundFromHeightMap(options: {
  83417. width: number;
  83418. height: number;
  83419. subdivisions: number;
  83420. minHeight: number;
  83421. maxHeight: number;
  83422. colorFilter: Color3;
  83423. buffer: Uint8Array;
  83424. bufferWidth: number;
  83425. bufferHeight: number;
  83426. alphaFilter: number;
  83427. }): VertexData;
  83428. /**
  83429. * Creates the VertexData for a Plane
  83430. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  83431. * * size sets the width and height of the plane to the value of size, optional default 1
  83432. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  83433. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  83434. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83435. * * 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)
  83436. * * 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)
  83437. * @returns the VertexData of the box
  83438. */
  83439. static CreatePlane(options: {
  83440. size?: number;
  83441. width?: number;
  83442. height?: number;
  83443. sideOrientation?: number;
  83444. frontUVs?: Vector4;
  83445. backUVs?: Vector4;
  83446. }): VertexData;
  83447. /**
  83448. * Creates the VertexData of the Disc or regular Polygon
  83449. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  83450. * * radius the radius of the disc, optional default 0.5
  83451. * * tessellation the number of polygon sides, optional, default 64
  83452. * * 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
  83453. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83454. * * 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)
  83455. * * 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)
  83456. * @returns the VertexData of the box
  83457. */
  83458. static CreateDisc(options: {
  83459. radius?: number;
  83460. tessellation?: number;
  83461. arc?: number;
  83462. sideOrientation?: number;
  83463. frontUVs?: Vector4;
  83464. backUVs?: Vector4;
  83465. }): VertexData;
  83466. /**
  83467. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  83468. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  83469. * @param polygon a mesh built from polygonTriangulation.build()
  83470. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83471. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  83472. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  83473. * @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)
  83474. * @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)
  83475. * @returns the VertexData of the Polygon
  83476. */
  83477. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  83478. /**
  83479. * Creates the VertexData of the IcoSphere
  83480. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  83481. * * radius the radius of the IcoSphere, optional default 1
  83482. * * radiusX allows stretching in the x direction, optional, default radius
  83483. * * radiusY allows stretching in the y direction, optional, default radius
  83484. * * radiusZ allows stretching in the z direction, optional, default radius
  83485. * * flat when true creates a flat shaded mesh, optional, default true
  83486. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  83487. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83488. * * 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)
  83489. * * 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)
  83490. * @returns the VertexData of the IcoSphere
  83491. */
  83492. static CreateIcoSphere(options: {
  83493. radius?: number;
  83494. radiusX?: number;
  83495. radiusY?: number;
  83496. radiusZ?: number;
  83497. flat?: boolean;
  83498. subdivisions?: number;
  83499. sideOrientation?: number;
  83500. frontUVs?: Vector4;
  83501. backUVs?: Vector4;
  83502. }): VertexData;
  83503. /**
  83504. * Creates the VertexData for a Polyhedron
  83505. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  83506. * * type provided types are:
  83507. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  83508. * * 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)
  83509. * * size the size of the IcoSphere, optional default 1
  83510. * * sizeX allows stretching in the x direction, optional, default size
  83511. * * sizeY allows stretching in the y direction, optional, default size
  83512. * * sizeZ allows stretching in the z direction, optional, default size
  83513. * * 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
  83514. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  83515. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  83516. * * flat when true creates a flat shaded mesh, optional, default true
  83517. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  83518. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83519. * * 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)
  83520. * * 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)
  83521. * @returns the VertexData of the Polyhedron
  83522. */
  83523. static CreatePolyhedron(options: {
  83524. type?: number;
  83525. size?: number;
  83526. sizeX?: number;
  83527. sizeY?: number;
  83528. sizeZ?: number;
  83529. custom?: any;
  83530. faceUV?: Vector4[];
  83531. faceColors?: Color4[];
  83532. flat?: boolean;
  83533. sideOrientation?: number;
  83534. frontUVs?: Vector4;
  83535. backUVs?: Vector4;
  83536. }): VertexData;
  83537. /**
  83538. * Creates the VertexData for a TorusKnot
  83539. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  83540. * * radius the radius of the torus knot, optional, default 2
  83541. * * tube the thickness of the tube, optional, default 0.5
  83542. * * radialSegments the number of sides on each tube segments, optional, default 32
  83543. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  83544. * * p the number of windings around the z axis, optional, default 2
  83545. * * q the number of windings around the x axis, optional, default 3
  83546. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83547. * * 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)
  83548. * * 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)
  83549. * @returns the VertexData of the Torus Knot
  83550. */
  83551. static CreateTorusKnot(options: {
  83552. radius?: number;
  83553. tube?: number;
  83554. radialSegments?: number;
  83555. tubularSegments?: number;
  83556. p?: number;
  83557. q?: number;
  83558. sideOrientation?: number;
  83559. frontUVs?: Vector4;
  83560. backUVs?: Vector4;
  83561. }): VertexData;
  83562. /**
  83563. * Compute normals for given positions and indices
  83564. * @param positions an array of vertex positions, [...., x, y, z, ......]
  83565. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  83566. * @param normals an array of vertex normals, [...., x, y, z, ......]
  83567. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  83568. * * facetNormals : optional array of facet normals (vector3)
  83569. * * facetPositions : optional array of facet positions (vector3)
  83570. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  83571. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  83572. * * bInfo : optional bounding info, required for facetPartitioning computation
  83573. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  83574. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  83575. * * useRightHandedSystem: optional boolean to for right handed system computation
  83576. * * depthSort : optional boolean to enable the facet depth sort computation
  83577. * * distanceTo : optional Vector3 to compute the facet depth from this location
  83578. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  83579. */
  83580. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  83581. facetNormals?: any;
  83582. facetPositions?: any;
  83583. facetPartitioning?: any;
  83584. ratio?: number;
  83585. bInfo?: any;
  83586. bbSize?: Vector3;
  83587. subDiv?: any;
  83588. useRightHandedSystem?: boolean;
  83589. depthSort?: boolean;
  83590. distanceTo?: Vector3;
  83591. depthSortedFacets?: any;
  83592. }): void;
  83593. /** @hidden */
  83594. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  83595. /**
  83596. * Applies VertexData created from the imported parameters to the geometry
  83597. * @param parsedVertexData the parsed data from an imported file
  83598. * @param geometry the geometry to apply the VertexData to
  83599. */
  83600. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  83601. }
  83602. }
  83603. declare module BABYLON {
  83604. /**
  83605. * Class containing static functions to help procedurally build meshes
  83606. */
  83607. export class DiscBuilder {
  83608. /**
  83609. * Creates a plane polygonal mesh. By default, this is a disc
  83610. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  83611. * * 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
  83612. * * 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
  83613. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  83614. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  83615. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  83616. * @param name defines the name of the mesh
  83617. * @param options defines the options used to create the mesh
  83618. * @param scene defines the hosting scene
  83619. * @returns the plane polygonal mesh
  83620. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  83621. */
  83622. static CreateDisc(name: string, options: {
  83623. radius?: number;
  83624. tessellation?: number;
  83625. arc?: number;
  83626. updatable?: boolean;
  83627. sideOrientation?: number;
  83628. frontUVs?: Vector4;
  83629. backUVs?: Vector4;
  83630. }, scene?: Nullable<Scene>): Mesh;
  83631. }
  83632. }
  83633. declare module BABYLON {
  83634. /**
  83635. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  83636. *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.
  83637. * The SPS is also a particle system. It provides some methods to manage the particles.
  83638. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  83639. *
  83640. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  83641. */
  83642. export class SolidParticleSystem implements IDisposable {
  83643. /**
  83644. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  83645. * Example : var p = SPS.particles[i];
  83646. */
  83647. particles: SolidParticle[];
  83648. /**
  83649. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  83650. */
  83651. nbParticles: number;
  83652. /**
  83653. * If the particles must ever face the camera (default false). Useful for planar particles.
  83654. */
  83655. billboard: boolean;
  83656. /**
  83657. * Recompute normals when adding a shape
  83658. */
  83659. recomputeNormals: boolean;
  83660. /**
  83661. * This a counter ofr your own usage. It's not set by any SPS functions.
  83662. */
  83663. counter: number;
  83664. /**
  83665. * The SPS name. This name is also given to the underlying mesh.
  83666. */
  83667. name: string;
  83668. /**
  83669. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  83670. */
  83671. mesh: Mesh;
  83672. /**
  83673. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  83674. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  83675. */
  83676. vars: any;
  83677. /**
  83678. * This array is populated when the SPS is set as 'pickable'.
  83679. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  83680. * Each element of this array is an object `{idx: int, faceId: int}`.
  83681. * `idx` is the picked particle index in the `SPS.particles` array
  83682. * `faceId` is the picked face index counted within this particle.
  83683. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  83684. */
  83685. pickedParticles: {
  83686. idx: number;
  83687. faceId: number;
  83688. }[];
  83689. /**
  83690. * This array is populated when `enableDepthSort` is set to true.
  83691. * Each element of this array is an instance of the class DepthSortedParticle.
  83692. */
  83693. depthSortedParticles: DepthSortedParticle[];
  83694. /**
  83695. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  83696. * @hidden
  83697. */
  83698. _bSphereOnly: boolean;
  83699. /**
  83700. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  83701. * @hidden
  83702. */
  83703. _bSphereRadiusFactor: number;
  83704. private _scene;
  83705. private _positions;
  83706. private _indices;
  83707. private _normals;
  83708. private _colors;
  83709. private _uvs;
  83710. private _indices32;
  83711. private _positions32;
  83712. private _normals32;
  83713. private _fixedNormal32;
  83714. private _colors32;
  83715. private _uvs32;
  83716. private _index;
  83717. private _updatable;
  83718. private _pickable;
  83719. private _isVisibilityBoxLocked;
  83720. private _alwaysVisible;
  83721. private _depthSort;
  83722. private _shapeCounter;
  83723. private _copy;
  83724. private _color;
  83725. private _computeParticleColor;
  83726. private _computeParticleTexture;
  83727. private _computeParticleRotation;
  83728. private _computeParticleVertex;
  83729. private _computeBoundingBox;
  83730. private _depthSortParticles;
  83731. private _camera;
  83732. private _mustUnrotateFixedNormals;
  83733. private _particlesIntersect;
  83734. private _needs32Bits;
  83735. /**
  83736. * Creates a SPS (Solid Particle System) object.
  83737. * @param name (String) is the SPS name, this will be the underlying mesh name.
  83738. * @param scene (Scene) is the scene in which the SPS is added.
  83739. * @param options defines the options of the sps e.g.
  83740. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  83741. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  83742. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  83743. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  83744. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  83745. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  83746. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  83747. */
  83748. constructor(name: string, scene: Scene, options?: {
  83749. updatable?: boolean;
  83750. isPickable?: boolean;
  83751. enableDepthSort?: boolean;
  83752. particleIntersection?: boolean;
  83753. boundingSphereOnly?: boolean;
  83754. bSphereRadiusFactor?: number;
  83755. });
  83756. /**
  83757. * Builds the SPS underlying mesh. Returns a standard Mesh.
  83758. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  83759. * @returns the created mesh
  83760. */
  83761. buildMesh(): Mesh;
  83762. /**
  83763. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  83764. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  83765. * Thus the particles generated from `digest()` have their property `position` set yet.
  83766. * @param mesh ( Mesh ) is the mesh to be digested
  83767. * @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
  83768. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  83769. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  83770. * @returns the current SPS
  83771. */
  83772. digest(mesh: Mesh, options?: {
  83773. facetNb?: number;
  83774. number?: number;
  83775. delta?: number;
  83776. }): SolidParticleSystem;
  83777. private _unrotateFixedNormals;
  83778. private _resetCopy;
  83779. private _meshBuilder;
  83780. private _posToShape;
  83781. private _uvsToShapeUV;
  83782. private _addParticle;
  83783. /**
  83784. * Adds some particles to the SPS from the model shape. Returns the shape id.
  83785. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  83786. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  83787. * @param nb (positive integer) the number of particles to be created from this model
  83788. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  83789. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  83790. * @returns the number of shapes in the system
  83791. */
  83792. addShape(mesh: Mesh, nb: number, options?: {
  83793. positionFunction?: any;
  83794. vertexFunction?: any;
  83795. }): number;
  83796. private _rebuildParticle;
  83797. /**
  83798. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  83799. * @returns the SPS.
  83800. */
  83801. rebuildMesh(): SolidParticleSystem;
  83802. /**
  83803. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  83804. * This method calls `updateParticle()` for each particle of the SPS.
  83805. * For an animated SPS, it is usually called within the render loop.
  83806. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  83807. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  83808. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  83809. * @returns the SPS.
  83810. */
  83811. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  83812. /**
  83813. * Disposes the SPS.
  83814. */
  83815. dispose(): void;
  83816. /**
  83817. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  83818. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  83819. * @returns the SPS.
  83820. */
  83821. refreshVisibleSize(): SolidParticleSystem;
  83822. /**
  83823. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  83824. * @param size the size (float) of the visibility box
  83825. * note : this doesn't lock the SPS mesh bounding box.
  83826. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  83827. */
  83828. setVisibilityBox(size: number): void;
  83829. /**
  83830. * Gets whether the SPS as always visible or not
  83831. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  83832. */
  83833. /**
  83834. * Sets the SPS as always visible or not
  83835. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  83836. */
  83837. isAlwaysVisible: boolean;
  83838. /**
  83839. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  83840. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  83841. */
  83842. /**
  83843. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  83844. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  83845. */
  83846. isVisibilityBoxLocked: boolean;
  83847. /**
  83848. * Tells to `setParticles()` to compute the particle rotations or not.
  83849. * Default value : true. The SPS is faster when it's set to false.
  83850. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  83851. */
  83852. /**
  83853. * Gets if `setParticles()` computes the particle rotations or not.
  83854. * Default value : true. The SPS is faster when it's set to false.
  83855. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  83856. */
  83857. computeParticleRotation: boolean;
  83858. /**
  83859. * Tells to `setParticles()` to compute the particle colors or not.
  83860. * Default value : true. The SPS is faster when it's set to false.
  83861. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  83862. */
  83863. /**
  83864. * Gets if `setParticles()` computes the particle colors or not.
  83865. * Default value : true. The SPS is faster when it's set to false.
  83866. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  83867. */
  83868. computeParticleColor: boolean;
  83869. /**
  83870. * Gets if `setParticles()` computes the particle textures or not.
  83871. * Default value : true. The SPS is faster when it's set to false.
  83872. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  83873. */
  83874. computeParticleTexture: boolean;
  83875. /**
  83876. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  83877. * Default value : false. The SPS is faster when it's set to false.
  83878. * Note : the particle custom vertex positions aren't stored values.
  83879. */
  83880. /**
  83881. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  83882. * Default value : false. The SPS is faster when it's set to false.
  83883. * Note : the particle custom vertex positions aren't stored values.
  83884. */
  83885. computeParticleVertex: boolean;
  83886. /**
  83887. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  83888. */
  83889. /**
  83890. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  83891. */
  83892. computeBoundingBox: boolean;
  83893. /**
  83894. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  83895. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  83896. * Default : `true`
  83897. */
  83898. /**
  83899. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  83900. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  83901. * Default : `true`
  83902. */
  83903. depthSortParticles: boolean;
  83904. /**
  83905. * This function does nothing. It may be overwritten to set all the particle first values.
  83906. * The SPS doesn't call this function, you may have to call it by your own.
  83907. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  83908. */
  83909. initParticles(): void;
  83910. /**
  83911. * This function does nothing. It may be overwritten to recycle a particle.
  83912. * The SPS doesn't call this function, you may have to call it by your own.
  83913. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  83914. * @param particle The particle to recycle
  83915. * @returns the recycled particle
  83916. */
  83917. recycleParticle(particle: SolidParticle): SolidParticle;
  83918. /**
  83919. * Updates a particle : this function should be overwritten by the user.
  83920. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  83921. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  83922. * @example : just set a particle position or velocity and recycle conditions
  83923. * @param particle The particle to update
  83924. * @returns the updated particle
  83925. */
  83926. updateParticle(particle: SolidParticle): SolidParticle;
  83927. /**
  83928. * Updates a vertex of a particle : it can be overwritten by the user.
  83929. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  83930. * @param particle the current particle
  83931. * @param vertex the current index of the current particle
  83932. * @param pt the index of the current vertex in the particle shape
  83933. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  83934. * @example : just set a vertex particle position
  83935. * @returns the updated vertex
  83936. */
  83937. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  83938. /**
  83939. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  83940. * This does nothing and may be overwritten by the user.
  83941. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  83942. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  83943. * @param update the boolean update value actually passed to setParticles()
  83944. */
  83945. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  83946. /**
  83947. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  83948. * This will be passed three parameters.
  83949. * This does nothing and may be overwritten by the user.
  83950. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  83951. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  83952. * @param update the boolean update value actually passed to setParticles()
  83953. */
  83954. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  83955. }
  83956. }
  83957. declare module BABYLON {
  83958. /**
  83959. * Represents one particle of a solid particle system.
  83960. */
  83961. export class SolidParticle {
  83962. /**
  83963. * particle global index
  83964. */
  83965. idx: number;
  83966. /**
  83967. * The color of the particle
  83968. */
  83969. color: Nullable<Color4>;
  83970. /**
  83971. * The world space position of the particle.
  83972. */
  83973. position: Vector3;
  83974. /**
  83975. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  83976. */
  83977. rotation: Vector3;
  83978. /**
  83979. * The world space rotation quaternion of the particle.
  83980. */
  83981. rotationQuaternion: Nullable<Quaternion>;
  83982. /**
  83983. * The scaling of the particle.
  83984. */
  83985. scaling: Vector3;
  83986. /**
  83987. * The uvs of the particle.
  83988. */
  83989. uvs: Vector4;
  83990. /**
  83991. * The current speed of the particle.
  83992. */
  83993. velocity: Vector3;
  83994. /**
  83995. * The pivot point in the particle local space.
  83996. */
  83997. pivot: Vector3;
  83998. /**
  83999. * Must the particle be translated from its pivot point in its local space ?
  84000. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  84001. * Default : false
  84002. */
  84003. translateFromPivot: boolean;
  84004. /**
  84005. * Is the particle active or not ?
  84006. */
  84007. alive: boolean;
  84008. /**
  84009. * Is the particle visible or not ?
  84010. */
  84011. isVisible: boolean;
  84012. /**
  84013. * Index of this particle in the global "positions" array (Internal use)
  84014. * @hidden
  84015. */
  84016. _pos: number;
  84017. /**
  84018. * @hidden Index of this particle in the global "indices" array (Internal use)
  84019. */
  84020. _ind: number;
  84021. /**
  84022. * @hidden ModelShape of this particle (Internal use)
  84023. */
  84024. _model: ModelShape;
  84025. /**
  84026. * ModelShape id of this particle
  84027. */
  84028. shapeId: number;
  84029. /**
  84030. * Index of the particle in its shape id (Internal use)
  84031. */
  84032. idxInShape: number;
  84033. /**
  84034. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  84035. */
  84036. _modelBoundingInfo: BoundingInfo;
  84037. /**
  84038. * @hidden Particle BoundingInfo object (Internal use)
  84039. */
  84040. _boundingInfo: BoundingInfo;
  84041. /**
  84042. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  84043. */
  84044. _sps: SolidParticleSystem;
  84045. /**
  84046. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  84047. */
  84048. _stillInvisible: boolean;
  84049. /**
  84050. * @hidden Last computed particle rotation matrix
  84051. */
  84052. _rotationMatrix: number[];
  84053. /**
  84054. * Parent particle Id, if any.
  84055. * Default null.
  84056. */
  84057. parentId: Nullable<number>;
  84058. /**
  84059. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  84060. * The possible values are :
  84061. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  84062. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  84063. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  84064. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  84065. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  84066. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  84067. * */
  84068. cullingStrategy: number;
  84069. /**
  84070. * @hidden Internal global position in the SPS.
  84071. */
  84072. _globalPosition: Vector3;
  84073. /**
  84074. * Creates a Solid Particle object.
  84075. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  84076. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  84077. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  84078. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  84079. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  84080. * @param shapeId (integer) is the model shape identifier in the SPS.
  84081. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  84082. * @param sps defines the sps it is associated to
  84083. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  84084. */
  84085. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  84086. /**
  84087. * Legacy support, changed scale to scaling
  84088. */
  84089. /**
  84090. * Legacy support, changed scale to scaling
  84091. */
  84092. scale: Vector3;
  84093. /**
  84094. * Legacy support, changed quaternion to rotationQuaternion
  84095. */
  84096. /**
  84097. * Legacy support, changed quaternion to rotationQuaternion
  84098. */
  84099. quaternion: Nullable<Quaternion>;
  84100. /**
  84101. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  84102. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  84103. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  84104. * @returns true if it intersects
  84105. */
  84106. intersectsMesh(target: Mesh | SolidParticle): boolean;
  84107. /**
  84108. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  84109. * A particle is in the frustum if its bounding box intersects the frustum
  84110. * @param frustumPlanes defines the frustum to test
  84111. * @returns true if the particle is in the frustum planes
  84112. */
  84113. isInFrustum(frustumPlanes: Plane[]): boolean;
  84114. /**
  84115. * get the rotation matrix of the particle
  84116. * @hidden
  84117. */
  84118. getRotationMatrix(m: Matrix): void;
  84119. }
  84120. /**
  84121. * Represents the shape of the model used by one particle of a solid particle system.
  84122. * SPS internal tool, don't use it manually.
  84123. */
  84124. export class ModelShape {
  84125. /**
  84126. * The shape id
  84127. * @hidden
  84128. */
  84129. shapeID: number;
  84130. /**
  84131. * flat array of model positions (internal use)
  84132. * @hidden
  84133. */
  84134. _shape: Vector3[];
  84135. /**
  84136. * flat array of model UVs (internal use)
  84137. * @hidden
  84138. */
  84139. _shapeUV: number[];
  84140. /**
  84141. * length of the shape in the model indices array (internal use)
  84142. * @hidden
  84143. */
  84144. _indicesLength: number;
  84145. /**
  84146. * Custom position function (internal use)
  84147. * @hidden
  84148. */
  84149. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  84150. /**
  84151. * Custom vertex function (internal use)
  84152. * @hidden
  84153. */
  84154. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  84155. /**
  84156. * 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.
  84157. * SPS internal tool, don't use it manually.
  84158. * @hidden
  84159. */
  84160. 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>);
  84161. }
  84162. /**
  84163. * Represents a Depth Sorted Particle in the solid particle system.
  84164. */
  84165. export class DepthSortedParticle {
  84166. /**
  84167. * Index of the particle in the "indices" array
  84168. */
  84169. ind: number;
  84170. /**
  84171. * Length of the particle shape in the "indices" array
  84172. */
  84173. indicesLength: number;
  84174. /**
  84175. * Squared distance from the particle to the camera
  84176. */
  84177. sqDistance: number;
  84178. }
  84179. }
  84180. declare module BABYLON {
  84181. /**
  84182. * @hidden
  84183. */
  84184. export class _MeshCollisionData {
  84185. _checkCollisions: boolean;
  84186. _collisionMask: number;
  84187. _collisionGroup: number;
  84188. _collider: Nullable<Collider>;
  84189. _oldPositionForCollisions: Vector3;
  84190. _diffPositionForCollisions: Vector3;
  84191. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  84192. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  84193. }
  84194. }
  84195. declare module BABYLON {
  84196. /**
  84197. * Class used to store all common mesh properties
  84198. */
  84199. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  84200. /** No occlusion */
  84201. static OCCLUSION_TYPE_NONE: number;
  84202. /** Occlusion set to optimisitic */
  84203. static OCCLUSION_TYPE_OPTIMISTIC: number;
  84204. /** Occlusion set to strict */
  84205. static OCCLUSION_TYPE_STRICT: number;
  84206. /** Use an accurante occlusion algorithm */
  84207. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  84208. /** Use a conservative occlusion algorithm */
  84209. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  84210. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  84211. * Test order :
  84212. * Is the bounding sphere outside the frustum ?
  84213. * If not, are the bounding box vertices outside the frustum ?
  84214. * It not, then the cullable object is in the frustum.
  84215. */
  84216. static readonly CULLINGSTRATEGY_STANDARD: number;
  84217. /** Culling strategy : Bounding Sphere Only.
  84218. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  84219. * It's also less accurate than the standard because some not visible objects can still be selected.
  84220. * Test : is the bounding sphere outside the frustum ?
  84221. * If not, then the cullable object is in the frustum.
  84222. */
  84223. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  84224. /** Culling strategy : Optimistic Inclusion.
  84225. * This in an inclusion test first, then the standard exclusion test.
  84226. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  84227. * 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.
  84228. * Anyway, it's as accurate as the standard strategy.
  84229. * Test :
  84230. * Is the cullable object bounding sphere center in the frustum ?
  84231. * If not, apply the default culling strategy.
  84232. */
  84233. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  84234. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  84235. * This in an inclusion test first, then the bounding sphere only exclusion test.
  84236. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  84237. * 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.
  84238. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  84239. * Test :
  84240. * Is the cullable object bounding sphere center in the frustum ?
  84241. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  84242. */
  84243. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  84244. /**
  84245. * No billboard
  84246. */
  84247. static readonly BILLBOARDMODE_NONE: number;
  84248. /** Billboard on X axis */
  84249. static readonly BILLBOARDMODE_X: number;
  84250. /** Billboard on Y axis */
  84251. static readonly BILLBOARDMODE_Y: number;
  84252. /** Billboard on Z axis */
  84253. static readonly BILLBOARDMODE_Z: number;
  84254. /** Billboard on all axes */
  84255. static readonly BILLBOARDMODE_ALL: number;
  84256. private _internalAbstractMeshDataInfo;
  84257. /**
  84258. * The culling strategy to use to check whether the mesh must be rendered or not.
  84259. * This value can be changed at any time and will be used on the next render mesh selection.
  84260. * The possible values are :
  84261. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  84262. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  84263. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  84264. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  84265. * Please read each static variable documentation to get details about the culling process.
  84266. * */
  84267. cullingStrategy: number;
  84268. /**
  84269. * Gets the number of facets in the mesh
  84270. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  84271. */
  84272. readonly facetNb: number;
  84273. /**
  84274. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  84275. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  84276. */
  84277. partitioningSubdivisions: number;
  84278. /**
  84279. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  84280. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  84281. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  84282. */
  84283. partitioningBBoxRatio: number;
  84284. /**
  84285. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  84286. * Works only for updatable meshes.
  84287. * Doesn't work with multi-materials
  84288. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  84289. */
  84290. mustDepthSortFacets: boolean;
  84291. /**
  84292. * The location (Vector3) where the facet depth sort must be computed from.
  84293. * By default, the active camera position.
  84294. * Used only when facet depth sort is enabled
  84295. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  84296. */
  84297. facetDepthSortFrom: Vector3;
  84298. /**
  84299. * gets a boolean indicating if facetData is enabled
  84300. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  84301. */
  84302. readonly isFacetDataEnabled: boolean;
  84303. /** @hidden */
  84304. _updateNonUniformScalingState(value: boolean): boolean;
  84305. /**
  84306. * An event triggered when this mesh collides with another one
  84307. */
  84308. onCollideObservable: Observable<AbstractMesh>;
  84309. /** Set a function to call when this mesh collides with another one */
  84310. onCollide: () => void;
  84311. /**
  84312. * An event triggered when the collision's position changes
  84313. */
  84314. onCollisionPositionChangeObservable: Observable<Vector3>;
  84315. /** Set a function to call when the collision's position changes */
  84316. onCollisionPositionChange: () => void;
  84317. /**
  84318. * An event triggered when material is changed
  84319. */
  84320. onMaterialChangedObservable: Observable<AbstractMesh>;
  84321. /**
  84322. * Gets or sets the orientation for POV movement & rotation
  84323. */
  84324. definedFacingForward: boolean;
  84325. /** @hidden */
  84326. _occlusionQuery: Nullable<WebGLQuery>;
  84327. /** @hidden */
  84328. _isActive: boolean;
  84329. /** @hidden */
  84330. _onlyForInstances: boolean;
  84331. /** @hidden */
  84332. _renderingGroup: Nullable<RenderingGroup>;
  84333. /**
  84334. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  84335. */
  84336. /**
  84337. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  84338. */
  84339. visibility: number;
  84340. /** Gets or sets the alpha index used to sort transparent meshes
  84341. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  84342. */
  84343. alphaIndex: number;
  84344. /**
  84345. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  84346. */
  84347. isVisible: boolean;
  84348. /**
  84349. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  84350. */
  84351. isPickable: boolean;
  84352. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  84353. showSubMeshesBoundingBox: boolean;
  84354. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  84355. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  84356. */
  84357. isBlocker: boolean;
  84358. /**
  84359. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  84360. */
  84361. enablePointerMoveEvents: boolean;
  84362. /**
  84363. * Specifies the rendering group id for this mesh (0 by default)
  84364. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  84365. */
  84366. renderingGroupId: number;
  84367. private _material;
  84368. /** Gets or sets current material */
  84369. material: Nullable<Material>;
  84370. /**
  84371. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  84372. * @see http://doc.babylonjs.com/babylon101/shadows
  84373. */
  84374. receiveShadows: boolean;
  84375. /** Defines color to use when rendering outline */
  84376. outlineColor: Color3;
  84377. /** Define width to use when rendering outline */
  84378. outlineWidth: number;
  84379. /** Defines color to use when rendering overlay */
  84380. overlayColor: Color3;
  84381. /** Defines alpha to use when rendering overlay */
  84382. overlayAlpha: number;
  84383. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  84384. hasVertexAlpha: boolean;
  84385. /** 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) */
  84386. useVertexColors: boolean;
  84387. /**
  84388. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  84389. */
  84390. computeBonesUsingShaders: boolean;
  84391. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  84392. numBoneInfluencers: number;
  84393. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  84394. applyFog: boolean;
  84395. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  84396. useOctreeForRenderingSelection: boolean;
  84397. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  84398. useOctreeForPicking: boolean;
  84399. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  84400. useOctreeForCollisions: boolean;
  84401. /**
  84402. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  84403. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  84404. */
  84405. layerMask: number;
  84406. /**
  84407. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  84408. */
  84409. alwaysSelectAsActiveMesh: boolean;
  84410. /**
  84411. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  84412. */
  84413. doNotSyncBoundingInfo: boolean;
  84414. /**
  84415. * Gets or sets the current action manager
  84416. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  84417. */
  84418. actionManager: Nullable<AbstractActionManager>;
  84419. private _meshCollisionData;
  84420. /**
  84421. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  84422. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  84423. */
  84424. ellipsoid: Vector3;
  84425. /**
  84426. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  84427. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  84428. */
  84429. ellipsoidOffset: Vector3;
  84430. /**
  84431. * Gets or sets a collision mask used to mask collisions (default is -1).
  84432. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  84433. */
  84434. collisionMask: number;
  84435. /**
  84436. * Gets or sets the current collision group mask (-1 by default).
  84437. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  84438. */
  84439. collisionGroup: number;
  84440. /**
  84441. * Defines edge width used when edgesRenderer is enabled
  84442. * @see https://www.babylonjs-playground.com/#10OJSG#13
  84443. */
  84444. edgesWidth: number;
  84445. /**
  84446. * Defines edge color used when edgesRenderer is enabled
  84447. * @see https://www.babylonjs-playground.com/#10OJSG#13
  84448. */
  84449. edgesColor: Color4;
  84450. /** @hidden */
  84451. _edgesRenderer: Nullable<IEdgesRenderer>;
  84452. /** @hidden */
  84453. _masterMesh: Nullable<AbstractMesh>;
  84454. /** @hidden */
  84455. _boundingInfo: Nullable<BoundingInfo>;
  84456. /** @hidden */
  84457. _renderId: number;
  84458. /**
  84459. * Gets or sets the list of subMeshes
  84460. * @see http://doc.babylonjs.com/how_to/multi_materials
  84461. */
  84462. subMeshes: SubMesh[];
  84463. /** @hidden */
  84464. _intersectionsInProgress: AbstractMesh[];
  84465. /** @hidden */
  84466. _unIndexed: boolean;
  84467. /** @hidden */
  84468. _lightSources: Light[];
  84469. /** Gets the list of lights affecting that mesh */
  84470. readonly lightSources: Light[];
  84471. /** @hidden */
  84472. readonly _positions: Nullable<Vector3[]>;
  84473. /** @hidden */
  84474. _waitingData: {
  84475. lods: Nullable<any>;
  84476. actions: Nullable<any>;
  84477. freezeWorldMatrix: Nullable<boolean>;
  84478. };
  84479. /** @hidden */
  84480. _bonesTransformMatrices: Nullable<Float32Array>;
  84481. /**
  84482. * Gets or sets a skeleton to apply skining transformations
  84483. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  84484. */
  84485. skeleton: Nullable<Skeleton>;
  84486. /**
  84487. * An event triggered when the mesh is rebuilt.
  84488. */
  84489. onRebuildObservable: Observable<AbstractMesh>;
  84490. /**
  84491. * Creates a new AbstractMesh
  84492. * @param name defines the name of the mesh
  84493. * @param scene defines the hosting scene
  84494. */
  84495. constructor(name: string, scene?: Nullable<Scene>);
  84496. /**
  84497. * Returns the string "AbstractMesh"
  84498. * @returns "AbstractMesh"
  84499. */
  84500. getClassName(): string;
  84501. /**
  84502. * Gets a string representation of the current mesh
  84503. * @param fullDetails defines a boolean indicating if full details must be included
  84504. * @returns a string representation of the current mesh
  84505. */
  84506. toString(fullDetails?: boolean): string;
  84507. /**
  84508. * @hidden
  84509. */
  84510. protected _getEffectiveParent(): Nullable<Node>;
  84511. /** @hidden */
  84512. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  84513. /** @hidden */
  84514. _rebuild(): void;
  84515. /** @hidden */
  84516. _resyncLightSources(): void;
  84517. /** @hidden */
  84518. _resyncLighSource(light: Light): void;
  84519. /** @hidden */
  84520. _unBindEffect(): void;
  84521. /** @hidden */
  84522. _removeLightSource(light: Light): void;
  84523. private _markSubMeshesAsDirty;
  84524. /** @hidden */
  84525. _markSubMeshesAsLightDirty(): void;
  84526. /** @hidden */
  84527. _markSubMeshesAsAttributesDirty(): void;
  84528. /** @hidden */
  84529. _markSubMeshesAsMiscDirty(): void;
  84530. /**
  84531. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  84532. */
  84533. scaling: Vector3;
  84534. /**
  84535. * Returns true if the mesh is blocked. Implemented by child classes
  84536. */
  84537. readonly isBlocked: boolean;
  84538. /**
  84539. * Returns the mesh itself by default. Implemented by child classes
  84540. * @param camera defines the camera to use to pick the right LOD level
  84541. * @returns the currentAbstractMesh
  84542. */
  84543. getLOD(camera: Camera): Nullable<AbstractMesh>;
  84544. /**
  84545. * Returns 0 by default. Implemented by child classes
  84546. * @returns an integer
  84547. */
  84548. getTotalVertices(): number;
  84549. /**
  84550. * Returns a positive integer : the total number of indices in this mesh geometry.
  84551. * @returns the numner of indices or zero if the mesh has no geometry.
  84552. */
  84553. getTotalIndices(): number;
  84554. /**
  84555. * Returns null by default. Implemented by child classes
  84556. * @returns null
  84557. */
  84558. getIndices(): Nullable<IndicesArray>;
  84559. /**
  84560. * Returns the array of the requested vertex data kind. Implemented by child classes
  84561. * @param kind defines the vertex data kind to use
  84562. * @returns null
  84563. */
  84564. getVerticesData(kind: string): Nullable<FloatArray>;
  84565. /**
  84566. * Sets the vertex data of the mesh geometry for the requested `kind`.
  84567. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  84568. * Note that a new underlying VertexBuffer object is created each call.
  84569. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  84570. * @param kind defines vertex data kind:
  84571. * * VertexBuffer.PositionKind
  84572. * * VertexBuffer.UVKind
  84573. * * VertexBuffer.UV2Kind
  84574. * * VertexBuffer.UV3Kind
  84575. * * VertexBuffer.UV4Kind
  84576. * * VertexBuffer.UV5Kind
  84577. * * VertexBuffer.UV6Kind
  84578. * * VertexBuffer.ColorKind
  84579. * * VertexBuffer.MatricesIndicesKind
  84580. * * VertexBuffer.MatricesIndicesExtraKind
  84581. * * VertexBuffer.MatricesWeightsKind
  84582. * * VertexBuffer.MatricesWeightsExtraKind
  84583. * @param data defines the data source
  84584. * @param updatable defines if the data must be flagged as updatable (or static)
  84585. * @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
  84586. * @returns the current mesh
  84587. */
  84588. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  84589. /**
  84590. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  84591. * If the mesh has no geometry, it is simply returned as it is.
  84592. * @param kind defines vertex data kind:
  84593. * * VertexBuffer.PositionKind
  84594. * * VertexBuffer.UVKind
  84595. * * VertexBuffer.UV2Kind
  84596. * * VertexBuffer.UV3Kind
  84597. * * VertexBuffer.UV4Kind
  84598. * * VertexBuffer.UV5Kind
  84599. * * VertexBuffer.UV6Kind
  84600. * * VertexBuffer.ColorKind
  84601. * * VertexBuffer.MatricesIndicesKind
  84602. * * VertexBuffer.MatricesIndicesExtraKind
  84603. * * VertexBuffer.MatricesWeightsKind
  84604. * * VertexBuffer.MatricesWeightsExtraKind
  84605. * @param data defines the data source
  84606. * @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
  84607. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  84608. * @returns the current mesh
  84609. */
  84610. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  84611. /**
  84612. * Sets the mesh indices,
  84613. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  84614. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  84615. * @param totalVertices Defines the total number of vertices
  84616. * @returns the current mesh
  84617. */
  84618. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  84619. /**
  84620. * Gets a boolean indicating if specific vertex data is present
  84621. * @param kind defines the vertex data kind to use
  84622. * @returns true is data kind is present
  84623. */
  84624. isVerticesDataPresent(kind: string): boolean;
  84625. /**
  84626. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  84627. * @returns a BoundingInfo
  84628. */
  84629. getBoundingInfo(): BoundingInfo;
  84630. /**
  84631. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  84632. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  84633. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  84634. * @returns the current mesh
  84635. */
  84636. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean): AbstractMesh;
  84637. /**
  84638. * Overwrite the current bounding info
  84639. * @param boundingInfo defines the new bounding info
  84640. * @returns the current mesh
  84641. */
  84642. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  84643. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  84644. readonly useBones: boolean;
  84645. /** @hidden */
  84646. _preActivate(): void;
  84647. /** @hidden */
  84648. _preActivateForIntermediateRendering(renderId: number): void;
  84649. /** @hidden */
  84650. _activate(renderId: number): boolean;
  84651. /** @hidden */
  84652. _postActivate(): void;
  84653. /** @hidden */
  84654. _freeze(): void;
  84655. /** @hidden */
  84656. _unFreeze(): void;
  84657. /**
  84658. * Gets the current world matrix
  84659. * @returns a Matrix
  84660. */
  84661. getWorldMatrix(): Matrix;
  84662. /** @hidden */
  84663. _getWorldMatrixDeterminant(): number;
  84664. /**
  84665. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  84666. */
  84667. readonly isAnInstance: boolean;
  84668. /**
  84669. * Perform relative position change from the point of view of behind the front of the mesh.
  84670. * This is performed taking into account the meshes current rotation, so you do not have to care.
  84671. * Supports definition of mesh facing forward or backward
  84672. * @param amountRight defines the distance on the right axis
  84673. * @param amountUp defines the distance on the up axis
  84674. * @param amountForward defines the distance on the forward axis
  84675. * @returns the current mesh
  84676. */
  84677. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  84678. /**
  84679. * Calculate relative position change from the point of view of behind the front of the mesh.
  84680. * This is performed taking into account the meshes current rotation, so you do not have to care.
  84681. * Supports definition of mesh facing forward or backward
  84682. * @param amountRight defines the distance on the right axis
  84683. * @param amountUp defines the distance on the up axis
  84684. * @param amountForward defines the distance on the forward axis
  84685. * @returns the new displacement vector
  84686. */
  84687. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  84688. /**
  84689. * Perform relative rotation change from the point of view of behind the front of the mesh.
  84690. * Supports definition of mesh facing forward or backward
  84691. * @param flipBack defines the flip
  84692. * @param twirlClockwise defines the twirl
  84693. * @param tiltRight defines the tilt
  84694. * @returns the current mesh
  84695. */
  84696. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  84697. /**
  84698. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  84699. * Supports definition of mesh facing forward or backward.
  84700. * @param flipBack defines the flip
  84701. * @param twirlClockwise defines the twirl
  84702. * @param tiltRight defines the tilt
  84703. * @returns the new rotation vector
  84704. */
  84705. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  84706. /**
  84707. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  84708. * This means the mesh underlying bounding box and sphere are recomputed.
  84709. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  84710. * @returns the current mesh
  84711. */
  84712. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  84713. /** @hidden */
  84714. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  84715. /** @hidden */
  84716. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  84717. /** @hidden */
  84718. _updateBoundingInfo(): AbstractMesh;
  84719. /** @hidden */
  84720. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  84721. /** @hidden */
  84722. protected _afterComputeWorldMatrix(): void;
  84723. /** @hidden */
  84724. readonly _effectiveMesh: AbstractMesh;
  84725. /**
  84726. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  84727. * A mesh is in the frustum if its bounding box intersects the frustum
  84728. * @param frustumPlanes defines the frustum to test
  84729. * @returns true if the mesh is in the frustum planes
  84730. */
  84731. isInFrustum(frustumPlanes: Plane[]): boolean;
  84732. /**
  84733. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  84734. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  84735. * @param frustumPlanes defines the frustum to test
  84736. * @returns true if the mesh is completely in the frustum planes
  84737. */
  84738. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  84739. /**
  84740. * True if the mesh intersects another mesh or a SolidParticle object
  84741. * @param mesh defines a target mesh or SolidParticle to test
  84742. * @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)
  84743. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  84744. * @returns true if there is an intersection
  84745. */
  84746. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  84747. /**
  84748. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  84749. * @param point defines the point to test
  84750. * @returns true if there is an intersection
  84751. */
  84752. intersectsPoint(point: Vector3): boolean;
  84753. /**
  84754. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  84755. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  84756. */
  84757. checkCollisions: boolean;
  84758. /**
  84759. * Gets Collider object used to compute collisions (not physics)
  84760. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  84761. */
  84762. readonly collider: Nullable<Collider>;
  84763. /**
  84764. * Move the mesh using collision engine
  84765. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  84766. * @param displacement defines the requested displacement vector
  84767. * @returns the current mesh
  84768. */
  84769. moveWithCollisions(displacement: Vector3): AbstractMesh;
  84770. private _onCollisionPositionChange;
  84771. /** @hidden */
  84772. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  84773. /** @hidden */
  84774. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  84775. /** @hidden */
  84776. _checkCollision(collider: Collider): AbstractMesh;
  84777. /** @hidden */
  84778. _generatePointsArray(): boolean;
  84779. /**
  84780. * Checks if the passed Ray intersects with the mesh
  84781. * @param ray defines the ray to use
  84782. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  84783. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  84784. * @returns the picking info
  84785. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  84786. */
  84787. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  84788. /**
  84789. * Clones the current mesh
  84790. * @param name defines the mesh name
  84791. * @param newParent defines the new mesh parent
  84792. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  84793. * @returns the new mesh
  84794. */
  84795. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  84796. /**
  84797. * Disposes all the submeshes of the current meshnp
  84798. * @returns the current mesh
  84799. */
  84800. releaseSubMeshes(): AbstractMesh;
  84801. /**
  84802. * Releases resources associated with this abstract mesh.
  84803. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  84804. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  84805. */
  84806. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  84807. /**
  84808. * Adds the passed mesh as a child to the current mesh
  84809. * @param mesh defines the child mesh
  84810. * @returns the current mesh
  84811. */
  84812. addChild(mesh: AbstractMesh): AbstractMesh;
  84813. /**
  84814. * Removes the passed mesh from the current mesh children list
  84815. * @param mesh defines the child mesh
  84816. * @returns the current mesh
  84817. */
  84818. removeChild(mesh: AbstractMesh): AbstractMesh;
  84819. /** @hidden */
  84820. private _initFacetData;
  84821. /**
  84822. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  84823. * This method can be called within the render loop.
  84824. * 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
  84825. * @returns the current mesh
  84826. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84827. */
  84828. updateFacetData(): AbstractMesh;
  84829. /**
  84830. * Returns the facetLocalNormals array.
  84831. * The normals are expressed in the mesh local spac
  84832. * @returns an array of Vector3
  84833. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84834. */
  84835. getFacetLocalNormals(): Vector3[];
  84836. /**
  84837. * Returns the facetLocalPositions array.
  84838. * The facet positions are expressed in the mesh local space
  84839. * @returns an array of Vector3
  84840. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84841. */
  84842. getFacetLocalPositions(): Vector3[];
  84843. /**
  84844. * Returns the facetLocalPartioning array
  84845. * @returns an array of array of numbers
  84846. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84847. */
  84848. getFacetLocalPartitioning(): number[][];
  84849. /**
  84850. * Returns the i-th facet position in the world system.
  84851. * This method allocates a new Vector3 per call
  84852. * @param i defines the facet index
  84853. * @returns a new Vector3
  84854. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84855. */
  84856. getFacetPosition(i: number): Vector3;
  84857. /**
  84858. * Sets the reference Vector3 with the i-th facet position in the world system
  84859. * @param i defines the facet index
  84860. * @param ref defines the target vector
  84861. * @returns the current mesh
  84862. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84863. */
  84864. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  84865. /**
  84866. * Returns the i-th facet normal in the world system.
  84867. * This method allocates a new Vector3 per call
  84868. * @param i defines the facet index
  84869. * @returns a new Vector3
  84870. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84871. */
  84872. getFacetNormal(i: number): Vector3;
  84873. /**
  84874. * Sets the reference Vector3 with the i-th facet normal in the world system
  84875. * @param i defines the facet index
  84876. * @param ref defines the target vector
  84877. * @returns the current mesh
  84878. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84879. */
  84880. getFacetNormalToRef(i: number, ref: Vector3): this;
  84881. /**
  84882. * 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)
  84883. * @param x defines x coordinate
  84884. * @param y defines y coordinate
  84885. * @param z defines z coordinate
  84886. * @returns the array of facet indexes
  84887. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84888. */
  84889. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  84890. /**
  84891. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  84892. * @param projected sets as the (x,y,z) world projection on the facet
  84893. * @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
  84894. * @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
  84895. * @param x defines x coordinate
  84896. * @param y defines y coordinate
  84897. * @param z defines z coordinate
  84898. * @returns the face index if found (or null instead)
  84899. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84900. */
  84901. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  84902. /**
  84903. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  84904. * @param projected sets as the (x,y,z) local projection on the facet
  84905. * @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
  84906. * @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
  84907. * @param x defines x coordinate
  84908. * @param y defines y coordinate
  84909. * @param z defines z coordinate
  84910. * @returns the face index if found (or null instead)
  84911. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84912. */
  84913. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  84914. /**
  84915. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  84916. * @returns the parameters
  84917. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84918. */
  84919. getFacetDataParameters(): any;
  84920. /**
  84921. * Disables the feature FacetData and frees the related memory
  84922. * @returns the current mesh
  84923. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84924. */
  84925. disableFacetData(): AbstractMesh;
  84926. /**
  84927. * Updates the AbstractMesh indices array
  84928. * @param indices defines the data source
  84929. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  84930. * @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)
  84931. * @returns the current mesh
  84932. */
  84933. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  84934. /**
  84935. * Creates new normals data for the mesh
  84936. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  84937. * @returns the current mesh
  84938. */
  84939. createNormals(updatable: boolean): AbstractMesh;
  84940. /**
  84941. * Align the mesh with a normal
  84942. * @param normal defines the normal to use
  84943. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  84944. * @returns the current mesh
  84945. */
  84946. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  84947. /** @hidden */
  84948. _checkOcclusionQuery(): boolean;
  84949. /**
  84950. * Disables the mesh edge rendering mode
  84951. * @returns the currentAbstractMesh
  84952. */
  84953. disableEdgesRendering(): AbstractMesh;
  84954. /**
  84955. * Enables the edge rendering mode on the mesh.
  84956. * This mode makes the mesh edges visible
  84957. * @param epsilon defines the maximal distance between two angles to detect a face
  84958. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  84959. * @returns the currentAbstractMesh
  84960. * @see https://www.babylonjs-playground.com/#19O9TU#0
  84961. */
  84962. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  84963. }
  84964. }
  84965. declare module BABYLON {
  84966. /**
  84967. * Interface used to define ActionEvent
  84968. */
  84969. export interface IActionEvent {
  84970. /** The mesh or sprite that triggered the action */
  84971. source: any;
  84972. /** The X mouse cursor position at the time of the event */
  84973. pointerX: number;
  84974. /** The Y mouse cursor position at the time of the event */
  84975. pointerY: number;
  84976. /** The mesh that is currently pointed at (can be null) */
  84977. meshUnderPointer: Nullable<AbstractMesh>;
  84978. /** the original (browser) event that triggered the ActionEvent */
  84979. sourceEvent?: any;
  84980. /** additional data for the event */
  84981. additionalData?: any;
  84982. }
  84983. /**
  84984. * ActionEvent is the event being sent when an action is triggered.
  84985. */
  84986. export class ActionEvent implements IActionEvent {
  84987. /** The mesh or sprite that triggered the action */
  84988. source: any;
  84989. /** The X mouse cursor position at the time of the event */
  84990. pointerX: number;
  84991. /** The Y mouse cursor position at the time of the event */
  84992. pointerY: number;
  84993. /** The mesh that is currently pointed at (can be null) */
  84994. meshUnderPointer: Nullable<AbstractMesh>;
  84995. /** the original (browser) event that triggered the ActionEvent */
  84996. sourceEvent?: any;
  84997. /** additional data for the event */
  84998. additionalData?: any;
  84999. /**
  85000. * Creates a new ActionEvent
  85001. * @param source The mesh or sprite that triggered the action
  85002. * @param pointerX The X mouse cursor position at the time of the event
  85003. * @param pointerY The Y mouse cursor position at the time of the event
  85004. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  85005. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  85006. * @param additionalData additional data for the event
  85007. */
  85008. constructor(
  85009. /** The mesh or sprite that triggered the action */
  85010. source: any,
  85011. /** The X mouse cursor position at the time of the event */
  85012. pointerX: number,
  85013. /** The Y mouse cursor position at the time of the event */
  85014. pointerY: number,
  85015. /** The mesh that is currently pointed at (can be null) */
  85016. meshUnderPointer: Nullable<AbstractMesh>,
  85017. /** the original (browser) event that triggered the ActionEvent */
  85018. sourceEvent?: any,
  85019. /** additional data for the event */
  85020. additionalData?: any);
  85021. /**
  85022. * Helper function to auto-create an ActionEvent from a source mesh.
  85023. * @param source The source mesh that triggered the event
  85024. * @param evt The original (browser) event
  85025. * @param additionalData additional data for the event
  85026. * @returns the new ActionEvent
  85027. */
  85028. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  85029. /**
  85030. * Helper function to auto-create an ActionEvent from a source sprite
  85031. * @param source The source sprite that triggered the event
  85032. * @param scene Scene associated with the sprite
  85033. * @param evt The original (browser) event
  85034. * @param additionalData additional data for the event
  85035. * @returns the new ActionEvent
  85036. */
  85037. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  85038. /**
  85039. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  85040. * @param scene the scene where the event occurred
  85041. * @param evt The original (browser) event
  85042. * @returns the new ActionEvent
  85043. */
  85044. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  85045. /**
  85046. * Helper function to auto-create an ActionEvent from a primitive
  85047. * @param prim defines the target primitive
  85048. * @param pointerPos defines the pointer position
  85049. * @param evt The original (browser) event
  85050. * @param additionalData additional data for the event
  85051. * @returns the new ActionEvent
  85052. */
  85053. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  85054. }
  85055. }
  85056. declare module BABYLON {
  85057. /**
  85058. * Abstract class used to decouple action Manager from scene and meshes.
  85059. * Do not instantiate.
  85060. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  85061. */
  85062. export abstract class AbstractActionManager implements IDisposable {
  85063. /** Gets the list of active triggers */
  85064. static Triggers: {
  85065. [key: string]: number;
  85066. };
  85067. /** Gets the cursor to use when hovering items */
  85068. hoverCursor: string;
  85069. /** Gets the list of actions */
  85070. actions: IAction[];
  85071. /**
  85072. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  85073. */
  85074. isRecursive: boolean;
  85075. /**
  85076. * Releases all associated resources
  85077. */
  85078. abstract dispose(): void;
  85079. /**
  85080. * Does this action manager has pointer triggers
  85081. */
  85082. abstract readonly hasPointerTriggers: boolean;
  85083. /**
  85084. * Does this action manager has pick triggers
  85085. */
  85086. abstract readonly hasPickTriggers: boolean;
  85087. /**
  85088. * Process a specific trigger
  85089. * @param trigger defines the trigger to process
  85090. * @param evt defines the event details to be processed
  85091. */
  85092. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  85093. /**
  85094. * Does this action manager handles actions of any of the given triggers
  85095. * @param triggers defines the triggers to be tested
  85096. * @return a boolean indicating whether one (or more) of the triggers is handled
  85097. */
  85098. abstract hasSpecificTriggers(triggers: number[]): boolean;
  85099. /**
  85100. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  85101. * speed.
  85102. * @param triggerA defines the trigger to be tested
  85103. * @param triggerB defines the trigger to be tested
  85104. * @return a boolean indicating whether one (or more) of the triggers is handled
  85105. */
  85106. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  85107. /**
  85108. * Does this action manager handles actions of a given trigger
  85109. * @param trigger defines the trigger to be tested
  85110. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  85111. * @return whether the trigger is handled
  85112. */
  85113. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  85114. /**
  85115. * Serialize this manager to a JSON object
  85116. * @param name defines the property name to store this manager
  85117. * @returns a JSON representation of this manager
  85118. */
  85119. abstract serialize(name: string): any;
  85120. /**
  85121. * Registers an action to this action manager
  85122. * @param action defines the action to be registered
  85123. * @return the action amended (prepared) after registration
  85124. */
  85125. abstract registerAction(action: IAction): Nullable<IAction>;
  85126. /**
  85127. * Unregisters an action to this action manager
  85128. * @param action defines the action to be unregistered
  85129. * @return a boolean indicating whether the action has been unregistered
  85130. */
  85131. abstract unregisterAction(action: IAction): Boolean;
  85132. /**
  85133. * Does exist one action manager with at least one trigger
  85134. **/
  85135. static readonly HasTriggers: boolean;
  85136. /**
  85137. * Does exist one action manager with at least one pick trigger
  85138. **/
  85139. static readonly HasPickTriggers: boolean;
  85140. /**
  85141. * Does exist one action manager that handles actions of a given trigger
  85142. * @param trigger defines the trigger to be tested
  85143. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  85144. **/
  85145. static HasSpecificTrigger(trigger: number): boolean;
  85146. }
  85147. }
  85148. declare module BABYLON {
  85149. /**
  85150. * Defines how a node can be built from a string name.
  85151. */
  85152. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  85153. /**
  85154. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  85155. */
  85156. export class Node implements IBehaviorAware<Node> {
  85157. /** @hidden */
  85158. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  85159. private static _NodeConstructors;
  85160. /**
  85161. * Add a new node constructor
  85162. * @param type defines the type name of the node to construct
  85163. * @param constructorFunc defines the constructor function
  85164. */
  85165. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  85166. /**
  85167. * Returns a node constructor based on type name
  85168. * @param type defines the type name
  85169. * @param name defines the new node name
  85170. * @param scene defines the hosting scene
  85171. * @param options defines optional options to transmit to constructors
  85172. * @returns the new constructor or null
  85173. */
  85174. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  85175. /**
  85176. * Gets or sets the name of the node
  85177. */
  85178. name: string;
  85179. /**
  85180. * Gets or sets the id of the node
  85181. */
  85182. id: string;
  85183. /**
  85184. * Gets or sets the unique id of the node
  85185. */
  85186. uniqueId: number;
  85187. /**
  85188. * Gets or sets a string used to store user defined state for the node
  85189. */
  85190. state: string;
  85191. /**
  85192. * Gets or sets an object used to store user defined information for the node
  85193. */
  85194. metadata: any;
  85195. /**
  85196. * For internal use only. Please do not use.
  85197. */
  85198. reservedDataStore: any;
  85199. /**
  85200. * List of inspectable custom properties (used by the Inspector)
  85201. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  85202. */
  85203. inspectableCustomProperties: IInspectable[];
  85204. /**
  85205. * Gets or sets a boolean used to define if the node must be serialized
  85206. */
  85207. doNotSerialize: boolean;
  85208. /** @hidden */
  85209. _isDisposed: boolean;
  85210. /**
  85211. * Gets a list of Animations associated with the node
  85212. */
  85213. animations: Animation[];
  85214. protected _ranges: {
  85215. [name: string]: Nullable<AnimationRange>;
  85216. };
  85217. /**
  85218. * Callback raised when the node is ready to be used
  85219. */
  85220. onReady: Nullable<(node: Node) => void>;
  85221. private _isEnabled;
  85222. private _isParentEnabled;
  85223. private _isReady;
  85224. /** @hidden */
  85225. _currentRenderId: number;
  85226. private _parentUpdateId;
  85227. /** @hidden */
  85228. _childUpdateId: number;
  85229. /** @hidden */
  85230. _waitingParentId: Nullable<string>;
  85231. /** @hidden */
  85232. _scene: Scene;
  85233. /** @hidden */
  85234. _cache: any;
  85235. private _parentNode;
  85236. private _children;
  85237. /** @hidden */
  85238. _worldMatrix: Matrix;
  85239. /** @hidden */
  85240. _worldMatrixDeterminant: number;
  85241. /** @hidden */
  85242. _worldMatrixDeterminantIsDirty: boolean;
  85243. /** @hidden */
  85244. private _sceneRootNodesIndex;
  85245. /**
  85246. * Gets a boolean indicating if the node has been disposed
  85247. * @returns true if the node was disposed
  85248. */
  85249. isDisposed(): boolean;
  85250. /**
  85251. * Gets or sets the parent of the node (without keeping the current position in the scene)
  85252. * @see https://doc.babylonjs.com/how_to/parenting
  85253. */
  85254. parent: Nullable<Node>;
  85255. private addToSceneRootNodes;
  85256. private removeFromSceneRootNodes;
  85257. private _animationPropertiesOverride;
  85258. /**
  85259. * Gets or sets the animation properties override
  85260. */
  85261. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  85262. /**
  85263. * Gets a string idenfifying the name of the class
  85264. * @returns "Node" string
  85265. */
  85266. getClassName(): string;
  85267. /** @hidden */
  85268. readonly _isNode: boolean;
  85269. /**
  85270. * An event triggered when the mesh is disposed
  85271. */
  85272. onDisposeObservable: Observable<Node>;
  85273. private _onDisposeObserver;
  85274. /**
  85275. * Sets a callback that will be raised when the node will be disposed
  85276. */
  85277. onDispose: () => void;
  85278. /**
  85279. * Creates a new Node
  85280. * @param name the name and id to be given to this node
  85281. * @param scene the scene this node will be added to
  85282. * @param addToRootNodes the node will be added to scene.rootNodes
  85283. */
  85284. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  85285. /**
  85286. * Gets the scene of the node
  85287. * @returns a scene
  85288. */
  85289. getScene(): Scene;
  85290. /**
  85291. * Gets the engine of the node
  85292. * @returns a Engine
  85293. */
  85294. getEngine(): Engine;
  85295. private _behaviors;
  85296. /**
  85297. * Attach a behavior to the node
  85298. * @see http://doc.babylonjs.com/features/behaviour
  85299. * @param behavior defines the behavior to attach
  85300. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  85301. * @returns the current Node
  85302. */
  85303. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  85304. /**
  85305. * Remove an attached behavior
  85306. * @see http://doc.babylonjs.com/features/behaviour
  85307. * @param behavior defines the behavior to attach
  85308. * @returns the current Node
  85309. */
  85310. removeBehavior(behavior: Behavior<Node>): Node;
  85311. /**
  85312. * Gets the list of attached behaviors
  85313. * @see http://doc.babylonjs.com/features/behaviour
  85314. */
  85315. readonly behaviors: Behavior<Node>[];
  85316. /**
  85317. * Gets an attached behavior by name
  85318. * @param name defines the name of the behavior to look for
  85319. * @see http://doc.babylonjs.com/features/behaviour
  85320. * @returns null if behavior was not found else the requested behavior
  85321. */
  85322. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  85323. /**
  85324. * Returns the latest update of the World matrix
  85325. * @returns a Matrix
  85326. */
  85327. getWorldMatrix(): Matrix;
  85328. /** @hidden */
  85329. _getWorldMatrixDeterminant(): number;
  85330. /**
  85331. * Returns directly the latest state of the mesh World matrix.
  85332. * A Matrix is returned.
  85333. */
  85334. readonly worldMatrixFromCache: Matrix;
  85335. /** @hidden */
  85336. _initCache(): void;
  85337. /** @hidden */
  85338. updateCache(force?: boolean): void;
  85339. /** @hidden */
  85340. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  85341. /** @hidden */
  85342. _updateCache(ignoreParentClass?: boolean): void;
  85343. /** @hidden */
  85344. _isSynchronized(): boolean;
  85345. /** @hidden */
  85346. _markSyncedWithParent(): void;
  85347. /** @hidden */
  85348. isSynchronizedWithParent(): boolean;
  85349. /** @hidden */
  85350. isSynchronized(): boolean;
  85351. /**
  85352. * Is this node ready to be used/rendered
  85353. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  85354. * @return true if the node is ready
  85355. */
  85356. isReady(completeCheck?: boolean): boolean;
  85357. /**
  85358. * Is this node enabled?
  85359. * 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
  85360. * @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
  85361. * @return whether this node (and its parent) is enabled
  85362. */
  85363. isEnabled(checkAncestors?: boolean): boolean;
  85364. /** @hidden */
  85365. protected _syncParentEnabledState(): void;
  85366. /**
  85367. * Set the enabled state of this node
  85368. * @param value defines the new enabled state
  85369. */
  85370. setEnabled(value: boolean): void;
  85371. /**
  85372. * Is this node a descendant of the given node?
  85373. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  85374. * @param ancestor defines the parent node to inspect
  85375. * @returns a boolean indicating if this node is a descendant of the given node
  85376. */
  85377. isDescendantOf(ancestor: Node): boolean;
  85378. /** @hidden */
  85379. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  85380. /**
  85381. * Will return all nodes that have this node as ascendant
  85382. * @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
  85383. * @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
  85384. * @return all children nodes of all types
  85385. */
  85386. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  85387. /**
  85388. * Get all child-meshes of this node
  85389. * @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)
  85390. * @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
  85391. * @returns an array of AbstractMesh
  85392. */
  85393. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  85394. /**
  85395. * Get all direct children of this node
  85396. * @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
  85397. * @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)
  85398. * @returns an array of Node
  85399. */
  85400. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  85401. /** @hidden */
  85402. _setReady(state: boolean): void;
  85403. /**
  85404. * Get an animation by name
  85405. * @param name defines the name of the animation to look for
  85406. * @returns null if not found else the requested animation
  85407. */
  85408. getAnimationByName(name: string): Nullable<Animation>;
  85409. /**
  85410. * Creates an animation range for this node
  85411. * @param name defines the name of the range
  85412. * @param from defines the starting key
  85413. * @param to defines the end key
  85414. */
  85415. createAnimationRange(name: string, from: number, to: number): void;
  85416. /**
  85417. * Delete a specific animation range
  85418. * @param name defines the name of the range to delete
  85419. * @param deleteFrames defines if animation frames from the range must be deleted as well
  85420. */
  85421. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  85422. /**
  85423. * Get an animation range by name
  85424. * @param name defines the name of the animation range to look for
  85425. * @returns null if not found else the requested animation range
  85426. */
  85427. getAnimationRange(name: string): Nullable<AnimationRange>;
  85428. /**
  85429. * Gets the list of all animation ranges defined on this node
  85430. * @returns an array
  85431. */
  85432. getAnimationRanges(): Nullable<AnimationRange>[];
  85433. /**
  85434. * Will start the animation sequence
  85435. * @param name defines the range frames for animation sequence
  85436. * @param loop defines if the animation should loop (false by default)
  85437. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  85438. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  85439. * @returns the object created for this animation. If range does not exist, it will return null
  85440. */
  85441. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  85442. /**
  85443. * Serialize animation ranges into a JSON compatible object
  85444. * @returns serialization object
  85445. */
  85446. serializeAnimationRanges(): any;
  85447. /**
  85448. * Computes the world matrix of the node
  85449. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  85450. * @returns the world matrix
  85451. */
  85452. computeWorldMatrix(force?: boolean): Matrix;
  85453. /**
  85454. * Releases resources associated with this node.
  85455. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  85456. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  85457. */
  85458. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  85459. /**
  85460. * Parse animation range data from a serialization object and store them into a given node
  85461. * @param node defines where to store the animation ranges
  85462. * @param parsedNode defines the serialization object to read data from
  85463. * @param scene defines the hosting scene
  85464. */
  85465. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  85466. /**
  85467. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  85468. * @param includeDescendants Include bounding info from descendants as well (true by default)
  85469. * @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
  85470. * @returns the new bounding vectors
  85471. */
  85472. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  85473. min: Vector3;
  85474. max: Vector3;
  85475. };
  85476. }
  85477. }
  85478. declare module BABYLON {
  85479. /**
  85480. * @hidden
  85481. */
  85482. export class _IAnimationState {
  85483. key: number;
  85484. repeatCount: number;
  85485. workValue?: any;
  85486. loopMode?: number;
  85487. offsetValue?: any;
  85488. highLimitValue?: any;
  85489. }
  85490. /**
  85491. * Class used to store any kind of animation
  85492. */
  85493. export class Animation {
  85494. /**Name of the animation */
  85495. name: string;
  85496. /**Property to animate */
  85497. targetProperty: string;
  85498. /**The frames per second of the animation */
  85499. framePerSecond: number;
  85500. /**The data type of the animation */
  85501. dataType: number;
  85502. /**The loop mode of the animation */
  85503. loopMode?: number | undefined;
  85504. /**Specifies if blending should be enabled */
  85505. enableBlending?: boolean | undefined;
  85506. /**
  85507. * Use matrix interpolation instead of using direct key value when animating matrices
  85508. */
  85509. static AllowMatricesInterpolation: boolean;
  85510. /**
  85511. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  85512. */
  85513. static AllowMatrixDecomposeForInterpolation: boolean;
  85514. /**
  85515. * Stores the key frames of the animation
  85516. */
  85517. private _keys;
  85518. /**
  85519. * Stores the easing function of the animation
  85520. */
  85521. private _easingFunction;
  85522. /**
  85523. * @hidden Internal use only
  85524. */
  85525. _runtimeAnimations: RuntimeAnimation[];
  85526. /**
  85527. * The set of event that will be linked to this animation
  85528. */
  85529. private _events;
  85530. /**
  85531. * Stores an array of target property paths
  85532. */
  85533. targetPropertyPath: string[];
  85534. /**
  85535. * Stores the blending speed of the animation
  85536. */
  85537. blendingSpeed: number;
  85538. /**
  85539. * Stores the animation ranges for the animation
  85540. */
  85541. private _ranges;
  85542. /**
  85543. * @hidden Internal use
  85544. */
  85545. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  85546. /**
  85547. * Sets up an animation
  85548. * @param property The property to animate
  85549. * @param animationType The animation type to apply
  85550. * @param framePerSecond The frames per second of the animation
  85551. * @param easingFunction The easing function used in the animation
  85552. * @returns The created animation
  85553. */
  85554. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  85555. /**
  85556. * Create and start an animation on a node
  85557. * @param name defines the name of the global animation that will be run on all nodes
  85558. * @param node defines the root node where the animation will take place
  85559. * @param targetProperty defines property to animate
  85560. * @param framePerSecond defines the number of frame per second yo use
  85561. * @param totalFrame defines the number of frames in total
  85562. * @param from defines the initial value
  85563. * @param to defines the final value
  85564. * @param loopMode defines which loop mode you want to use (off by default)
  85565. * @param easingFunction defines the easing function to use (linear by default)
  85566. * @param onAnimationEnd defines the callback to call when animation end
  85567. * @returns the animatable created for this animation
  85568. */
  85569. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  85570. /**
  85571. * Create and start an animation on a node and its descendants
  85572. * @param name defines the name of the global animation that will be run on all nodes
  85573. * @param node defines the root node where the animation will take place
  85574. * @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
  85575. * @param targetProperty defines property to animate
  85576. * @param framePerSecond defines the number of frame per second to use
  85577. * @param totalFrame defines the number of frames in total
  85578. * @param from defines the initial value
  85579. * @param to defines the final value
  85580. * @param loopMode defines which loop mode you want to use (off by default)
  85581. * @param easingFunction defines the easing function to use (linear by default)
  85582. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  85583. * @returns the list of animatables created for all nodes
  85584. * @example https://www.babylonjs-playground.com/#MH0VLI
  85585. */
  85586. 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[]>;
  85587. /**
  85588. * Creates a new animation, merges it with the existing animations and starts it
  85589. * @param name Name of the animation
  85590. * @param node Node which contains the scene that begins the animations
  85591. * @param targetProperty Specifies which property to animate
  85592. * @param framePerSecond The frames per second of the animation
  85593. * @param totalFrame The total number of frames
  85594. * @param from The frame at the beginning of the animation
  85595. * @param to The frame at the end of the animation
  85596. * @param loopMode Specifies the loop mode of the animation
  85597. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  85598. * @param onAnimationEnd Callback to run once the animation is complete
  85599. * @returns Nullable animation
  85600. */
  85601. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  85602. /**
  85603. * Transition property of an host to the target Value
  85604. * @param property The property to transition
  85605. * @param targetValue The target Value of the property
  85606. * @param host The object where the property to animate belongs
  85607. * @param scene Scene used to run the animation
  85608. * @param frameRate Framerate (in frame/s) to use
  85609. * @param transition The transition type we want to use
  85610. * @param duration The duration of the animation, in milliseconds
  85611. * @param onAnimationEnd Callback trigger at the end of the animation
  85612. * @returns Nullable animation
  85613. */
  85614. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  85615. /**
  85616. * Return the array of runtime animations currently using this animation
  85617. */
  85618. readonly runtimeAnimations: RuntimeAnimation[];
  85619. /**
  85620. * Specifies if any of the runtime animations are currently running
  85621. */
  85622. readonly hasRunningRuntimeAnimations: boolean;
  85623. /**
  85624. * Initializes the animation
  85625. * @param name Name of the animation
  85626. * @param targetProperty Property to animate
  85627. * @param framePerSecond The frames per second of the animation
  85628. * @param dataType The data type of the animation
  85629. * @param loopMode The loop mode of the animation
  85630. * @param enableBlending Specifies if blending should be enabled
  85631. */
  85632. constructor(
  85633. /**Name of the animation */
  85634. name: string,
  85635. /**Property to animate */
  85636. targetProperty: string,
  85637. /**The frames per second of the animation */
  85638. framePerSecond: number,
  85639. /**The data type of the animation */
  85640. dataType: number,
  85641. /**The loop mode of the animation */
  85642. loopMode?: number | undefined,
  85643. /**Specifies if blending should be enabled */
  85644. enableBlending?: boolean | undefined);
  85645. /**
  85646. * Converts the animation to a string
  85647. * @param fullDetails support for multiple levels of logging within scene loading
  85648. * @returns String form of the animation
  85649. */
  85650. toString(fullDetails?: boolean): string;
  85651. /**
  85652. * Add an event to this animation
  85653. * @param event Event to add
  85654. */
  85655. addEvent(event: AnimationEvent): void;
  85656. /**
  85657. * Remove all events found at the given frame
  85658. * @param frame The frame to remove events from
  85659. */
  85660. removeEvents(frame: number): void;
  85661. /**
  85662. * Retrieves all the events from the animation
  85663. * @returns Events from the animation
  85664. */
  85665. getEvents(): AnimationEvent[];
  85666. /**
  85667. * Creates an animation range
  85668. * @param name Name of the animation range
  85669. * @param from Starting frame of the animation range
  85670. * @param to Ending frame of the animation
  85671. */
  85672. createRange(name: string, from: number, to: number): void;
  85673. /**
  85674. * Deletes an animation range by name
  85675. * @param name Name of the animation range to delete
  85676. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  85677. */
  85678. deleteRange(name: string, deleteFrames?: boolean): void;
  85679. /**
  85680. * Gets the animation range by name, or null if not defined
  85681. * @param name Name of the animation range
  85682. * @returns Nullable animation range
  85683. */
  85684. getRange(name: string): Nullable<AnimationRange>;
  85685. /**
  85686. * Gets the key frames from the animation
  85687. * @returns The key frames of the animation
  85688. */
  85689. getKeys(): Array<IAnimationKey>;
  85690. /**
  85691. * Gets the highest frame rate of the animation
  85692. * @returns Highest frame rate of the animation
  85693. */
  85694. getHighestFrame(): number;
  85695. /**
  85696. * Gets the easing function of the animation
  85697. * @returns Easing function of the animation
  85698. */
  85699. getEasingFunction(): IEasingFunction;
  85700. /**
  85701. * Sets the easing function of the animation
  85702. * @param easingFunction A custom mathematical formula for animation
  85703. */
  85704. setEasingFunction(easingFunction: EasingFunction): void;
  85705. /**
  85706. * Interpolates a scalar linearly
  85707. * @param startValue Start value of the animation curve
  85708. * @param endValue End value of the animation curve
  85709. * @param gradient Scalar amount to interpolate
  85710. * @returns Interpolated scalar value
  85711. */
  85712. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  85713. /**
  85714. * Interpolates a scalar cubically
  85715. * @param startValue Start value of the animation curve
  85716. * @param outTangent End tangent of the animation
  85717. * @param endValue End value of the animation curve
  85718. * @param inTangent Start tangent of the animation curve
  85719. * @param gradient Scalar amount to interpolate
  85720. * @returns Interpolated scalar value
  85721. */
  85722. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  85723. /**
  85724. * Interpolates a quaternion using a spherical linear interpolation
  85725. * @param startValue Start value of the animation curve
  85726. * @param endValue End value of the animation curve
  85727. * @param gradient Scalar amount to interpolate
  85728. * @returns Interpolated quaternion value
  85729. */
  85730. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  85731. /**
  85732. * Interpolates a quaternion cubically
  85733. * @param startValue Start value of the animation curve
  85734. * @param outTangent End tangent of the animation curve
  85735. * @param endValue End value of the animation curve
  85736. * @param inTangent Start tangent of the animation curve
  85737. * @param gradient Scalar amount to interpolate
  85738. * @returns Interpolated quaternion value
  85739. */
  85740. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  85741. /**
  85742. * Interpolates a Vector3 linearl
  85743. * @param startValue Start value of the animation curve
  85744. * @param endValue End value of the animation curve
  85745. * @param gradient Scalar amount to interpolate
  85746. * @returns Interpolated scalar value
  85747. */
  85748. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  85749. /**
  85750. * Interpolates a Vector3 cubically
  85751. * @param startValue Start value of the animation curve
  85752. * @param outTangent End tangent of the animation
  85753. * @param endValue End value of the animation curve
  85754. * @param inTangent Start tangent of the animation curve
  85755. * @param gradient Scalar amount to interpolate
  85756. * @returns InterpolatedVector3 value
  85757. */
  85758. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  85759. /**
  85760. * Interpolates a Vector2 linearly
  85761. * @param startValue Start value of the animation curve
  85762. * @param endValue End value of the animation curve
  85763. * @param gradient Scalar amount to interpolate
  85764. * @returns Interpolated Vector2 value
  85765. */
  85766. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  85767. /**
  85768. * Interpolates a Vector2 cubically
  85769. * @param startValue Start value of the animation curve
  85770. * @param outTangent End tangent of the animation
  85771. * @param endValue End value of the animation curve
  85772. * @param inTangent Start tangent of the animation curve
  85773. * @param gradient Scalar amount to interpolate
  85774. * @returns Interpolated Vector2 value
  85775. */
  85776. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  85777. /**
  85778. * Interpolates a size linearly
  85779. * @param startValue Start value of the animation curve
  85780. * @param endValue End value of the animation curve
  85781. * @param gradient Scalar amount to interpolate
  85782. * @returns Interpolated Size value
  85783. */
  85784. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  85785. /**
  85786. * Interpolates a Color3 linearly
  85787. * @param startValue Start value of the animation curve
  85788. * @param endValue End value of the animation curve
  85789. * @param gradient Scalar amount to interpolate
  85790. * @returns Interpolated Color3 value
  85791. */
  85792. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  85793. /**
  85794. * @hidden Internal use only
  85795. */
  85796. _getKeyValue(value: any): any;
  85797. /**
  85798. * @hidden Internal use only
  85799. */
  85800. _interpolate(currentFrame: number, state: _IAnimationState): any;
  85801. /**
  85802. * Defines the function to use to interpolate matrices
  85803. * @param startValue defines the start matrix
  85804. * @param endValue defines the end matrix
  85805. * @param gradient defines the gradient between both matrices
  85806. * @param result defines an optional target matrix where to store the interpolation
  85807. * @returns the interpolated matrix
  85808. */
  85809. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  85810. /**
  85811. * Makes a copy of the animation
  85812. * @returns Cloned animation
  85813. */
  85814. clone(): Animation;
  85815. /**
  85816. * Sets the key frames of the animation
  85817. * @param values The animation key frames to set
  85818. */
  85819. setKeys(values: Array<IAnimationKey>): void;
  85820. /**
  85821. * Serializes the animation to an object
  85822. * @returns Serialized object
  85823. */
  85824. serialize(): any;
  85825. /**
  85826. * Float animation type
  85827. */
  85828. private static _ANIMATIONTYPE_FLOAT;
  85829. /**
  85830. * Vector3 animation type
  85831. */
  85832. private static _ANIMATIONTYPE_VECTOR3;
  85833. /**
  85834. * Quaternion animation type
  85835. */
  85836. private static _ANIMATIONTYPE_QUATERNION;
  85837. /**
  85838. * Matrix animation type
  85839. */
  85840. private static _ANIMATIONTYPE_MATRIX;
  85841. /**
  85842. * Color3 animation type
  85843. */
  85844. private static _ANIMATIONTYPE_COLOR3;
  85845. /**
  85846. * Vector2 animation type
  85847. */
  85848. private static _ANIMATIONTYPE_VECTOR2;
  85849. /**
  85850. * Size animation type
  85851. */
  85852. private static _ANIMATIONTYPE_SIZE;
  85853. /**
  85854. * Relative Loop Mode
  85855. */
  85856. private static _ANIMATIONLOOPMODE_RELATIVE;
  85857. /**
  85858. * Cycle Loop Mode
  85859. */
  85860. private static _ANIMATIONLOOPMODE_CYCLE;
  85861. /**
  85862. * Constant Loop Mode
  85863. */
  85864. private static _ANIMATIONLOOPMODE_CONSTANT;
  85865. /**
  85866. * Get the float animation type
  85867. */
  85868. static readonly ANIMATIONTYPE_FLOAT: number;
  85869. /**
  85870. * Get the Vector3 animation type
  85871. */
  85872. static readonly ANIMATIONTYPE_VECTOR3: number;
  85873. /**
  85874. * Get the Vector2 animation type
  85875. */
  85876. static readonly ANIMATIONTYPE_VECTOR2: number;
  85877. /**
  85878. * Get the Size animation type
  85879. */
  85880. static readonly ANIMATIONTYPE_SIZE: number;
  85881. /**
  85882. * Get the Quaternion animation type
  85883. */
  85884. static readonly ANIMATIONTYPE_QUATERNION: number;
  85885. /**
  85886. * Get the Matrix animation type
  85887. */
  85888. static readonly ANIMATIONTYPE_MATRIX: number;
  85889. /**
  85890. * Get the Color3 animation type
  85891. */
  85892. static readonly ANIMATIONTYPE_COLOR3: number;
  85893. /**
  85894. * Get the Relative Loop Mode
  85895. */
  85896. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  85897. /**
  85898. * Get the Cycle Loop Mode
  85899. */
  85900. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  85901. /**
  85902. * Get the Constant Loop Mode
  85903. */
  85904. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  85905. /** @hidden */
  85906. static _UniversalLerp(left: any, right: any, amount: number): any;
  85907. /**
  85908. * Parses an animation object and creates an animation
  85909. * @param parsedAnimation Parsed animation object
  85910. * @returns Animation object
  85911. */
  85912. static Parse(parsedAnimation: any): Animation;
  85913. /**
  85914. * Appends the serialized animations from the source animations
  85915. * @param source Source containing the animations
  85916. * @param destination Target to store the animations
  85917. */
  85918. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  85919. }
  85920. }
  85921. declare module BABYLON {
  85922. /**
  85923. * Base class of all the textures in babylon.
  85924. * It groups all the common properties the materials, post process, lights... might need
  85925. * in order to make a correct use of the texture.
  85926. */
  85927. export class BaseTexture implements IAnimatable {
  85928. /**
  85929. * Default anisotropic filtering level for the application.
  85930. * It is set to 4 as a good tradeoff between perf and quality.
  85931. */
  85932. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  85933. /**
  85934. * Gets or sets the unique id of the texture
  85935. */
  85936. uniqueId: number;
  85937. /**
  85938. * Define the name of the texture.
  85939. */
  85940. name: string;
  85941. /**
  85942. * Gets or sets an object used to store user defined information.
  85943. */
  85944. metadata: any;
  85945. /**
  85946. * For internal use only. Please do not use.
  85947. */
  85948. reservedDataStore: any;
  85949. private _hasAlpha;
  85950. /**
  85951. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  85952. */
  85953. hasAlpha: boolean;
  85954. /**
  85955. * Defines if the alpha value should be determined via the rgb values.
  85956. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  85957. */
  85958. getAlphaFromRGB: boolean;
  85959. /**
  85960. * Intensity or strength of the texture.
  85961. * It is commonly used by materials to fine tune the intensity of the texture
  85962. */
  85963. level: number;
  85964. /**
  85965. * Define the UV chanel to use starting from 0 and defaulting to 0.
  85966. * This is part of the texture as textures usually maps to one uv set.
  85967. */
  85968. coordinatesIndex: number;
  85969. private _coordinatesMode;
  85970. /**
  85971. * How a texture is mapped.
  85972. *
  85973. * | Value | Type | Description |
  85974. * | ----- | ----------------------------------- | ----------- |
  85975. * | 0 | EXPLICIT_MODE | |
  85976. * | 1 | SPHERICAL_MODE | |
  85977. * | 2 | PLANAR_MODE | |
  85978. * | 3 | CUBIC_MODE | |
  85979. * | 4 | PROJECTION_MODE | |
  85980. * | 5 | SKYBOX_MODE | |
  85981. * | 6 | INVCUBIC_MODE | |
  85982. * | 7 | EQUIRECTANGULAR_MODE | |
  85983. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  85984. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  85985. */
  85986. coordinatesMode: number;
  85987. /**
  85988. * | Value | Type | Description |
  85989. * | ----- | ------------------ | ----------- |
  85990. * | 0 | CLAMP_ADDRESSMODE | |
  85991. * | 1 | WRAP_ADDRESSMODE | |
  85992. * | 2 | MIRROR_ADDRESSMODE | |
  85993. */
  85994. wrapU: number;
  85995. /**
  85996. * | Value | Type | Description |
  85997. * | ----- | ------------------ | ----------- |
  85998. * | 0 | CLAMP_ADDRESSMODE | |
  85999. * | 1 | WRAP_ADDRESSMODE | |
  86000. * | 2 | MIRROR_ADDRESSMODE | |
  86001. */
  86002. wrapV: number;
  86003. /**
  86004. * | Value | Type | Description |
  86005. * | ----- | ------------------ | ----------- |
  86006. * | 0 | CLAMP_ADDRESSMODE | |
  86007. * | 1 | WRAP_ADDRESSMODE | |
  86008. * | 2 | MIRROR_ADDRESSMODE | |
  86009. */
  86010. wrapR: number;
  86011. /**
  86012. * With compliant hardware and browser (supporting anisotropic filtering)
  86013. * this defines the level of anisotropic filtering in the texture.
  86014. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  86015. */
  86016. anisotropicFilteringLevel: number;
  86017. /**
  86018. * Define if the texture is a cube texture or if false a 2d texture.
  86019. */
  86020. isCube: boolean;
  86021. /**
  86022. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  86023. */
  86024. is3D: boolean;
  86025. /**
  86026. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  86027. * HDR texture are usually stored in linear space.
  86028. * This only impacts the PBR and Background materials
  86029. */
  86030. gammaSpace: boolean;
  86031. /**
  86032. * Gets whether or not the texture contains RGBD data.
  86033. */
  86034. readonly isRGBD: boolean;
  86035. /**
  86036. * Is Z inverted in the texture (useful in a cube texture).
  86037. */
  86038. invertZ: boolean;
  86039. /**
  86040. * Are mip maps generated for this texture or not.
  86041. */
  86042. readonly noMipmap: boolean;
  86043. /**
  86044. * @hidden
  86045. */
  86046. lodLevelInAlpha: boolean;
  86047. /**
  86048. * With prefiltered texture, defined the offset used during the prefiltering steps.
  86049. */
  86050. lodGenerationOffset: number;
  86051. /**
  86052. * With prefiltered texture, defined the scale used during the prefiltering steps.
  86053. */
  86054. lodGenerationScale: number;
  86055. /**
  86056. * Define if the texture is a render target.
  86057. */
  86058. isRenderTarget: boolean;
  86059. /**
  86060. * Define the unique id of the texture in the scene.
  86061. */
  86062. readonly uid: string;
  86063. /**
  86064. * Return a string representation of the texture.
  86065. * @returns the texture as a string
  86066. */
  86067. toString(): string;
  86068. /**
  86069. * Get the class name of the texture.
  86070. * @returns "BaseTexture"
  86071. */
  86072. getClassName(): string;
  86073. /**
  86074. * Define the list of animation attached to the texture.
  86075. */
  86076. animations: Animation[];
  86077. /**
  86078. * An event triggered when the texture is disposed.
  86079. */
  86080. onDisposeObservable: Observable<BaseTexture>;
  86081. private _onDisposeObserver;
  86082. /**
  86083. * Callback triggered when the texture has been disposed.
  86084. * Kept for back compatibility, you can use the onDisposeObservable instead.
  86085. */
  86086. onDispose: () => void;
  86087. /**
  86088. * Define the current state of the loading sequence when in delayed load mode.
  86089. */
  86090. delayLoadState: number;
  86091. private _scene;
  86092. /** @hidden */
  86093. _texture: Nullable<InternalTexture>;
  86094. private _uid;
  86095. /**
  86096. * Define if the texture is preventinga material to render or not.
  86097. * If not and the texture is not ready, the engine will use a default black texture instead.
  86098. */
  86099. readonly isBlocking: boolean;
  86100. /**
  86101. * Instantiates a new BaseTexture.
  86102. * Base class of all the textures in babylon.
  86103. * It groups all the common properties the materials, post process, lights... might need
  86104. * in order to make a correct use of the texture.
  86105. * @param scene Define the scene the texture blongs to
  86106. */
  86107. constructor(scene: Nullable<Scene>);
  86108. /**
  86109. * Get the scene the texture belongs to.
  86110. * @returns the scene or null if undefined
  86111. */
  86112. getScene(): Nullable<Scene>;
  86113. /**
  86114. * Get the texture transform matrix used to offset tile the texture for istance.
  86115. * @returns the transformation matrix
  86116. */
  86117. getTextureMatrix(): Matrix;
  86118. /**
  86119. * Get the texture reflection matrix used to rotate/transform the reflection.
  86120. * @returns the reflection matrix
  86121. */
  86122. getReflectionTextureMatrix(): Matrix;
  86123. /**
  86124. * Get the underlying lower level texture from Babylon.
  86125. * @returns the insternal texture
  86126. */
  86127. getInternalTexture(): Nullable<InternalTexture>;
  86128. /**
  86129. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  86130. * @returns true if ready or not blocking
  86131. */
  86132. isReadyOrNotBlocking(): boolean;
  86133. /**
  86134. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  86135. * @returns true if fully ready
  86136. */
  86137. isReady(): boolean;
  86138. private _cachedSize;
  86139. /**
  86140. * Get the size of the texture.
  86141. * @returns the texture size.
  86142. */
  86143. getSize(): ISize;
  86144. /**
  86145. * Get the base size of the texture.
  86146. * It can be different from the size if the texture has been resized for POT for instance
  86147. * @returns the base size
  86148. */
  86149. getBaseSize(): ISize;
  86150. /**
  86151. * Update the sampling mode of the texture.
  86152. * Default is Trilinear mode.
  86153. *
  86154. * | Value | Type | Description |
  86155. * | ----- | ------------------ | ----------- |
  86156. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  86157. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  86158. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  86159. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  86160. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  86161. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  86162. * | 7 | NEAREST_LINEAR | |
  86163. * | 8 | NEAREST_NEAREST | |
  86164. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  86165. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  86166. * | 11 | LINEAR_LINEAR | |
  86167. * | 12 | LINEAR_NEAREST | |
  86168. *
  86169. * > _mag_: magnification filter (close to the viewer)
  86170. * > _min_: minification filter (far from the viewer)
  86171. * > _mip_: filter used between mip map levels
  86172. *@param samplingMode Define the new sampling mode of the texture
  86173. */
  86174. updateSamplingMode(samplingMode: number): void;
  86175. /**
  86176. * Scales the texture if is `canRescale()`
  86177. * @param ratio the resize factor we want to use to rescale
  86178. */
  86179. scale(ratio: number): void;
  86180. /**
  86181. * Get if the texture can rescale.
  86182. */
  86183. readonly canRescale: boolean;
  86184. /** @hidden */
  86185. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  86186. /** @hidden */
  86187. _rebuild(): void;
  86188. /**
  86189. * Triggers the load sequence in delayed load mode.
  86190. */
  86191. delayLoad(): void;
  86192. /**
  86193. * Clones the texture.
  86194. * @returns the cloned texture
  86195. */
  86196. clone(): Nullable<BaseTexture>;
  86197. /**
  86198. * Get the texture underlying type (INT, FLOAT...)
  86199. */
  86200. readonly textureType: number;
  86201. /**
  86202. * Get the texture underlying format (RGB, RGBA...)
  86203. */
  86204. readonly textureFormat: number;
  86205. /**
  86206. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  86207. * This will returns an RGBA array buffer containing either in values (0-255) or
  86208. * float values (0-1) depending of the underlying buffer type.
  86209. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  86210. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  86211. * @param buffer defines a user defined buffer to fill with data (can be null)
  86212. * @returns The Array buffer containing the pixels data.
  86213. */
  86214. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  86215. /**
  86216. * Release and destroy the underlying lower level texture aka internalTexture.
  86217. */
  86218. releaseInternalTexture(): void;
  86219. /**
  86220. * Get the polynomial representation of the texture data.
  86221. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  86222. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  86223. */
  86224. sphericalPolynomial: Nullable<SphericalPolynomial>;
  86225. /** @hidden */
  86226. readonly _lodTextureHigh: Nullable<BaseTexture>;
  86227. /** @hidden */
  86228. readonly _lodTextureMid: Nullable<BaseTexture>;
  86229. /** @hidden */
  86230. readonly _lodTextureLow: Nullable<BaseTexture>;
  86231. /**
  86232. * Dispose the texture and release its associated resources.
  86233. */
  86234. dispose(): void;
  86235. /**
  86236. * Serialize the texture into a JSON representation that can be parsed later on.
  86237. * @returns the JSON representation of the texture
  86238. */
  86239. serialize(): any;
  86240. /**
  86241. * Helper function to be called back once a list of texture contains only ready textures.
  86242. * @param textures Define the list of textures to wait for
  86243. * @param callback Define the callback triggered once the entire list will be ready
  86244. */
  86245. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  86246. }
  86247. }
  86248. declare module BABYLON {
  86249. /**
  86250. * Uniform buffer objects.
  86251. *
  86252. * Handles blocks of uniform on the GPU.
  86253. *
  86254. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  86255. *
  86256. * For more information, please refer to :
  86257. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  86258. */
  86259. export class UniformBuffer {
  86260. private _engine;
  86261. private _buffer;
  86262. private _data;
  86263. private _bufferData;
  86264. private _dynamic?;
  86265. private _uniformLocations;
  86266. private _uniformSizes;
  86267. private _uniformLocationPointer;
  86268. private _needSync;
  86269. private _noUBO;
  86270. private _currentEffect;
  86271. private static _MAX_UNIFORM_SIZE;
  86272. private static _tempBuffer;
  86273. /**
  86274. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  86275. * This is dynamic to allow compat with webgl 1 and 2.
  86276. * You will need to pass the name of the uniform as well as the value.
  86277. */
  86278. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  86279. /**
  86280. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  86281. * This is dynamic to allow compat with webgl 1 and 2.
  86282. * You will need to pass the name of the uniform as well as the value.
  86283. */
  86284. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  86285. /**
  86286. * Lambda to Update a single float in a uniform buffer.
  86287. * This is dynamic to allow compat with webgl 1 and 2.
  86288. * You will need to pass the name of the uniform as well as the value.
  86289. */
  86290. updateFloat: (name: string, x: number) => void;
  86291. /**
  86292. * Lambda to Update a vec2 of float in a uniform buffer.
  86293. * This is dynamic to allow compat with webgl 1 and 2.
  86294. * You will need to pass the name of the uniform as well as the value.
  86295. */
  86296. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  86297. /**
  86298. * Lambda to Update a vec3 of float in a uniform buffer.
  86299. * This is dynamic to allow compat with webgl 1 and 2.
  86300. * You will need to pass the name of the uniform as well as the value.
  86301. */
  86302. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  86303. /**
  86304. * Lambda to Update a vec4 of float in a uniform buffer.
  86305. * This is dynamic to allow compat with webgl 1 and 2.
  86306. * You will need to pass the name of the uniform as well as the value.
  86307. */
  86308. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  86309. /**
  86310. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  86311. * This is dynamic to allow compat with webgl 1 and 2.
  86312. * You will need to pass the name of the uniform as well as the value.
  86313. */
  86314. updateMatrix: (name: string, mat: Matrix) => void;
  86315. /**
  86316. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  86317. * This is dynamic to allow compat with webgl 1 and 2.
  86318. * You will need to pass the name of the uniform as well as the value.
  86319. */
  86320. updateVector3: (name: string, vector: Vector3) => void;
  86321. /**
  86322. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  86323. * This is dynamic to allow compat with webgl 1 and 2.
  86324. * You will need to pass the name of the uniform as well as the value.
  86325. */
  86326. updateVector4: (name: string, vector: Vector4) => void;
  86327. /**
  86328. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  86329. * This is dynamic to allow compat with webgl 1 and 2.
  86330. * You will need to pass the name of the uniform as well as the value.
  86331. */
  86332. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  86333. /**
  86334. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  86335. * This is dynamic to allow compat with webgl 1 and 2.
  86336. * You will need to pass the name of the uniform as well as the value.
  86337. */
  86338. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  86339. /**
  86340. * Instantiates a new Uniform buffer objects.
  86341. *
  86342. * Handles blocks of uniform on the GPU.
  86343. *
  86344. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  86345. *
  86346. * For more information, please refer to :
  86347. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  86348. * @param engine Define the engine the buffer is associated with
  86349. * @param data Define the data contained in the buffer
  86350. * @param dynamic Define if the buffer is updatable
  86351. */
  86352. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  86353. /**
  86354. * Indicates if the buffer is using the WebGL2 UBO implementation,
  86355. * or just falling back on setUniformXXX calls.
  86356. */
  86357. readonly useUbo: boolean;
  86358. /**
  86359. * Indicates if the WebGL underlying uniform buffer is in sync
  86360. * with the javascript cache data.
  86361. */
  86362. readonly isSync: boolean;
  86363. /**
  86364. * Indicates if the WebGL underlying uniform buffer is dynamic.
  86365. * Also, a dynamic UniformBuffer will disable cache verification and always
  86366. * update the underlying WebGL uniform buffer to the GPU.
  86367. * @returns if Dynamic, otherwise false
  86368. */
  86369. isDynamic(): boolean;
  86370. /**
  86371. * The data cache on JS side.
  86372. * @returns the underlying data as a float array
  86373. */
  86374. getData(): Float32Array;
  86375. /**
  86376. * The underlying WebGL Uniform buffer.
  86377. * @returns the webgl buffer
  86378. */
  86379. getBuffer(): Nullable<DataBuffer>;
  86380. /**
  86381. * std140 layout specifies how to align data within an UBO structure.
  86382. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  86383. * for specs.
  86384. */
  86385. private _fillAlignment;
  86386. /**
  86387. * Adds an uniform in the buffer.
  86388. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  86389. * for the layout to be correct !
  86390. * @param name Name of the uniform, as used in the uniform block in the shader.
  86391. * @param size Data size, or data directly.
  86392. */
  86393. addUniform(name: string, size: number | number[]): void;
  86394. /**
  86395. * Adds a Matrix 4x4 to the uniform buffer.
  86396. * @param name Name of the uniform, as used in the uniform block in the shader.
  86397. * @param mat A 4x4 matrix.
  86398. */
  86399. addMatrix(name: string, mat: Matrix): void;
  86400. /**
  86401. * Adds a vec2 to the uniform buffer.
  86402. * @param name Name of the uniform, as used in the uniform block in the shader.
  86403. * @param x Define the x component value of the vec2
  86404. * @param y Define the y component value of the vec2
  86405. */
  86406. addFloat2(name: string, x: number, y: number): void;
  86407. /**
  86408. * Adds a vec3 to the uniform buffer.
  86409. * @param name Name of the uniform, as used in the uniform block in the shader.
  86410. * @param x Define the x component value of the vec3
  86411. * @param y Define the y component value of the vec3
  86412. * @param z Define the z component value of the vec3
  86413. */
  86414. addFloat3(name: string, x: number, y: number, z: number): void;
  86415. /**
  86416. * Adds a vec3 to the uniform buffer.
  86417. * @param name Name of the uniform, as used in the uniform block in the shader.
  86418. * @param color Define the vec3 from a Color
  86419. */
  86420. addColor3(name: string, color: Color3): void;
  86421. /**
  86422. * Adds a vec4 to the uniform buffer.
  86423. * @param name Name of the uniform, as used in the uniform block in the shader.
  86424. * @param color Define the rgb components from a Color
  86425. * @param alpha Define the a component of the vec4
  86426. */
  86427. addColor4(name: string, color: Color3, alpha: number): void;
  86428. /**
  86429. * Adds a vec3 to the uniform buffer.
  86430. * @param name Name of the uniform, as used in the uniform block in the shader.
  86431. * @param vector Define the vec3 components from a Vector
  86432. */
  86433. addVector3(name: string, vector: Vector3): void;
  86434. /**
  86435. * Adds a Matrix 3x3 to the uniform buffer.
  86436. * @param name Name of the uniform, as used in the uniform block in the shader.
  86437. */
  86438. addMatrix3x3(name: string): void;
  86439. /**
  86440. * Adds a Matrix 2x2 to the uniform buffer.
  86441. * @param name Name of the uniform, as used in the uniform block in the shader.
  86442. */
  86443. addMatrix2x2(name: string): void;
  86444. /**
  86445. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  86446. */
  86447. create(): void;
  86448. /** @hidden */
  86449. _rebuild(): void;
  86450. /**
  86451. * Updates the WebGL Uniform Buffer on the GPU.
  86452. * If the `dynamic` flag is set to true, no cache comparison is done.
  86453. * Otherwise, the buffer will be updated only if the cache differs.
  86454. */
  86455. update(): void;
  86456. /**
  86457. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  86458. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  86459. * @param data Define the flattened data
  86460. * @param size Define the size of the data.
  86461. */
  86462. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  86463. private _updateMatrix3x3ForUniform;
  86464. private _updateMatrix3x3ForEffect;
  86465. private _updateMatrix2x2ForEffect;
  86466. private _updateMatrix2x2ForUniform;
  86467. private _updateFloatForEffect;
  86468. private _updateFloatForUniform;
  86469. private _updateFloat2ForEffect;
  86470. private _updateFloat2ForUniform;
  86471. private _updateFloat3ForEffect;
  86472. private _updateFloat3ForUniform;
  86473. private _updateFloat4ForEffect;
  86474. private _updateFloat4ForUniform;
  86475. private _updateMatrixForEffect;
  86476. private _updateMatrixForUniform;
  86477. private _updateVector3ForEffect;
  86478. private _updateVector3ForUniform;
  86479. private _updateVector4ForEffect;
  86480. private _updateVector4ForUniform;
  86481. private _updateColor3ForEffect;
  86482. private _updateColor3ForUniform;
  86483. private _updateColor4ForEffect;
  86484. private _updateColor4ForUniform;
  86485. /**
  86486. * Sets a sampler uniform on the effect.
  86487. * @param name Define the name of the sampler.
  86488. * @param texture Define the texture to set in the sampler
  86489. */
  86490. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  86491. /**
  86492. * Directly updates the value of the uniform in the cache AND on the GPU.
  86493. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  86494. * @param data Define the flattened data
  86495. */
  86496. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  86497. /**
  86498. * Binds this uniform buffer to an effect.
  86499. * @param effect Define the effect to bind the buffer to
  86500. * @param name Name of the uniform block in the shader.
  86501. */
  86502. bindToEffect(effect: Effect, name: string): void;
  86503. /**
  86504. * Disposes the uniform buffer.
  86505. */
  86506. dispose(): void;
  86507. }
  86508. }
  86509. declare module BABYLON {
  86510. /**
  86511. * Class used to work with sound analyzer using fast fourier transform (FFT)
  86512. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  86513. */
  86514. export class Analyser {
  86515. /**
  86516. * Gets or sets the smoothing
  86517. * @ignorenaming
  86518. */
  86519. SMOOTHING: number;
  86520. /**
  86521. * Gets or sets the FFT table size
  86522. * @ignorenaming
  86523. */
  86524. FFT_SIZE: number;
  86525. /**
  86526. * Gets or sets the bar graph amplitude
  86527. * @ignorenaming
  86528. */
  86529. BARGRAPHAMPLITUDE: number;
  86530. /**
  86531. * Gets or sets the position of the debug canvas
  86532. * @ignorenaming
  86533. */
  86534. DEBUGCANVASPOS: {
  86535. x: number;
  86536. y: number;
  86537. };
  86538. /**
  86539. * Gets or sets the debug canvas size
  86540. * @ignorenaming
  86541. */
  86542. DEBUGCANVASSIZE: {
  86543. width: number;
  86544. height: number;
  86545. };
  86546. private _byteFreqs;
  86547. private _byteTime;
  86548. private _floatFreqs;
  86549. private _webAudioAnalyser;
  86550. private _debugCanvas;
  86551. private _debugCanvasContext;
  86552. private _scene;
  86553. private _registerFunc;
  86554. private _audioEngine;
  86555. /**
  86556. * Creates a new analyser
  86557. * @param scene defines hosting scene
  86558. */
  86559. constructor(scene: Scene);
  86560. /**
  86561. * Get the number of data values you will have to play with for the visualization
  86562. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  86563. * @returns a number
  86564. */
  86565. getFrequencyBinCount(): number;
  86566. /**
  86567. * Gets the current frequency data as a byte array
  86568. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  86569. * @returns a Uint8Array
  86570. */
  86571. getByteFrequencyData(): Uint8Array;
  86572. /**
  86573. * Gets the current waveform as a byte array
  86574. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  86575. * @returns a Uint8Array
  86576. */
  86577. getByteTimeDomainData(): Uint8Array;
  86578. /**
  86579. * Gets the current frequency data as a float array
  86580. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  86581. * @returns a Float32Array
  86582. */
  86583. getFloatFrequencyData(): Float32Array;
  86584. /**
  86585. * Renders the debug canvas
  86586. */
  86587. drawDebugCanvas(): void;
  86588. /**
  86589. * Stops rendering the debug canvas and removes it
  86590. */
  86591. stopDebugCanvas(): void;
  86592. /**
  86593. * Connects two audio nodes
  86594. * @param inputAudioNode defines first node to connect
  86595. * @param outputAudioNode defines second node to connect
  86596. */
  86597. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  86598. /**
  86599. * Releases all associated resources
  86600. */
  86601. dispose(): void;
  86602. }
  86603. }
  86604. declare module BABYLON {
  86605. /**
  86606. * This represents an audio engine and it is responsible
  86607. * to play, synchronize and analyse sounds throughout the application.
  86608. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  86609. */
  86610. export interface IAudioEngine extends IDisposable {
  86611. /**
  86612. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  86613. */
  86614. readonly canUseWebAudio: boolean;
  86615. /**
  86616. * Gets the current AudioContext if available.
  86617. */
  86618. readonly audioContext: Nullable<AudioContext>;
  86619. /**
  86620. * The master gain node defines the global audio volume of your audio engine.
  86621. */
  86622. readonly masterGain: GainNode;
  86623. /**
  86624. * Gets whether or not mp3 are supported by your browser.
  86625. */
  86626. readonly isMP3supported: boolean;
  86627. /**
  86628. * Gets whether or not ogg are supported by your browser.
  86629. */
  86630. readonly isOGGsupported: boolean;
  86631. /**
  86632. * Defines if Babylon should emit a warning if WebAudio is not supported.
  86633. * @ignoreNaming
  86634. */
  86635. WarnedWebAudioUnsupported: boolean;
  86636. /**
  86637. * Defines if the audio engine relies on a custom unlocked button.
  86638. * In this case, the embedded button will not be displayed.
  86639. */
  86640. useCustomUnlockedButton: boolean;
  86641. /**
  86642. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  86643. */
  86644. readonly unlocked: boolean;
  86645. /**
  86646. * Event raised when audio has been unlocked on the browser.
  86647. */
  86648. onAudioUnlockedObservable: Observable<AudioEngine>;
  86649. /**
  86650. * Event raised when audio has been locked on the browser.
  86651. */
  86652. onAudioLockedObservable: Observable<AudioEngine>;
  86653. /**
  86654. * Flags the audio engine in Locked state.
  86655. * This happens due to new browser policies preventing audio to autoplay.
  86656. */
  86657. lock(): void;
  86658. /**
  86659. * Unlocks the audio engine once a user action has been done on the dom.
  86660. * This is helpful to resume play once browser policies have been satisfied.
  86661. */
  86662. unlock(): void;
  86663. }
  86664. /**
  86665. * This represents the default audio engine used in babylon.
  86666. * It is responsible to play, synchronize and analyse sounds throughout the application.
  86667. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  86668. */
  86669. export class AudioEngine implements IAudioEngine {
  86670. private _audioContext;
  86671. private _audioContextInitialized;
  86672. private _muteButton;
  86673. private _hostElement;
  86674. /**
  86675. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  86676. */
  86677. canUseWebAudio: boolean;
  86678. /**
  86679. * The master gain node defines the global audio volume of your audio engine.
  86680. */
  86681. masterGain: GainNode;
  86682. /**
  86683. * Defines if Babylon should emit a warning if WebAudio is not supported.
  86684. * @ignoreNaming
  86685. */
  86686. WarnedWebAudioUnsupported: boolean;
  86687. /**
  86688. * Gets whether or not mp3 are supported by your browser.
  86689. */
  86690. isMP3supported: boolean;
  86691. /**
  86692. * Gets whether or not ogg are supported by your browser.
  86693. */
  86694. isOGGsupported: boolean;
  86695. /**
  86696. * Gets whether audio has been unlocked on the device.
  86697. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  86698. * a user interaction has happened.
  86699. */
  86700. unlocked: boolean;
  86701. /**
  86702. * Defines if the audio engine relies on a custom unlocked button.
  86703. * In this case, the embedded button will not be displayed.
  86704. */
  86705. useCustomUnlockedButton: boolean;
  86706. /**
  86707. * Event raised when audio has been unlocked on the browser.
  86708. */
  86709. onAudioUnlockedObservable: Observable<AudioEngine>;
  86710. /**
  86711. * Event raised when audio has been locked on the browser.
  86712. */
  86713. onAudioLockedObservable: Observable<AudioEngine>;
  86714. /**
  86715. * Gets the current AudioContext if available.
  86716. */
  86717. readonly audioContext: Nullable<AudioContext>;
  86718. private _connectedAnalyser;
  86719. /**
  86720. * Instantiates a new audio engine.
  86721. *
  86722. * There should be only one per page as some browsers restrict the number
  86723. * of audio contexts you can create.
  86724. * @param hostElement defines the host element where to display the mute icon if necessary
  86725. */
  86726. constructor(hostElement?: Nullable<HTMLElement>);
  86727. /**
  86728. * Flags the audio engine in Locked state.
  86729. * This happens due to new browser policies preventing audio to autoplay.
  86730. */
  86731. lock(): void;
  86732. /**
  86733. * Unlocks the audio engine once a user action has been done on the dom.
  86734. * This is helpful to resume play once browser policies have been satisfied.
  86735. */
  86736. unlock(): void;
  86737. private _resumeAudioContext;
  86738. private _initializeAudioContext;
  86739. private _tryToRun;
  86740. private _triggerRunningState;
  86741. private _triggerSuspendedState;
  86742. private _displayMuteButton;
  86743. private _moveButtonToTopLeft;
  86744. private _onResize;
  86745. private _hideMuteButton;
  86746. /**
  86747. * Destroy and release the resources associated with the audio ccontext.
  86748. */
  86749. dispose(): void;
  86750. /**
  86751. * Gets the global volume sets on the master gain.
  86752. * @returns the global volume if set or -1 otherwise
  86753. */
  86754. getGlobalVolume(): number;
  86755. /**
  86756. * Sets the global volume of your experience (sets on the master gain).
  86757. * @param newVolume Defines the new global volume of the application
  86758. */
  86759. setGlobalVolume(newVolume: number): void;
  86760. /**
  86761. * Connect the audio engine to an audio analyser allowing some amazing
  86762. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  86763. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  86764. * @param analyser The analyser to connect to the engine
  86765. */
  86766. connectToAnalyser(analyser: Analyser): void;
  86767. }
  86768. }
  86769. declare module BABYLON {
  86770. /**
  86771. * Interface used to present a loading screen while loading a scene
  86772. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  86773. */
  86774. export interface ILoadingScreen {
  86775. /**
  86776. * Function called to display the loading screen
  86777. */
  86778. displayLoadingUI: () => void;
  86779. /**
  86780. * Function called to hide the loading screen
  86781. */
  86782. hideLoadingUI: () => void;
  86783. /**
  86784. * Gets or sets the color to use for the background
  86785. */
  86786. loadingUIBackgroundColor: string;
  86787. /**
  86788. * Gets or sets the text to display while loading
  86789. */
  86790. loadingUIText: string;
  86791. }
  86792. /**
  86793. * Class used for the default loading screen
  86794. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  86795. */
  86796. export class DefaultLoadingScreen implements ILoadingScreen {
  86797. private _renderingCanvas;
  86798. private _loadingText;
  86799. private _loadingDivBackgroundColor;
  86800. private _loadingDiv;
  86801. private _loadingTextDiv;
  86802. /**
  86803. * Creates a new default loading screen
  86804. * @param _renderingCanvas defines the canvas used to render the scene
  86805. * @param _loadingText defines the default text to display
  86806. * @param _loadingDivBackgroundColor defines the default background color
  86807. */
  86808. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  86809. /**
  86810. * Function called to display the loading screen
  86811. */
  86812. displayLoadingUI(): void;
  86813. /**
  86814. * Function called to hide the loading screen
  86815. */
  86816. hideLoadingUI(): void;
  86817. /**
  86818. * Gets or sets the text to display while loading
  86819. */
  86820. loadingUIText: string;
  86821. /**
  86822. * Gets or sets the color to use for the background
  86823. */
  86824. loadingUIBackgroundColor: string;
  86825. private _resizeLoadingUI;
  86826. }
  86827. }
  86828. declare module BABYLON {
  86829. /** @hidden */
  86830. export class WebGLPipelineContext implements IPipelineContext {
  86831. engine: Engine;
  86832. program: Nullable<WebGLProgram>;
  86833. context?: WebGLRenderingContext;
  86834. vertexShader?: WebGLShader;
  86835. fragmentShader?: WebGLShader;
  86836. isParallelCompiled: boolean;
  86837. onCompiled?: () => void;
  86838. transformFeedback?: WebGLTransformFeedback | null;
  86839. readonly isAsync: boolean;
  86840. readonly isReady: boolean;
  86841. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  86842. }
  86843. }
  86844. declare module BABYLON {
  86845. /** @hidden */
  86846. export class WebGLDataBuffer extends DataBuffer {
  86847. private _buffer;
  86848. constructor(resource: WebGLBuffer);
  86849. readonly underlyingResource: any;
  86850. }
  86851. }
  86852. declare module BABYLON {
  86853. /**
  86854. * Settings for finer control over video usage
  86855. */
  86856. export interface VideoTextureSettings {
  86857. /**
  86858. * Applies `autoplay` to video, if specified
  86859. */
  86860. autoPlay?: boolean;
  86861. /**
  86862. * Applies `loop` to video, if specified
  86863. */
  86864. loop?: boolean;
  86865. /**
  86866. * Automatically updates internal texture from video at every frame in the render loop
  86867. */
  86868. autoUpdateTexture: boolean;
  86869. /**
  86870. * Image src displayed during the video loading or until the user interacts with the video.
  86871. */
  86872. poster?: string;
  86873. }
  86874. /**
  86875. * If you want to display a video in your scene, this is the special texture for that.
  86876. * This special texture works similar to other textures, with the exception of a few parameters.
  86877. * @see https://doc.babylonjs.com/how_to/video_texture
  86878. */
  86879. export class VideoTexture extends Texture {
  86880. /**
  86881. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  86882. */
  86883. readonly autoUpdateTexture: boolean;
  86884. /**
  86885. * The video instance used by the texture internally
  86886. */
  86887. readonly video: HTMLVideoElement;
  86888. private _onUserActionRequestedObservable;
  86889. /**
  86890. * Event triggerd when a dom action is required by the user to play the video.
  86891. * This happens due to recent changes in browser policies preventing video to auto start.
  86892. */
  86893. readonly onUserActionRequestedObservable: Observable<Texture>;
  86894. private _generateMipMaps;
  86895. private _engine;
  86896. private _stillImageCaptured;
  86897. private _displayingPosterTexture;
  86898. private _settings;
  86899. private _createInternalTextureOnEvent;
  86900. /**
  86901. * Creates a video texture.
  86902. * If you want to display a video in your scene, this is the special texture for that.
  86903. * This special texture works similar to other textures, with the exception of a few parameters.
  86904. * @see https://doc.babylonjs.com/how_to/video_texture
  86905. * @param name optional name, will detect from video source, if not defined
  86906. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  86907. * @param scene is obviously the current scene.
  86908. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  86909. * @param invertY is false by default but can be used to invert video on Y axis
  86910. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  86911. * @param settings allows finer control over video usage
  86912. */
  86913. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  86914. private _getName;
  86915. private _getVideo;
  86916. private _createInternalTexture;
  86917. private reset;
  86918. /**
  86919. * @hidden Internal method to initiate `update`.
  86920. */
  86921. _rebuild(): void;
  86922. /**
  86923. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  86924. */
  86925. update(): void;
  86926. /**
  86927. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  86928. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  86929. */
  86930. updateTexture(isVisible: boolean): void;
  86931. protected _updateInternalTexture: () => void;
  86932. /**
  86933. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  86934. * @param url New url.
  86935. */
  86936. updateURL(url: string): void;
  86937. /**
  86938. * Dispose the texture and release its associated resources.
  86939. */
  86940. dispose(): void;
  86941. /**
  86942. * Creates a video texture straight from a stream.
  86943. * @param scene Define the scene the texture should be created in
  86944. * @param stream Define the stream the texture should be created from
  86945. * @returns The created video texture as a promise
  86946. */
  86947. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  86948. /**
  86949. * Creates a video texture straight from your WebCam video feed.
  86950. * @param scene Define the scene the texture should be created in
  86951. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  86952. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  86953. * @returns The created video texture as a promise
  86954. */
  86955. static CreateFromWebCamAsync(scene: Scene, constraints: {
  86956. minWidth: number;
  86957. maxWidth: number;
  86958. minHeight: number;
  86959. maxHeight: number;
  86960. deviceId: string;
  86961. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  86962. /**
  86963. * Creates a video texture straight from your WebCam video feed.
  86964. * @param scene Define the scene the texture should be created in
  86965. * @param onReady Define a callback to triggered once the texture will be ready
  86966. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  86967. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  86968. */
  86969. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  86970. minWidth: number;
  86971. maxWidth: number;
  86972. minHeight: number;
  86973. maxHeight: number;
  86974. deviceId: string;
  86975. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  86976. }
  86977. }
  86978. declare module BABYLON {
  86979. /**
  86980. * Interface for attribute information associated with buffer instanciation
  86981. */
  86982. export class InstancingAttributeInfo {
  86983. /**
  86984. * Index/offset of the attribute in the vertex shader
  86985. */
  86986. index: number;
  86987. /**
  86988. * size of the attribute, 1, 2, 3 or 4
  86989. */
  86990. attributeSize: number;
  86991. /**
  86992. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  86993. * default is FLOAT
  86994. */
  86995. attribyteType: number;
  86996. /**
  86997. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  86998. */
  86999. normalized: boolean;
  87000. /**
  87001. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  87002. */
  87003. offset: number;
  87004. /**
  87005. * Name of the GLSL attribute, for debugging purpose only
  87006. */
  87007. attributeName: string;
  87008. }
  87009. /**
  87010. * Define options used to create a depth texture
  87011. */
  87012. export class DepthTextureCreationOptions {
  87013. /** Specifies whether or not a stencil should be allocated in the texture */
  87014. generateStencil?: boolean;
  87015. /** Specifies whether or not bilinear filtering is enable on the texture */
  87016. bilinearFiltering?: boolean;
  87017. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  87018. comparisonFunction?: number;
  87019. /** Specifies if the created texture is a cube texture */
  87020. isCube?: boolean;
  87021. }
  87022. /**
  87023. * Class used to describe the capabilities of the engine relatively to the current browser
  87024. */
  87025. export class EngineCapabilities {
  87026. /** Maximum textures units per fragment shader */
  87027. maxTexturesImageUnits: number;
  87028. /** Maximum texture units per vertex shader */
  87029. maxVertexTextureImageUnits: number;
  87030. /** Maximum textures units in the entire pipeline */
  87031. maxCombinedTexturesImageUnits: number;
  87032. /** Maximum texture size */
  87033. maxTextureSize: number;
  87034. /** Maximum cube texture size */
  87035. maxCubemapTextureSize: number;
  87036. /** Maximum render texture size */
  87037. maxRenderTextureSize: number;
  87038. /** Maximum number of vertex attributes */
  87039. maxVertexAttribs: number;
  87040. /** Maximum number of varyings */
  87041. maxVaryingVectors: number;
  87042. /** Maximum number of uniforms per vertex shader */
  87043. maxVertexUniformVectors: number;
  87044. /** Maximum number of uniforms per fragment shader */
  87045. maxFragmentUniformVectors: number;
  87046. /** Defines if standard derivates (dx/dy) are supported */
  87047. standardDerivatives: boolean;
  87048. /** Defines if s3tc texture compression is supported */
  87049. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  87050. /** Defines if pvrtc texture compression is supported */
  87051. pvrtc: any;
  87052. /** Defines if etc1 texture compression is supported */
  87053. etc1: any;
  87054. /** Defines if etc2 texture compression is supported */
  87055. etc2: any;
  87056. /** Defines if astc texture compression is supported */
  87057. astc: any;
  87058. /** Defines if float textures are supported */
  87059. textureFloat: boolean;
  87060. /** Defines if vertex array objects are supported */
  87061. vertexArrayObject: boolean;
  87062. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  87063. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  87064. /** Gets the maximum level of anisotropy supported */
  87065. maxAnisotropy: number;
  87066. /** Defines if instancing is supported */
  87067. instancedArrays: boolean;
  87068. /** Defines if 32 bits indices are supported */
  87069. uintIndices: boolean;
  87070. /** Defines if high precision shaders are supported */
  87071. highPrecisionShaderSupported: boolean;
  87072. /** Defines if depth reading in the fragment shader is supported */
  87073. fragmentDepthSupported: boolean;
  87074. /** Defines if float texture linear filtering is supported*/
  87075. textureFloatLinearFiltering: boolean;
  87076. /** Defines if rendering to float textures is supported */
  87077. textureFloatRender: boolean;
  87078. /** Defines if half float textures are supported*/
  87079. textureHalfFloat: boolean;
  87080. /** Defines if half float texture linear filtering is supported*/
  87081. textureHalfFloatLinearFiltering: boolean;
  87082. /** Defines if rendering to half float textures is supported */
  87083. textureHalfFloatRender: boolean;
  87084. /** Defines if textureLOD shader command is supported */
  87085. textureLOD: boolean;
  87086. /** Defines if draw buffers extension is supported */
  87087. drawBuffersExtension: boolean;
  87088. /** Defines if depth textures are supported */
  87089. depthTextureExtension: boolean;
  87090. /** Defines if float color buffer are supported */
  87091. colorBufferFloat: boolean;
  87092. /** Gets disjoint timer query extension (null if not supported) */
  87093. timerQuery: EXT_disjoint_timer_query;
  87094. /** Defines if timestamp can be used with timer query */
  87095. canUseTimestampForTimerQuery: boolean;
  87096. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  87097. multiview: any;
  87098. /** Function used to let the system compiles shaders in background */
  87099. parallelShaderCompile: {
  87100. COMPLETION_STATUS_KHR: number;
  87101. };
  87102. }
  87103. /** Interface defining initialization parameters for Engine class */
  87104. export interface EngineOptions extends WebGLContextAttributes {
  87105. /**
  87106. * Defines if the engine should no exceed a specified device ratio
  87107. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  87108. */
  87109. limitDeviceRatio?: number;
  87110. /**
  87111. * Defines if webvr should be enabled automatically
  87112. * @see http://doc.babylonjs.com/how_to/webvr_camera
  87113. */
  87114. autoEnableWebVR?: boolean;
  87115. /**
  87116. * Defines if webgl2 should be turned off even if supported
  87117. * @see http://doc.babylonjs.com/features/webgl2
  87118. */
  87119. disableWebGL2Support?: boolean;
  87120. /**
  87121. * Defines if webaudio should be initialized as well
  87122. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  87123. */
  87124. audioEngine?: boolean;
  87125. /**
  87126. * Defines if animations should run using a deterministic lock step
  87127. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  87128. */
  87129. deterministicLockstep?: boolean;
  87130. /** Defines the maximum steps to use with deterministic lock step mode */
  87131. lockstepMaxSteps?: number;
  87132. /**
  87133. * Defines that engine should ignore context lost events
  87134. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  87135. */
  87136. doNotHandleContextLost?: boolean;
  87137. /**
  87138. * Defines that engine should ignore modifying touch action attribute and style
  87139. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  87140. */
  87141. doNotHandleTouchAction?: boolean;
  87142. /**
  87143. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  87144. */
  87145. useHighPrecisionFloats?: boolean;
  87146. }
  87147. /**
  87148. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  87149. */
  87150. export class Engine {
  87151. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  87152. static ExceptionList: ({
  87153. key: string;
  87154. capture: string;
  87155. captureConstraint: number;
  87156. targets: string[];
  87157. } | {
  87158. key: string;
  87159. capture: null;
  87160. captureConstraint: null;
  87161. targets: string[];
  87162. })[];
  87163. /** Gets the list of created engines */
  87164. static readonly Instances: Engine[];
  87165. /**
  87166. * Gets the latest created engine
  87167. */
  87168. static readonly LastCreatedEngine: Nullable<Engine>;
  87169. /**
  87170. * Gets the latest created scene
  87171. */
  87172. static readonly LastCreatedScene: Nullable<Scene>;
  87173. /**
  87174. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  87175. * @param flag defines which part of the materials must be marked as dirty
  87176. * @param predicate defines a predicate used to filter which materials should be affected
  87177. */
  87178. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  87179. /**
  87180. * Hidden
  87181. */
  87182. static _TextureLoaders: IInternalTextureLoader[];
  87183. /** Defines that alpha blending is disabled */
  87184. static readonly ALPHA_DISABLE: number;
  87185. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  87186. static readonly ALPHA_ADD: number;
  87187. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  87188. static readonly ALPHA_COMBINE: number;
  87189. /** Defines that alpha blending to DEST - SRC * DEST */
  87190. static readonly ALPHA_SUBTRACT: number;
  87191. /** Defines that alpha blending to SRC * DEST */
  87192. static readonly ALPHA_MULTIPLY: number;
  87193. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  87194. static readonly ALPHA_MAXIMIZED: number;
  87195. /** Defines that alpha blending to SRC + DEST */
  87196. static readonly ALPHA_ONEONE: number;
  87197. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  87198. static readonly ALPHA_PREMULTIPLIED: number;
  87199. /**
  87200. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  87201. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  87202. */
  87203. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  87204. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  87205. static readonly ALPHA_INTERPOLATE: number;
  87206. /**
  87207. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  87208. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  87209. */
  87210. static readonly ALPHA_SCREENMODE: number;
  87211. /** Defines that the ressource is not delayed*/
  87212. static readonly DELAYLOADSTATE_NONE: number;
  87213. /** Defines that the ressource was successfully delay loaded */
  87214. static readonly DELAYLOADSTATE_LOADED: number;
  87215. /** Defines that the ressource is currently delay loading */
  87216. static readonly DELAYLOADSTATE_LOADING: number;
  87217. /** Defines that the ressource is delayed and has not started loading */
  87218. static readonly DELAYLOADSTATE_NOTLOADED: number;
  87219. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  87220. static readonly NEVER: number;
  87221. /** 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 */
  87222. static readonly ALWAYS: number;
  87223. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  87224. static readonly LESS: number;
  87225. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  87226. static readonly EQUAL: number;
  87227. /** 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 */
  87228. static readonly LEQUAL: number;
  87229. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  87230. static readonly GREATER: number;
  87231. /** 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 */
  87232. static readonly GEQUAL: number;
  87233. /** 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 */
  87234. static readonly NOTEQUAL: number;
  87235. /** Passed to stencilOperation to specify that stencil value must be kept */
  87236. static readonly KEEP: number;
  87237. /** Passed to stencilOperation to specify that stencil value must be replaced */
  87238. static readonly REPLACE: number;
  87239. /** Passed to stencilOperation to specify that stencil value must be incremented */
  87240. static readonly INCR: number;
  87241. /** Passed to stencilOperation to specify that stencil value must be decremented */
  87242. static readonly DECR: number;
  87243. /** Passed to stencilOperation to specify that stencil value must be inverted */
  87244. static readonly INVERT: number;
  87245. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  87246. static readonly INCR_WRAP: number;
  87247. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  87248. static readonly DECR_WRAP: number;
  87249. /** Texture is not repeating outside of 0..1 UVs */
  87250. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  87251. /** Texture is repeating outside of 0..1 UVs */
  87252. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  87253. /** Texture is repeating and mirrored */
  87254. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  87255. /** ALPHA */
  87256. static readonly TEXTUREFORMAT_ALPHA: number;
  87257. /** LUMINANCE */
  87258. static readonly TEXTUREFORMAT_LUMINANCE: number;
  87259. /** LUMINANCE_ALPHA */
  87260. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  87261. /** RGB */
  87262. static readonly TEXTUREFORMAT_RGB: number;
  87263. /** RGBA */
  87264. static readonly TEXTUREFORMAT_RGBA: number;
  87265. /** RED */
  87266. static readonly TEXTUREFORMAT_RED: number;
  87267. /** RED (2nd reference) */
  87268. static readonly TEXTUREFORMAT_R: number;
  87269. /** RG */
  87270. static readonly TEXTUREFORMAT_RG: number;
  87271. /** RED_INTEGER */
  87272. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  87273. /** RED_INTEGER (2nd reference) */
  87274. static readonly TEXTUREFORMAT_R_INTEGER: number;
  87275. /** RG_INTEGER */
  87276. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  87277. /** RGB_INTEGER */
  87278. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  87279. /** RGBA_INTEGER */
  87280. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  87281. /** UNSIGNED_BYTE */
  87282. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  87283. /** UNSIGNED_BYTE (2nd reference) */
  87284. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  87285. /** FLOAT */
  87286. static readonly TEXTURETYPE_FLOAT: number;
  87287. /** HALF_FLOAT */
  87288. static readonly TEXTURETYPE_HALF_FLOAT: number;
  87289. /** BYTE */
  87290. static readonly TEXTURETYPE_BYTE: number;
  87291. /** SHORT */
  87292. static readonly TEXTURETYPE_SHORT: number;
  87293. /** UNSIGNED_SHORT */
  87294. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  87295. /** INT */
  87296. static readonly TEXTURETYPE_INT: number;
  87297. /** UNSIGNED_INT */
  87298. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  87299. /** UNSIGNED_SHORT_4_4_4_4 */
  87300. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  87301. /** UNSIGNED_SHORT_5_5_5_1 */
  87302. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  87303. /** UNSIGNED_SHORT_5_6_5 */
  87304. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  87305. /** UNSIGNED_INT_2_10_10_10_REV */
  87306. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  87307. /** UNSIGNED_INT_24_8 */
  87308. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  87309. /** UNSIGNED_INT_10F_11F_11F_REV */
  87310. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  87311. /** UNSIGNED_INT_5_9_9_9_REV */
  87312. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  87313. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  87314. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  87315. /** nearest is mag = nearest and min = nearest and mip = linear */
  87316. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  87317. /** Bilinear is mag = linear and min = linear and mip = nearest */
  87318. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  87319. /** Trilinear is mag = linear and min = linear and mip = linear */
  87320. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  87321. /** nearest is mag = nearest and min = nearest and mip = linear */
  87322. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  87323. /** Bilinear is mag = linear and min = linear and mip = nearest */
  87324. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  87325. /** Trilinear is mag = linear and min = linear and mip = linear */
  87326. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  87327. /** mag = nearest and min = nearest and mip = nearest */
  87328. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  87329. /** mag = nearest and min = linear and mip = nearest */
  87330. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  87331. /** mag = nearest and min = linear and mip = linear */
  87332. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  87333. /** mag = nearest and min = linear and mip = none */
  87334. static readonly TEXTURE_NEAREST_LINEAR: number;
  87335. /** mag = nearest and min = nearest and mip = none */
  87336. static readonly TEXTURE_NEAREST_NEAREST: number;
  87337. /** mag = linear and min = nearest and mip = nearest */
  87338. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  87339. /** mag = linear and min = nearest and mip = linear */
  87340. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  87341. /** mag = linear and min = linear and mip = none */
  87342. static readonly TEXTURE_LINEAR_LINEAR: number;
  87343. /** mag = linear and min = nearest and mip = none */
  87344. static readonly TEXTURE_LINEAR_NEAREST: number;
  87345. /** Explicit coordinates mode */
  87346. static readonly TEXTURE_EXPLICIT_MODE: number;
  87347. /** Spherical coordinates mode */
  87348. static readonly TEXTURE_SPHERICAL_MODE: number;
  87349. /** Planar coordinates mode */
  87350. static readonly TEXTURE_PLANAR_MODE: number;
  87351. /** Cubic coordinates mode */
  87352. static readonly TEXTURE_CUBIC_MODE: number;
  87353. /** Projection coordinates mode */
  87354. static readonly TEXTURE_PROJECTION_MODE: number;
  87355. /** Skybox coordinates mode */
  87356. static readonly TEXTURE_SKYBOX_MODE: number;
  87357. /** Inverse Cubic coordinates mode */
  87358. static readonly TEXTURE_INVCUBIC_MODE: number;
  87359. /** Equirectangular coordinates mode */
  87360. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  87361. /** Equirectangular Fixed coordinates mode */
  87362. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  87363. /** Equirectangular Fixed Mirrored coordinates mode */
  87364. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  87365. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  87366. static readonly SCALEMODE_FLOOR: number;
  87367. /** Defines that texture rescaling will look for the nearest power of 2 size */
  87368. static readonly SCALEMODE_NEAREST: number;
  87369. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  87370. static readonly SCALEMODE_CEILING: number;
  87371. /**
  87372. * Returns the current npm package of the sdk
  87373. */
  87374. static readonly NpmPackage: string;
  87375. /**
  87376. * Returns the current version of the framework
  87377. */
  87378. static readonly Version: string;
  87379. /**
  87380. * Returns a string describing the current engine
  87381. */
  87382. readonly description: string;
  87383. /**
  87384. * Gets or sets the epsilon value used by collision engine
  87385. */
  87386. static CollisionsEpsilon: number;
  87387. /**
  87388. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  87389. */
  87390. static ShadersRepository: string;
  87391. /**
  87392. * Method called to create the default loading screen.
  87393. * This can be overriden in your own app.
  87394. * @param canvas The rendering canvas element
  87395. * @returns The loading screen
  87396. */
  87397. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  87398. /**
  87399. * Method called to create the default rescale post process on each engine.
  87400. */
  87401. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  87402. /**
  87403. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  87404. */
  87405. forcePOTTextures: boolean;
  87406. /**
  87407. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  87408. */
  87409. isFullscreen: boolean;
  87410. /**
  87411. * Gets a boolean indicating if the pointer is currently locked
  87412. */
  87413. isPointerLock: boolean;
  87414. /**
  87415. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  87416. */
  87417. cullBackFaces: boolean;
  87418. /**
  87419. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  87420. */
  87421. renderEvenInBackground: boolean;
  87422. /**
  87423. * Gets or sets a boolean indicating that cache can be kept between frames
  87424. */
  87425. preventCacheWipeBetweenFrames: boolean;
  87426. /**
  87427. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  87428. **/
  87429. enableOfflineSupport: boolean;
  87430. /**
  87431. * 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)
  87432. **/
  87433. disableManifestCheck: boolean;
  87434. /**
  87435. * Gets the list of created scenes
  87436. */
  87437. scenes: Scene[];
  87438. /**
  87439. * Event raised when a new scene is created
  87440. */
  87441. onNewSceneAddedObservable: Observable<Scene>;
  87442. /**
  87443. * Gets the list of created postprocesses
  87444. */
  87445. postProcesses: PostProcess[];
  87446. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  87447. validateShaderPrograms: boolean;
  87448. /**
  87449. * Observable event triggered each time the rendering canvas is resized
  87450. */
  87451. onResizeObservable: Observable<Engine>;
  87452. /**
  87453. * Observable event triggered each time the canvas loses focus
  87454. */
  87455. onCanvasBlurObservable: Observable<Engine>;
  87456. /**
  87457. * Observable event triggered each time the canvas gains focus
  87458. */
  87459. onCanvasFocusObservable: Observable<Engine>;
  87460. /**
  87461. * Observable event triggered each time the canvas receives pointerout event
  87462. */
  87463. onCanvasPointerOutObservable: Observable<PointerEvent>;
  87464. /**
  87465. * Observable event triggered before each texture is initialized
  87466. */
  87467. onBeforeTextureInitObservable: Observable<Texture>;
  87468. /**
  87469. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  87470. */
  87471. disableUniformBuffers: boolean;
  87472. /** @hidden */
  87473. _uniformBuffers: UniformBuffer[];
  87474. /**
  87475. * Gets a boolean indicating that the engine supports uniform buffers
  87476. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  87477. */
  87478. readonly supportsUniformBuffers: boolean;
  87479. /**
  87480. * Observable raised when the engine begins a new frame
  87481. */
  87482. onBeginFrameObservable: Observable<Engine>;
  87483. /**
  87484. * If set, will be used to request the next animation frame for the render loop
  87485. */
  87486. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  87487. /**
  87488. * Observable raised when the engine ends the current frame
  87489. */
  87490. onEndFrameObservable: Observable<Engine>;
  87491. /**
  87492. * Observable raised when the engine is about to compile a shader
  87493. */
  87494. onBeforeShaderCompilationObservable: Observable<Engine>;
  87495. /**
  87496. * Observable raised when the engine has jsut compiled a shader
  87497. */
  87498. onAfterShaderCompilationObservable: Observable<Engine>;
  87499. /** @hidden */
  87500. _gl: WebGLRenderingContext;
  87501. private _renderingCanvas;
  87502. private _windowIsBackground;
  87503. private _webGLVersion;
  87504. protected _highPrecisionShadersAllowed: boolean;
  87505. /** @hidden */
  87506. readonly _shouldUseHighPrecisionShader: boolean;
  87507. /**
  87508. * Gets a boolean indicating that only power of 2 textures are supported
  87509. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  87510. */
  87511. readonly needPOTTextures: boolean;
  87512. /** @hidden */
  87513. _badOS: boolean;
  87514. /** @hidden */
  87515. _badDesktopOS: boolean;
  87516. /**
  87517. * Gets the audio engine
  87518. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  87519. * @ignorenaming
  87520. */
  87521. static audioEngine: IAudioEngine;
  87522. /**
  87523. * Default AudioEngine factory responsible of creating the Audio Engine.
  87524. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  87525. */
  87526. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  87527. /**
  87528. * Default offline support factory responsible of creating a tool used to store data locally.
  87529. * By default, this will create a Database object if the workload has been embedded.
  87530. */
  87531. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  87532. private _onFocus;
  87533. private _onBlur;
  87534. private _onCanvasPointerOut;
  87535. private _onCanvasBlur;
  87536. private _onCanvasFocus;
  87537. private _onFullscreenChange;
  87538. private _onPointerLockChange;
  87539. private _hardwareScalingLevel;
  87540. /** @hidden */
  87541. _caps: EngineCapabilities;
  87542. private _pointerLockRequested;
  87543. private _isStencilEnable;
  87544. private _colorWrite;
  87545. private _loadingScreen;
  87546. /** @hidden */
  87547. _drawCalls: PerfCounter;
  87548. private _glVersion;
  87549. private _glRenderer;
  87550. private _glVendor;
  87551. private _videoTextureSupported;
  87552. private _renderingQueueLaunched;
  87553. private _activeRenderLoops;
  87554. private _deterministicLockstep;
  87555. private _lockstepMaxSteps;
  87556. /**
  87557. * Observable signaled when a context lost event is raised
  87558. */
  87559. onContextLostObservable: Observable<Engine>;
  87560. /**
  87561. * Observable signaled when a context restored event is raised
  87562. */
  87563. onContextRestoredObservable: Observable<Engine>;
  87564. private _onContextLost;
  87565. private _onContextRestored;
  87566. private _contextWasLost;
  87567. /** @hidden */
  87568. _doNotHandleContextLost: boolean;
  87569. /**
  87570. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  87571. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  87572. */
  87573. doNotHandleContextLost: boolean;
  87574. private _performanceMonitor;
  87575. private _fps;
  87576. private _deltaTime;
  87577. /**
  87578. * Turn this value on if you want to pause FPS computation when in background
  87579. */
  87580. disablePerformanceMonitorInBackground: boolean;
  87581. /**
  87582. * Gets the performance monitor attached to this engine
  87583. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  87584. */
  87585. readonly performanceMonitor: PerformanceMonitor;
  87586. /**
  87587. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  87588. */
  87589. disableVertexArrayObjects: boolean;
  87590. /** @hidden */
  87591. protected _depthCullingState: _DepthCullingState;
  87592. /** @hidden */
  87593. protected _stencilState: _StencilState;
  87594. /** @hidden */
  87595. protected _alphaState: _AlphaState;
  87596. /** @hidden */
  87597. protected _alphaMode: number;
  87598. /** @hidden */
  87599. _internalTexturesCache: InternalTexture[];
  87600. /** @hidden */
  87601. protected _activeChannel: number;
  87602. private _currentTextureChannel;
  87603. /** @hidden */
  87604. protected _boundTexturesCache: {
  87605. [key: string]: Nullable<InternalTexture>;
  87606. };
  87607. /** @hidden */
  87608. protected _currentEffect: Nullable<Effect>;
  87609. /** @hidden */
  87610. protected _currentProgram: Nullable<WebGLProgram>;
  87611. private _compiledEffects;
  87612. private _vertexAttribArraysEnabled;
  87613. /** @hidden */
  87614. protected _cachedViewport: Nullable<Viewport>;
  87615. private _cachedVertexArrayObject;
  87616. /** @hidden */
  87617. protected _cachedVertexBuffers: any;
  87618. /** @hidden */
  87619. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  87620. /** @hidden */
  87621. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  87622. /** @hidden */
  87623. _currentRenderTarget: Nullable<InternalTexture>;
  87624. private _uintIndicesCurrentlySet;
  87625. private _currentBoundBuffer;
  87626. /** @hidden */
  87627. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  87628. private _currentBufferPointers;
  87629. private _currentInstanceLocations;
  87630. private _currentInstanceBuffers;
  87631. private _textureUnits;
  87632. /** @hidden */
  87633. _workingCanvas: Nullable<HTMLCanvasElement>;
  87634. /** @hidden */
  87635. _workingContext: Nullable<CanvasRenderingContext2D>;
  87636. private _rescalePostProcess;
  87637. private _dummyFramebuffer;
  87638. private _externalData;
  87639. /** @hidden */
  87640. _bindedRenderFunction: any;
  87641. private _vaoRecordInProgress;
  87642. private _mustWipeVertexAttributes;
  87643. private _emptyTexture;
  87644. private _emptyCubeTexture;
  87645. private _emptyTexture3D;
  87646. /** @hidden */
  87647. _frameHandler: number;
  87648. private _nextFreeTextureSlots;
  87649. private _maxSimultaneousTextures;
  87650. private _activeRequests;
  87651. private _texturesSupported;
  87652. /** @hidden */
  87653. _textureFormatInUse: Nullable<string>;
  87654. /**
  87655. * Gets the list of texture formats supported
  87656. */
  87657. readonly texturesSupported: Array<string>;
  87658. /**
  87659. * Gets the list of texture formats in use
  87660. */
  87661. readonly textureFormatInUse: Nullable<string>;
  87662. /**
  87663. * Gets the current viewport
  87664. */
  87665. readonly currentViewport: Nullable<Viewport>;
  87666. /**
  87667. * Gets the default empty texture
  87668. */
  87669. readonly emptyTexture: InternalTexture;
  87670. /**
  87671. * Gets the default empty 3D texture
  87672. */
  87673. readonly emptyTexture3D: InternalTexture;
  87674. /**
  87675. * Gets the default empty cube texture
  87676. */
  87677. readonly emptyCubeTexture: InternalTexture;
  87678. /**
  87679. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  87680. */
  87681. readonly premultipliedAlpha: boolean;
  87682. /**
  87683. * Creates a new engine
  87684. * @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
  87685. * @param antialias defines enable antialiasing (default: false)
  87686. * @param options defines further options to be sent to the getContext() function
  87687. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  87688. */
  87689. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  87690. /**
  87691. * Initializes a webVR display and starts listening to display change events
  87692. * The onVRDisplayChangedObservable will be notified upon these changes
  87693. * @returns The onVRDisplayChangedObservable
  87694. */
  87695. initWebVR(): Observable<IDisplayChangedEventArgs>;
  87696. /** @hidden */
  87697. _prepareVRComponent(): void;
  87698. /** @hidden */
  87699. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  87700. /** @hidden */
  87701. _submitVRFrame(): void;
  87702. /**
  87703. * Call this function to leave webVR mode
  87704. * Will do nothing if webVR is not supported or if there is no webVR device
  87705. * @see http://doc.babylonjs.com/how_to/webvr_camera
  87706. */
  87707. disableVR(): void;
  87708. /**
  87709. * Gets a boolean indicating that the system is in VR mode and is presenting
  87710. * @returns true if VR mode is engaged
  87711. */
  87712. isVRPresenting(): boolean;
  87713. /** @hidden */
  87714. _requestVRFrame(): void;
  87715. private _disableTouchAction;
  87716. private _rebuildInternalTextures;
  87717. private _rebuildEffects;
  87718. /**
  87719. * Gets a boolean indicating if all created effects are ready
  87720. * @returns true if all effects are ready
  87721. */
  87722. areAllEffectsReady(): boolean;
  87723. private _rebuildBuffers;
  87724. private _initGLContext;
  87725. /**
  87726. * Gets version of the current webGL context
  87727. */
  87728. readonly webGLVersion: number;
  87729. /**
  87730. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  87731. */
  87732. readonly isStencilEnable: boolean;
  87733. /** @hidden */
  87734. _prepareWorkingCanvas(): void;
  87735. /**
  87736. * Reset the texture cache to empty state
  87737. */
  87738. resetTextureCache(): void;
  87739. /**
  87740. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  87741. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  87742. * @returns true if engine is in deterministic lock step mode
  87743. */
  87744. isDeterministicLockStep(): boolean;
  87745. /**
  87746. * Gets the max steps when engine is running in deterministic lock step
  87747. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  87748. * @returns the max steps
  87749. */
  87750. getLockstepMaxSteps(): number;
  87751. /**
  87752. * Gets an object containing information about the current webGL context
  87753. * @returns an object containing the vender, the renderer and the version of the current webGL context
  87754. */
  87755. getGlInfo(): {
  87756. vendor: string;
  87757. renderer: string;
  87758. version: string;
  87759. };
  87760. /**
  87761. * Gets current aspect ratio
  87762. * @param camera defines the camera to use to get the aspect ratio
  87763. * @param useScreen defines if screen size must be used (or the current render target if any)
  87764. * @returns a number defining the aspect ratio
  87765. */
  87766. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  87767. /**
  87768. * Gets current screen aspect ratio
  87769. * @returns a number defining the aspect ratio
  87770. */
  87771. getScreenAspectRatio(): number;
  87772. /**
  87773. * Gets the current render width
  87774. * @param useScreen defines if screen size must be used (or the current render target if any)
  87775. * @returns a number defining the current render width
  87776. */
  87777. getRenderWidth(useScreen?: boolean): number;
  87778. /**
  87779. * Gets the current render height
  87780. * @param useScreen defines if screen size must be used (or the current render target if any)
  87781. * @returns a number defining the current render height
  87782. */
  87783. getRenderHeight(useScreen?: boolean): number;
  87784. /**
  87785. * Gets the HTML canvas attached with the current webGL context
  87786. * @returns a HTML canvas
  87787. */
  87788. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  87789. /**
  87790. * Gets the client rect of the HTML canvas attached with the current webGL context
  87791. * @returns a client rectanglee
  87792. */
  87793. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  87794. /**
  87795. * Defines the hardware scaling level.
  87796. * By default the hardware scaling level is computed from the window device ratio.
  87797. * 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.
  87798. * @param level defines the level to use
  87799. */
  87800. setHardwareScalingLevel(level: number): void;
  87801. /**
  87802. * Gets the current hardware scaling level.
  87803. * By default the hardware scaling level is computed from the window device ratio.
  87804. * 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.
  87805. * @returns a number indicating the current hardware scaling level
  87806. */
  87807. getHardwareScalingLevel(): number;
  87808. /**
  87809. * Gets the list of loaded textures
  87810. * @returns an array containing all loaded textures
  87811. */
  87812. getLoadedTexturesCache(): InternalTexture[];
  87813. /**
  87814. * Gets the object containing all engine capabilities
  87815. * @returns the EngineCapabilities object
  87816. */
  87817. getCaps(): EngineCapabilities;
  87818. /**
  87819. * Gets the current depth function
  87820. * @returns a number defining the depth function
  87821. */
  87822. getDepthFunction(): Nullable<number>;
  87823. /**
  87824. * Sets the current depth function
  87825. * @param depthFunc defines the function to use
  87826. */
  87827. setDepthFunction(depthFunc: number): void;
  87828. /**
  87829. * Sets the current depth function to GREATER
  87830. */
  87831. setDepthFunctionToGreater(): void;
  87832. /**
  87833. * Sets the current depth function to GEQUAL
  87834. */
  87835. setDepthFunctionToGreaterOrEqual(): void;
  87836. /**
  87837. * Sets the current depth function to LESS
  87838. */
  87839. setDepthFunctionToLess(): void;
  87840. private _cachedStencilBuffer;
  87841. private _cachedStencilFunction;
  87842. private _cachedStencilMask;
  87843. private _cachedStencilOperationPass;
  87844. private _cachedStencilOperationFail;
  87845. private _cachedStencilOperationDepthFail;
  87846. private _cachedStencilReference;
  87847. /**
  87848. * Caches the the state of the stencil buffer
  87849. */
  87850. cacheStencilState(): void;
  87851. /**
  87852. * Restores the state of the stencil buffer
  87853. */
  87854. restoreStencilState(): void;
  87855. /**
  87856. * Sets the current depth function to LEQUAL
  87857. */
  87858. setDepthFunctionToLessOrEqual(): void;
  87859. /**
  87860. * Gets a boolean indicating if stencil buffer is enabled
  87861. * @returns the current stencil buffer state
  87862. */
  87863. getStencilBuffer(): boolean;
  87864. /**
  87865. * Enable or disable the stencil buffer
  87866. * @param enable defines if the stencil buffer must be enabled or disabled
  87867. */
  87868. setStencilBuffer(enable: boolean): void;
  87869. /**
  87870. * Gets the current stencil mask
  87871. * @returns a number defining the new stencil mask to use
  87872. */
  87873. getStencilMask(): number;
  87874. /**
  87875. * Sets the current stencil mask
  87876. * @param mask defines the new stencil mask to use
  87877. */
  87878. setStencilMask(mask: number): void;
  87879. /**
  87880. * Gets the current stencil function
  87881. * @returns a number defining the stencil function to use
  87882. */
  87883. getStencilFunction(): number;
  87884. /**
  87885. * Gets the current stencil reference value
  87886. * @returns a number defining the stencil reference value to use
  87887. */
  87888. getStencilFunctionReference(): number;
  87889. /**
  87890. * Gets the current stencil mask
  87891. * @returns a number defining the stencil mask to use
  87892. */
  87893. getStencilFunctionMask(): number;
  87894. /**
  87895. * Sets the current stencil function
  87896. * @param stencilFunc defines the new stencil function to use
  87897. */
  87898. setStencilFunction(stencilFunc: number): void;
  87899. /**
  87900. * Sets the current stencil reference
  87901. * @param reference defines the new stencil reference to use
  87902. */
  87903. setStencilFunctionReference(reference: number): void;
  87904. /**
  87905. * Sets the current stencil mask
  87906. * @param mask defines the new stencil mask to use
  87907. */
  87908. setStencilFunctionMask(mask: number): void;
  87909. /**
  87910. * Gets the current stencil operation when stencil fails
  87911. * @returns a number defining stencil operation to use when stencil fails
  87912. */
  87913. getStencilOperationFail(): number;
  87914. /**
  87915. * Gets the current stencil operation when depth fails
  87916. * @returns a number defining stencil operation to use when depth fails
  87917. */
  87918. getStencilOperationDepthFail(): number;
  87919. /**
  87920. * Gets the current stencil operation when stencil passes
  87921. * @returns a number defining stencil operation to use when stencil passes
  87922. */
  87923. getStencilOperationPass(): number;
  87924. /**
  87925. * Sets the stencil operation to use when stencil fails
  87926. * @param operation defines the stencil operation to use when stencil fails
  87927. */
  87928. setStencilOperationFail(operation: number): void;
  87929. /**
  87930. * Sets the stencil operation to use when depth fails
  87931. * @param operation defines the stencil operation to use when depth fails
  87932. */
  87933. setStencilOperationDepthFail(operation: number): void;
  87934. /**
  87935. * Sets the stencil operation to use when stencil passes
  87936. * @param operation defines the stencil operation to use when stencil passes
  87937. */
  87938. setStencilOperationPass(operation: number): void;
  87939. /**
  87940. * Sets a boolean indicating if the dithering state is enabled or disabled
  87941. * @param value defines the dithering state
  87942. */
  87943. setDitheringState(value: boolean): void;
  87944. /**
  87945. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  87946. * @param value defines the rasterizer state
  87947. */
  87948. setRasterizerState(value: boolean): void;
  87949. /**
  87950. * stop executing a render loop function and remove it from the execution array
  87951. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  87952. */
  87953. stopRenderLoop(renderFunction?: () => void): void;
  87954. /** @hidden */
  87955. _renderLoop(): void;
  87956. /**
  87957. * Register and execute a render loop. The engine can have more than one render function
  87958. * @param renderFunction defines the function to continuously execute
  87959. */
  87960. runRenderLoop(renderFunction: () => void): void;
  87961. /**
  87962. * Toggle full screen mode
  87963. * @param requestPointerLock defines if a pointer lock should be requested from the user
  87964. */
  87965. switchFullscreen(requestPointerLock: boolean): void;
  87966. /**
  87967. * Enters full screen mode
  87968. * @param requestPointerLock defines if a pointer lock should be requested from the user
  87969. */
  87970. enterFullscreen(requestPointerLock: boolean): void;
  87971. /**
  87972. * Exits full screen mode
  87973. */
  87974. exitFullscreen(): void;
  87975. /**
  87976. * Clear the current render buffer or the current render target (if any is set up)
  87977. * @param color defines the color to use
  87978. * @param backBuffer defines if the back buffer must be cleared
  87979. * @param depth defines if the depth buffer must be cleared
  87980. * @param stencil defines if the stencil buffer must be cleared
  87981. */
  87982. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  87983. /**
  87984. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  87985. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  87986. * @param y defines the y-coordinate of the corner of the clear rectangle
  87987. * @param width defines the width of the clear rectangle
  87988. * @param height defines the height of the clear rectangle
  87989. * @param clearColor defines the clear color
  87990. */
  87991. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  87992. /**
  87993. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  87994. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  87995. * @param y defines the y-coordinate of the corner of the clear rectangle
  87996. * @param width defines the width of the clear rectangle
  87997. * @param height defines the height of the clear rectangle
  87998. */
  87999. enableScissor(x: number, y: number, width: number, height: number): void;
  88000. /**
  88001. * Disable previously set scissor test rectangle
  88002. */
  88003. disableScissor(): void;
  88004. private _viewportCached;
  88005. /** @hidden */
  88006. _viewport(x: number, y: number, width: number, height: number): void;
  88007. /**
  88008. * Set the WebGL's viewport
  88009. * @param viewport defines the viewport element to be used
  88010. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  88011. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  88012. */
  88013. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  88014. /**
  88015. * Directly set the WebGL Viewport
  88016. * @param x defines the x coordinate of the viewport (in screen space)
  88017. * @param y defines the y coordinate of the viewport (in screen space)
  88018. * @param width defines the width of the viewport (in screen space)
  88019. * @param height defines the height of the viewport (in screen space)
  88020. * @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
  88021. */
  88022. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  88023. /**
  88024. * Begin a new frame
  88025. */
  88026. beginFrame(): void;
  88027. /**
  88028. * Enf the current frame
  88029. */
  88030. endFrame(): void;
  88031. /**
  88032. * Resize the view according to the canvas' size
  88033. */
  88034. resize(): void;
  88035. /**
  88036. * Force a specific size of the canvas
  88037. * @param width defines the new canvas' width
  88038. * @param height defines the new canvas' height
  88039. */
  88040. setSize(width: number, height: number): void;
  88041. /**
  88042. * Binds the frame buffer to the specified texture.
  88043. * @param texture The texture to render to or null for the default canvas
  88044. * @param faceIndex The face of the texture to render to in case of cube texture
  88045. * @param requiredWidth The width of the target to render to
  88046. * @param requiredHeight The height of the target to render to
  88047. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  88048. * @param depthStencilTexture The depth stencil texture to use to render
  88049. * @param lodLevel defines le lod level to bind to the frame buffer
  88050. */
  88051. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  88052. /** @hidden */
  88053. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  88054. /**
  88055. * Unbind the current render target texture from the webGL context
  88056. * @param texture defines the render target texture to unbind
  88057. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  88058. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  88059. */
  88060. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  88061. /**
  88062. * Force the mipmap generation for the given render target texture
  88063. * @param texture defines the render target texture to use
  88064. */
  88065. generateMipMapsForCubemap(texture: InternalTexture): void;
  88066. /**
  88067. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  88068. */
  88069. flushFramebuffer(): void;
  88070. /**
  88071. * Unbind the current render target and bind the default framebuffer
  88072. */
  88073. restoreDefaultFramebuffer(): void;
  88074. /**
  88075. * Create an uniform buffer
  88076. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  88077. * @param elements defines the content of the uniform buffer
  88078. * @returns the webGL uniform buffer
  88079. */
  88080. createUniformBuffer(elements: FloatArray): DataBuffer;
  88081. /**
  88082. * Create a dynamic uniform buffer
  88083. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  88084. * @param elements defines the content of the uniform buffer
  88085. * @returns the webGL uniform buffer
  88086. */
  88087. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  88088. /**
  88089. * Update an existing uniform buffer
  88090. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  88091. * @param uniformBuffer defines the target uniform buffer
  88092. * @param elements defines the content to update
  88093. * @param offset defines the offset in the uniform buffer where update should start
  88094. * @param count defines the size of the data to update
  88095. */
  88096. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  88097. private _resetVertexBufferBinding;
  88098. /**
  88099. * Creates a vertex buffer
  88100. * @param data the data for the vertex buffer
  88101. * @returns the new WebGL static buffer
  88102. */
  88103. createVertexBuffer(data: DataArray): DataBuffer;
  88104. /**
  88105. * Creates a dynamic vertex buffer
  88106. * @param data the data for the dynamic vertex buffer
  88107. * @returns the new WebGL dynamic buffer
  88108. */
  88109. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  88110. /**
  88111. * Update a dynamic index buffer
  88112. * @param indexBuffer defines the target index buffer
  88113. * @param indices defines the data to update
  88114. * @param offset defines the offset in the target index buffer where update should start
  88115. */
  88116. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  88117. /**
  88118. * Updates a dynamic vertex buffer.
  88119. * @param vertexBuffer the vertex buffer to update
  88120. * @param data the data used to update the vertex buffer
  88121. * @param byteOffset the byte offset of the data
  88122. * @param byteLength the byte length of the data
  88123. */
  88124. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  88125. private _resetIndexBufferBinding;
  88126. /**
  88127. * Creates a new index buffer
  88128. * @param indices defines the content of the index buffer
  88129. * @param updatable defines if the index buffer must be updatable
  88130. * @returns a new webGL buffer
  88131. */
  88132. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  88133. /**
  88134. * Bind a webGL buffer to the webGL context
  88135. * @param buffer defines the buffer to bind
  88136. */
  88137. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  88138. /**
  88139. * Bind an uniform buffer to the current webGL context
  88140. * @param buffer defines the buffer to bind
  88141. */
  88142. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  88143. /**
  88144. * Bind a buffer to the current webGL context at a given location
  88145. * @param buffer defines the buffer to bind
  88146. * @param location defines the index where to bind the buffer
  88147. */
  88148. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  88149. /**
  88150. * Bind a specific block at a given index in a specific shader program
  88151. * @param pipelineContext defines the pipeline context to use
  88152. * @param blockName defines the block name
  88153. * @param index defines the index where to bind the block
  88154. */
  88155. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  88156. private bindIndexBuffer;
  88157. private bindBuffer;
  88158. /**
  88159. * update the bound buffer with the given data
  88160. * @param data defines the data to update
  88161. */
  88162. updateArrayBuffer(data: Float32Array): void;
  88163. private _vertexAttribPointer;
  88164. private _bindIndexBufferWithCache;
  88165. private _bindVertexBuffersAttributes;
  88166. /**
  88167. * Records a vertex array object
  88168. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  88169. * @param vertexBuffers defines the list of vertex buffers to store
  88170. * @param indexBuffer defines the index buffer to store
  88171. * @param effect defines the effect to store
  88172. * @returns the new vertex array object
  88173. */
  88174. recordVertexArrayObject(vertexBuffers: {
  88175. [key: string]: VertexBuffer;
  88176. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  88177. /**
  88178. * Bind a specific vertex array object
  88179. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  88180. * @param vertexArrayObject defines the vertex array object to bind
  88181. * @param indexBuffer defines the index buffer to bind
  88182. */
  88183. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  88184. /**
  88185. * Bind webGl buffers directly to the webGL context
  88186. * @param vertexBuffer defines the vertex buffer to bind
  88187. * @param indexBuffer defines the index buffer to bind
  88188. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  88189. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  88190. * @param effect defines the effect associated with the vertex buffer
  88191. */
  88192. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  88193. private _unbindVertexArrayObject;
  88194. /**
  88195. * Bind a list of vertex buffers to the webGL context
  88196. * @param vertexBuffers defines the list of vertex buffers to bind
  88197. * @param indexBuffer defines the index buffer to bind
  88198. * @param effect defines the effect associated with the vertex buffers
  88199. */
  88200. bindBuffers(vertexBuffers: {
  88201. [key: string]: Nullable<VertexBuffer>;
  88202. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  88203. /**
  88204. * Unbind all instance attributes
  88205. */
  88206. unbindInstanceAttributes(): void;
  88207. /**
  88208. * Release and free the memory of a vertex array object
  88209. * @param vao defines the vertex array object to delete
  88210. */
  88211. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  88212. /** @hidden */
  88213. _releaseBuffer(buffer: DataBuffer): boolean;
  88214. /**
  88215. * Creates a webGL buffer to use with instanciation
  88216. * @param capacity defines the size of the buffer
  88217. * @returns the webGL buffer
  88218. */
  88219. createInstancesBuffer(capacity: number): DataBuffer;
  88220. /**
  88221. * Delete a webGL buffer used with instanciation
  88222. * @param buffer defines the webGL buffer to delete
  88223. */
  88224. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  88225. /**
  88226. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  88227. * @param instancesBuffer defines the webGL buffer to update and bind
  88228. * @param data defines the data to store in the buffer
  88229. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  88230. */
  88231. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  88232. /**
  88233. * Apply all cached states (depth, culling, stencil and alpha)
  88234. */
  88235. applyStates(): void;
  88236. /**
  88237. * Send a draw order
  88238. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  88239. * @param indexStart defines the starting index
  88240. * @param indexCount defines the number of index to draw
  88241. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  88242. */
  88243. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  88244. /**
  88245. * Draw a list of points
  88246. * @param verticesStart defines the index of first vertex to draw
  88247. * @param verticesCount defines the count of vertices to draw
  88248. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  88249. */
  88250. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  88251. /**
  88252. * Draw a list of unindexed primitives
  88253. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  88254. * @param verticesStart defines the index of first vertex to draw
  88255. * @param verticesCount defines the count of vertices to draw
  88256. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  88257. */
  88258. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  88259. /**
  88260. * Draw a list of indexed primitives
  88261. * @param fillMode defines the primitive to use
  88262. * @param indexStart defines the starting index
  88263. * @param indexCount defines the number of index to draw
  88264. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  88265. */
  88266. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  88267. /**
  88268. * Draw a list of unindexed primitives
  88269. * @param fillMode defines the primitive to use
  88270. * @param verticesStart defines the index of first vertex to draw
  88271. * @param verticesCount defines the count of vertices to draw
  88272. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  88273. */
  88274. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  88275. private _drawMode;
  88276. /** @hidden */
  88277. _releaseEffect(effect: Effect): void;
  88278. /** @hidden */
  88279. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  88280. /**
  88281. * Create a new effect (used to store vertex/fragment shaders)
  88282. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  88283. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  88284. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  88285. * @param samplers defines an array of string used to represent textures
  88286. * @param defines defines the string containing the defines to use to compile the shaders
  88287. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  88288. * @param onCompiled defines a function to call when the effect creation is successful
  88289. * @param onError defines a function to call when the effect creation has failed
  88290. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  88291. * @returns the new Effect
  88292. */
  88293. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  88294. private _compileShader;
  88295. private _compileRawShader;
  88296. /**
  88297. * Directly creates a webGL program
  88298. * @param pipelineContext defines the pipeline context to attach to
  88299. * @param vertexCode defines the vertex shader code to use
  88300. * @param fragmentCode defines the fragment shader code to use
  88301. * @param context defines the webGL context to use (if not set, the current one will be used)
  88302. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  88303. * @returns the new webGL program
  88304. */
  88305. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  88306. /**
  88307. * Creates a webGL program
  88308. * @param pipelineContext defines the pipeline context to attach to
  88309. * @param vertexCode defines the vertex shader code to use
  88310. * @param fragmentCode defines the fragment shader code to use
  88311. * @param defines defines the string containing the defines to use to compile the shaders
  88312. * @param context defines the webGL context to use (if not set, the current one will be used)
  88313. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  88314. * @returns the new webGL program
  88315. */
  88316. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  88317. /**
  88318. * Creates a new pipeline context
  88319. * @returns the new pipeline
  88320. */
  88321. createPipelineContext(): WebGLPipelineContext;
  88322. private _createShaderProgram;
  88323. private _finalizePipelineContext;
  88324. /** @hidden */
  88325. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  88326. /** @hidden */
  88327. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  88328. /** @hidden */
  88329. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  88330. /**
  88331. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  88332. * @param pipelineContext defines the pipeline context to use
  88333. * @param uniformsNames defines the list of uniform names
  88334. * @returns an array of webGL uniform locations
  88335. */
  88336. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  88337. /**
  88338. * Gets the lsit of active attributes for a given webGL program
  88339. * @param pipelineContext defines the pipeline context to use
  88340. * @param attributesNames defines the list of attribute names to get
  88341. * @returns an array of indices indicating the offset of each attribute
  88342. */
  88343. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  88344. /**
  88345. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  88346. * @param effect defines the effect to activate
  88347. */
  88348. enableEffect(effect: Nullable<Effect>): void;
  88349. /**
  88350. * Set the value of an uniform to an array of int32
  88351. * @param uniform defines the webGL uniform location where to store the value
  88352. * @param array defines the array of int32 to store
  88353. */
  88354. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  88355. /**
  88356. * Set the value of an uniform to an array of int32 (stored as vec2)
  88357. * @param uniform defines the webGL uniform location where to store the value
  88358. * @param array defines the array of int32 to store
  88359. */
  88360. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  88361. /**
  88362. * Set the value of an uniform to an array of int32 (stored as vec3)
  88363. * @param uniform defines the webGL uniform location where to store the value
  88364. * @param array defines the array of int32 to store
  88365. */
  88366. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  88367. /**
  88368. * Set the value of an uniform to an array of int32 (stored as vec4)
  88369. * @param uniform defines the webGL uniform location where to store the value
  88370. * @param array defines the array of int32 to store
  88371. */
  88372. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  88373. /**
  88374. * Set the value of an uniform to an array of float32
  88375. * @param uniform defines the webGL uniform location where to store the value
  88376. * @param array defines the array of float32 to store
  88377. */
  88378. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  88379. /**
  88380. * Set the value of an uniform to an array of float32 (stored as vec2)
  88381. * @param uniform defines the webGL uniform location where to store the value
  88382. * @param array defines the array of float32 to store
  88383. */
  88384. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  88385. /**
  88386. * Set the value of an uniform to an array of float32 (stored as vec3)
  88387. * @param uniform defines the webGL uniform location where to store the value
  88388. * @param array defines the array of float32 to store
  88389. */
  88390. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  88391. /**
  88392. * Set the value of an uniform to an array of float32 (stored as vec4)
  88393. * @param uniform defines the webGL uniform location where to store the value
  88394. * @param array defines the array of float32 to store
  88395. */
  88396. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  88397. /**
  88398. * Set the value of an uniform to an array of number
  88399. * @param uniform defines the webGL uniform location where to store the value
  88400. * @param array defines the array of number to store
  88401. */
  88402. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  88403. /**
  88404. * Set the value of an uniform to an array of number (stored as vec2)
  88405. * @param uniform defines the webGL uniform location where to store the value
  88406. * @param array defines the array of number to store
  88407. */
  88408. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  88409. /**
  88410. * Set the value of an uniform to an array of number (stored as vec3)
  88411. * @param uniform defines the webGL uniform location where to store the value
  88412. * @param array defines the array of number to store
  88413. */
  88414. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  88415. /**
  88416. * Set the value of an uniform to an array of number (stored as vec4)
  88417. * @param uniform defines the webGL uniform location where to store the value
  88418. * @param array defines the array of number to store
  88419. */
  88420. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  88421. /**
  88422. * Set the value of an uniform to an array of float32 (stored as matrices)
  88423. * @param uniform defines the webGL uniform location where to store the value
  88424. * @param matrices defines the array of float32 to store
  88425. */
  88426. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  88427. /**
  88428. * Set the value of an uniform to a matrix
  88429. * @param uniform defines the webGL uniform location where to store the value
  88430. * @param matrix defines the matrix to store
  88431. */
  88432. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  88433. /**
  88434. * Set the value of an uniform to a matrix (3x3)
  88435. * @param uniform defines the webGL uniform location where to store the value
  88436. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  88437. */
  88438. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  88439. /**
  88440. * Set the value of an uniform to a matrix (2x2)
  88441. * @param uniform defines the webGL uniform location where to store the value
  88442. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  88443. */
  88444. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  88445. /**
  88446. * Set the value of an uniform to a number (int)
  88447. * @param uniform defines the webGL uniform location where to store the value
  88448. * @param value defines the int number to store
  88449. */
  88450. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  88451. /**
  88452. * Set the value of an uniform to a number (float)
  88453. * @param uniform defines the webGL uniform location where to store the value
  88454. * @param value defines the float number to store
  88455. */
  88456. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  88457. /**
  88458. * Set the value of an uniform to a vec2
  88459. * @param uniform defines the webGL uniform location where to store the value
  88460. * @param x defines the 1st component of the value
  88461. * @param y defines the 2nd component of the value
  88462. */
  88463. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  88464. /**
  88465. * Set the value of an uniform to a vec3
  88466. * @param uniform defines the webGL uniform location where to store the value
  88467. * @param x defines the 1st component of the value
  88468. * @param y defines the 2nd component of the value
  88469. * @param z defines the 3rd component of the value
  88470. */
  88471. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  88472. /**
  88473. * Set the value of an uniform to a boolean
  88474. * @param uniform defines the webGL uniform location where to store the value
  88475. * @param bool defines the boolean to store
  88476. */
  88477. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  88478. /**
  88479. * Set the value of an uniform to a vec4
  88480. * @param uniform defines the webGL uniform location where to store the value
  88481. * @param x defines the 1st component of the value
  88482. * @param y defines the 2nd component of the value
  88483. * @param z defines the 3rd component of the value
  88484. * @param w defines the 4th component of the value
  88485. */
  88486. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  88487. /**
  88488. * Set the value of an uniform to a Color3
  88489. * @param uniform defines the webGL uniform location where to store the value
  88490. * @param color3 defines the color to store
  88491. */
  88492. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  88493. /**
  88494. * Set the value of an uniform to a Color3 and an alpha value
  88495. * @param uniform defines the webGL uniform location where to store the value
  88496. * @param color3 defines the color to store
  88497. * @param alpha defines the alpha component to store
  88498. */
  88499. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  88500. /**
  88501. * Sets a Color4 on a uniform variable
  88502. * @param uniform defines the uniform location
  88503. * @param color4 defines the value to be set
  88504. */
  88505. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  88506. /**
  88507. * Set various states to the webGL context
  88508. * @param culling defines backface culling state
  88509. * @param zOffset defines the value to apply to zOffset (0 by default)
  88510. * @param force defines if states must be applied even if cache is up to date
  88511. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  88512. */
  88513. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  88514. /**
  88515. * Set the z offset to apply to current rendering
  88516. * @param value defines the offset to apply
  88517. */
  88518. setZOffset(value: number): void;
  88519. /**
  88520. * Gets the current value of the zOffset
  88521. * @returns the current zOffset state
  88522. */
  88523. getZOffset(): number;
  88524. /**
  88525. * Enable or disable depth buffering
  88526. * @param enable defines the state to set
  88527. */
  88528. setDepthBuffer(enable: boolean): void;
  88529. /**
  88530. * Gets a boolean indicating if depth writing is enabled
  88531. * @returns the current depth writing state
  88532. */
  88533. getDepthWrite(): boolean;
  88534. /**
  88535. * Enable or disable depth writing
  88536. * @param enable defines the state to set
  88537. */
  88538. setDepthWrite(enable: boolean): void;
  88539. /**
  88540. * Enable or disable color writing
  88541. * @param enable defines the state to set
  88542. */
  88543. setColorWrite(enable: boolean): void;
  88544. /**
  88545. * Gets a boolean indicating if color writing is enabled
  88546. * @returns the current color writing state
  88547. */
  88548. getColorWrite(): boolean;
  88549. /**
  88550. * Sets alpha constants used by some alpha blending modes
  88551. * @param r defines the red component
  88552. * @param g defines the green component
  88553. * @param b defines the blue component
  88554. * @param a defines the alpha component
  88555. */
  88556. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  88557. /**
  88558. * Sets the current alpha mode
  88559. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  88560. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  88561. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  88562. */
  88563. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  88564. /**
  88565. * Gets the current alpha mode
  88566. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  88567. * @returns the current alpha mode
  88568. */
  88569. getAlphaMode(): number;
  88570. /**
  88571. * Clears the list of texture accessible through engine.
  88572. * This can help preventing texture load conflict due to name collision.
  88573. */
  88574. clearInternalTexturesCache(): void;
  88575. /**
  88576. * Force the entire cache to be cleared
  88577. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  88578. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  88579. */
  88580. wipeCaches(bruteForce?: boolean): void;
  88581. /**
  88582. * Set the compressed texture format to use, based on the formats you have, and the formats
  88583. * supported by the hardware / browser.
  88584. *
  88585. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  88586. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  88587. * to API arguments needed to compressed textures. This puts the burden on the container
  88588. * generator to house the arcane code for determining these for current & future formats.
  88589. *
  88590. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  88591. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  88592. *
  88593. * Note: The result of this call is not taken into account when a texture is base64.
  88594. *
  88595. * @param formatsAvailable defines the list of those format families you have created
  88596. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  88597. *
  88598. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  88599. * @returns The extension selected.
  88600. */
  88601. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  88602. /** @hidden */
  88603. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  88604. min: number;
  88605. mag: number;
  88606. };
  88607. /** @hidden */
  88608. _createTexture(): WebGLTexture;
  88609. /**
  88610. * Usually called from Texture.ts.
  88611. * Passed information to create a WebGLTexture
  88612. * @param urlArg defines a value which contains one of the following:
  88613. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  88614. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  88615. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  88616. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  88617. * @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)
  88618. * @param scene needed for loading to the correct scene
  88619. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  88620. * @param onLoad optional callback to be called upon successful completion
  88621. * @param onError optional callback to be called upon failure
  88622. * @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
  88623. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  88624. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  88625. * @param forcedExtension defines the extension to use to pick the right loader
  88626. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  88627. * @returns a InternalTexture for assignment back into BABYLON.Texture
  88628. */
  88629. 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;
  88630. private _rescaleTexture;
  88631. private _unpackFlipYCached;
  88632. /**
  88633. * In case you are sharing the context with other applications, it might
  88634. * be interested to not cache the unpack flip y state to ensure a consistent
  88635. * value would be set.
  88636. */
  88637. enableUnpackFlipYCached: boolean;
  88638. /** @hidden */
  88639. _unpackFlipY(value: boolean): void;
  88640. /** @hidden */
  88641. _getUnpackAlignement(): number;
  88642. /**
  88643. * Creates a dynamic texture
  88644. * @param width defines the width of the texture
  88645. * @param height defines the height of the texture
  88646. * @param generateMipMaps defines if the engine should generate the mip levels
  88647. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  88648. * @returns the dynamic texture inside an InternalTexture
  88649. */
  88650. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  88651. /**
  88652. * Update the sampling mode of a given texture
  88653. * @param samplingMode defines the required sampling mode
  88654. * @param texture defines the texture to update
  88655. */
  88656. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  88657. /**
  88658. * Update the content of a dynamic texture
  88659. * @param texture defines the texture to update
  88660. * @param canvas defines the canvas containing the source
  88661. * @param invertY defines if data must be stored with Y axis inverted
  88662. * @param premulAlpha defines if alpha is stored as premultiplied
  88663. * @param format defines the format of the data
  88664. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  88665. */
  88666. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  88667. /**
  88668. * Update a video texture
  88669. * @param texture defines the texture to update
  88670. * @param video defines the video element to use
  88671. * @param invertY defines if data must be stored with Y axis inverted
  88672. */
  88673. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  88674. /**
  88675. * Updates a depth texture Comparison Mode and Function.
  88676. * If the comparison Function is equal to 0, the mode will be set to none.
  88677. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  88678. * @param texture The texture to set the comparison function for
  88679. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  88680. */
  88681. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  88682. /** @hidden */
  88683. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  88684. width: number;
  88685. height: number;
  88686. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  88687. /**
  88688. * Creates a depth stencil texture.
  88689. * This is only available in WebGL 2 or with the depth texture extension available.
  88690. * @param size The size of face edge in the texture.
  88691. * @param options The options defining the texture.
  88692. * @returns The texture
  88693. */
  88694. createDepthStencilTexture(size: number | {
  88695. width: number;
  88696. height: number;
  88697. }, options: DepthTextureCreationOptions): InternalTexture;
  88698. /**
  88699. * Creates a depth stencil texture.
  88700. * This is only available in WebGL 2 or with the depth texture extension available.
  88701. * @param size The size of face edge in the texture.
  88702. * @param options The options defining the texture.
  88703. * @returns The texture
  88704. */
  88705. private _createDepthStencilTexture;
  88706. /**
  88707. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  88708. * @param renderTarget The render target to set the frame buffer for
  88709. */
  88710. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  88711. /**
  88712. * Creates a new render target texture
  88713. * @param size defines the size of the texture
  88714. * @param options defines the options used to create the texture
  88715. * @returns a new render target texture stored in an InternalTexture
  88716. */
  88717. createRenderTargetTexture(size: number | {
  88718. width: number;
  88719. height: number;
  88720. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  88721. /** @hidden */
  88722. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  88723. /**
  88724. * Updates the sample count of a render target texture
  88725. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  88726. * @param texture defines the texture to update
  88727. * @param samples defines the sample count to set
  88728. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  88729. */
  88730. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  88731. /** @hidden */
  88732. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  88733. /** @hidden */
  88734. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  88735. /** @hidden */
  88736. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  88737. /** @hidden */
  88738. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  88739. /**
  88740. * @hidden
  88741. */
  88742. _setCubeMapTextureParams(loadMipmap: boolean): void;
  88743. private _prepareWebGLTextureContinuation;
  88744. private _prepareWebGLTexture;
  88745. /** @hidden */
  88746. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  88747. /** @hidden */
  88748. _releaseFramebufferObjects(texture: InternalTexture): void;
  88749. /** @hidden */
  88750. _releaseTexture(texture: InternalTexture): void;
  88751. private setProgram;
  88752. private _boundUniforms;
  88753. /**
  88754. * Binds an effect to the webGL context
  88755. * @param effect defines the effect to bind
  88756. */
  88757. bindSamplers(effect: Effect): void;
  88758. private _activateCurrentTexture;
  88759. /** @hidden */
  88760. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  88761. /** @hidden */
  88762. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  88763. /**
  88764. * Sets a texture to the webGL context from a postprocess
  88765. * @param channel defines the channel to use
  88766. * @param postProcess defines the source postprocess
  88767. */
  88768. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  88769. /**
  88770. * Binds the output of the passed in post process to the texture channel specified
  88771. * @param channel The channel the texture should be bound to
  88772. * @param postProcess The post process which's output should be bound
  88773. */
  88774. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  88775. /**
  88776. * Unbind all textures from the webGL context
  88777. */
  88778. unbindAllTextures(): void;
  88779. /**
  88780. * Sets a texture to the according uniform.
  88781. * @param channel The texture channel
  88782. * @param uniform The uniform to set
  88783. * @param texture The texture to apply
  88784. */
  88785. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  88786. /**
  88787. * Sets a depth stencil texture from a render target to the according uniform.
  88788. * @param channel The texture channel
  88789. * @param uniform The uniform to set
  88790. * @param texture The render target texture containing the depth stencil texture to apply
  88791. */
  88792. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  88793. private _bindSamplerUniformToChannel;
  88794. private _getTextureWrapMode;
  88795. private _setTexture;
  88796. /**
  88797. * Sets an array of texture to the webGL context
  88798. * @param channel defines the channel where the texture array must be set
  88799. * @param uniform defines the associated uniform location
  88800. * @param textures defines the array of textures to bind
  88801. */
  88802. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  88803. /** @hidden */
  88804. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  88805. private _setTextureParameterFloat;
  88806. private _setTextureParameterInteger;
  88807. /**
  88808. * Reads pixels from the current frame buffer. Please note that this function can be slow
  88809. * @param x defines the x coordinate of the rectangle where pixels must be read
  88810. * @param y defines the y coordinate of the rectangle where pixels must be read
  88811. * @param width defines the width of the rectangle where pixels must be read
  88812. * @param height defines the height of the rectangle where pixels must be read
  88813. * @returns a Uint8Array containing RGBA colors
  88814. */
  88815. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  88816. /**
  88817. * Add an externaly attached data from its key.
  88818. * This method call will fail and return false, if such key already exists.
  88819. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  88820. * @param key the unique key that identifies the data
  88821. * @param data the data object to associate to the key for this Engine instance
  88822. * @return true if no such key were already present and the data was added successfully, false otherwise
  88823. */
  88824. addExternalData<T>(key: string, data: T): boolean;
  88825. /**
  88826. * Get an externaly attached data from its key
  88827. * @param key the unique key that identifies the data
  88828. * @return the associated data, if present (can be null), or undefined if not present
  88829. */
  88830. getExternalData<T>(key: string): T;
  88831. /**
  88832. * Get an externaly attached data from its key, create it using a factory if it's not already present
  88833. * @param key the unique key that identifies the data
  88834. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  88835. * @return the associated data, can be null if the factory returned null.
  88836. */
  88837. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  88838. /**
  88839. * Remove an externaly attached data from the Engine instance
  88840. * @param key the unique key that identifies the data
  88841. * @return true if the data was successfully removed, false if it doesn't exist
  88842. */
  88843. removeExternalData(key: string): boolean;
  88844. /**
  88845. * Unbind all vertex attributes from the webGL context
  88846. */
  88847. unbindAllAttributes(): void;
  88848. /**
  88849. * 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
  88850. */
  88851. releaseEffects(): void;
  88852. /**
  88853. * Dispose and release all associated resources
  88854. */
  88855. dispose(): void;
  88856. /**
  88857. * Display the loading screen
  88858. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88859. */
  88860. displayLoadingUI(): void;
  88861. /**
  88862. * Hide the loading screen
  88863. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88864. */
  88865. hideLoadingUI(): void;
  88866. /**
  88867. * Gets the current loading screen object
  88868. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88869. */
  88870. /**
  88871. * Sets the current loading screen object
  88872. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88873. */
  88874. loadingScreen: ILoadingScreen;
  88875. /**
  88876. * Sets the current loading screen text
  88877. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88878. */
  88879. loadingUIText: string;
  88880. /**
  88881. * Sets the current loading screen background color
  88882. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88883. */
  88884. loadingUIBackgroundColor: string;
  88885. /**
  88886. * Attach a new callback raised when context lost event is fired
  88887. * @param callback defines the callback to call
  88888. */
  88889. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  88890. /**
  88891. * Attach a new callback raised when context restored event is fired
  88892. * @param callback defines the callback to call
  88893. */
  88894. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  88895. /**
  88896. * Gets the source code of the vertex shader associated with a specific webGL program
  88897. * @param program defines the program to use
  88898. * @returns a string containing the source code of the vertex shader associated with the program
  88899. */
  88900. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  88901. /**
  88902. * Gets the source code of the fragment shader associated with a specific webGL program
  88903. * @param program defines the program to use
  88904. * @returns a string containing the source code of the fragment shader associated with the program
  88905. */
  88906. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  88907. /**
  88908. * Get the current error code of the webGL context
  88909. * @returns the error code
  88910. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  88911. */
  88912. getError(): number;
  88913. /**
  88914. * Gets the current framerate
  88915. * @returns a number representing the framerate
  88916. */
  88917. getFps(): number;
  88918. /**
  88919. * Gets the time spent between current and previous frame
  88920. * @returns a number representing the delta time in ms
  88921. */
  88922. getDeltaTime(): number;
  88923. private _measureFps;
  88924. /** @hidden */
  88925. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  88926. private _canRenderToFloatFramebuffer;
  88927. private _canRenderToHalfFloatFramebuffer;
  88928. private _canRenderToFramebuffer;
  88929. /** @hidden */
  88930. _getWebGLTextureType(type: number): number;
  88931. /** @hidden */
  88932. _getInternalFormat(format: number): number;
  88933. /** @hidden */
  88934. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  88935. /** @hidden */
  88936. _getRGBAMultiSampleBufferFormat(type: number): number;
  88937. /** @hidden */
  88938. _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;
  88939. /** @hidden */
  88940. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  88941. /**
  88942. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  88943. * @returns true if the engine can be created
  88944. * @ignorenaming
  88945. */
  88946. static isSupported(): boolean;
  88947. }
  88948. }
  88949. declare module BABYLON {
  88950. /**
  88951. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  88952. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  88953. */
  88954. export class EffectFallbacks {
  88955. private _defines;
  88956. private _currentRank;
  88957. private _maxRank;
  88958. private _mesh;
  88959. /**
  88960. * Removes the fallback from the bound mesh.
  88961. */
  88962. unBindMesh(): void;
  88963. /**
  88964. * Adds a fallback on the specified property.
  88965. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  88966. * @param define The name of the define in the shader
  88967. */
  88968. addFallback(rank: number, define: string): void;
  88969. /**
  88970. * Sets the mesh to use CPU skinning when needing to fallback.
  88971. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  88972. * @param mesh The mesh to use the fallbacks.
  88973. */
  88974. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  88975. /**
  88976. * Checks to see if more fallbacks are still availible.
  88977. */
  88978. readonly isMoreFallbacks: boolean;
  88979. /**
  88980. * Removes the defines that shoould be removed when falling back.
  88981. * @param currentDefines defines the current define statements for the shader.
  88982. * @param effect defines the current effect we try to compile
  88983. * @returns The resulting defines with defines of the current rank removed.
  88984. */
  88985. reduce(currentDefines: string, effect: Effect): string;
  88986. }
  88987. /**
  88988. * Options to be used when creating an effect.
  88989. */
  88990. export class EffectCreationOptions {
  88991. /**
  88992. * Atrributes that will be used in the shader.
  88993. */
  88994. attributes: string[];
  88995. /**
  88996. * Uniform varible names that will be set in the shader.
  88997. */
  88998. uniformsNames: string[];
  88999. /**
  89000. * Uniform buffer varible names that will be set in the shader.
  89001. */
  89002. uniformBuffersNames: string[];
  89003. /**
  89004. * Sampler texture variable names that will be set in the shader.
  89005. */
  89006. samplers: string[];
  89007. /**
  89008. * Define statements that will be set in the shader.
  89009. */
  89010. defines: any;
  89011. /**
  89012. * Possible fallbacks for this effect to improve performance when needed.
  89013. */
  89014. fallbacks: Nullable<EffectFallbacks>;
  89015. /**
  89016. * Callback that will be called when the shader is compiled.
  89017. */
  89018. onCompiled: Nullable<(effect: Effect) => void>;
  89019. /**
  89020. * Callback that will be called if an error occurs during shader compilation.
  89021. */
  89022. onError: Nullable<(effect: Effect, errors: string) => void>;
  89023. /**
  89024. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  89025. */
  89026. indexParameters: any;
  89027. /**
  89028. * Max number of lights that can be used in the shader.
  89029. */
  89030. maxSimultaneousLights: number;
  89031. /**
  89032. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  89033. */
  89034. transformFeedbackVaryings: Nullable<string[]>;
  89035. }
  89036. /**
  89037. * Effect containing vertex and fragment shader that can be executed on an object.
  89038. */
  89039. export class Effect implements IDisposable {
  89040. /**
  89041. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  89042. */
  89043. static ShadersRepository: string;
  89044. /**
  89045. * Name of the effect.
  89046. */
  89047. name: any;
  89048. /**
  89049. * String container all the define statements that should be set on the shader.
  89050. */
  89051. defines: string;
  89052. /**
  89053. * Callback that will be called when the shader is compiled.
  89054. */
  89055. onCompiled: Nullable<(effect: Effect) => void>;
  89056. /**
  89057. * Callback that will be called if an error occurs during shader compilation.
  89058. */
  89059. onError: Nullable<(effect: Effect, errors: string) => void>;
  89060. /**
  89061. * Callback that will be called when effect is bound.
  89062. */
  89063. onBind: Nullable<(effect: Effect) => void>;
  89064. /**
  89065. * Unique ID of the effect.
  89066. */
  89067. uniqueId: number;
  89068. /**
  89069. * Observable that will be called when the shader is compiled.
  89070. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  89071. */
  89072. onCompileObservable: Observable<Effect>;
  89073. /**
  89074. * Observable that will be called if an error occurs during shader compilation.
  89075. */
  89076. onErrorObservable: Observable<Effect>;
  89077. /** @hidden */
  89078. _onBindObservable: Nullable<Observable<Effect>>;
  89079. /**
  89080. * Observable that will be called when effect is bound.
  89081. */
  89082. readonly onBindObservable: Observable<Effect>;
  89083. /** @hidden */
  89084. _bonesComputationForcedToCPU: boolean;
  89085. private static _uniqueIdSeed;
  89086. private _engine;
  89087. private _uniformBuffersNames;
  89088. private _uniformsNames;
  89089. private _samplerList;
  89090. private _samplers;
  89091. private _isReady;
  89092. private _compilationError;
  89093. private _attributesNames;
  89094. private _attributes;
  89095. private _uniforms;
  89096. /**
  89097. * Key for the effect.
  89098. * @hidden
  89099. */
  89100. _key: string;
  89101. private _indexParameters;
  89102. private _fallbacks;
  89103. private _vertexSourceCode;
  89104. private _fragmentSourceCode;
  89105. private _vertexSourceCodeOverride;
  89106. private _fragmentSourceCodeOverride;
  89107. private _transformFeedbackVaryings;
  89108. /**
  89109. * Compiled shader to webGL program.
  89110. * @hidden
  89111. */
  89112. _pipelineContext: Nullable<IPipelineContext>;
  89113. private _valueCache;
  89114. private static _baseCache;
  89115. /**
  89116. * Instantiates an effect.
  89117. * An effect can be used to create/manage/execute vertex and fragment shaders.
  89118. * @param baseName Name of the effect.
  89119. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  89120. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  89121. * @param samplers List of sampler variables that will be passed to the shader.
  89122. * @param engine Engine to be used to render the effect
  89123. * @param defines Define statements to be added to the shader.
  89124. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  89125. * @param onCompiled Callback that will be called when the shader is compiled.
  89126. * @param onError Callback that will be called if an error occurs during shader compilation.
  89127. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  89128. */
  89129. 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);
  89130. /**
  89131. * Unique key for this effect
  89132. */
  89133. readonly key: string;
  89134. /**
  89135. * If the effect has been compiled and prepared.
  89136. * @returns if the effect is compiled and prepared.
  89137. */
  89138. isReady(): boolean;
  89139. /**
  89140. * The engine the effect was initialized with.
  89141. * @returns the engine.
  89142. */
  89143. getEngine(): Engine;
  89144. /**
  89145. * The pipeline context for this effect
  89146. * @returns the associated pipeline context
  89147. */
  89148. getPipelineContext(): Nullable<IPipelineContext>;
  89149. /**
  89150. * The set of names of attribute variables for the shader.
  89151. * @returns An array of attribute names.
  89152. */
  89153. getAttributesNames(): string[];
  89154. /**
  89155. * Returns the attribute at the given index.
  89156. * @param index The index of the attribute.
  89157. * @returns The location of the attribute.
  89158. */
  89159. getAttributeLocation(index: number): number;
  89160. /**
  89161. * Returns the attribute based on the name of the variable.
  89162. * @param name of the attribute to look up.
  89163. * @returns the attribute location.
  89164. */
  89165. getAttributeLocationByName(name: string): number;
  89166. /**
  89167. * The number of attributes.
  89168. * @returns the numnber of attributes.
  89169. */
  89170. getAttributesCount(): number;
  89171. /**
  89172. * Gets the index of a uniform variable.
  89173. * @param uniformName of the uniform to look up.
  89174. * @returns the index.
  89175. */
  89176. getUniformIndex(uniformName: string): number;
  89177. /**
  89178. * Returns the attribute based on the name of the variable.
  89179. * @param uniformName of the uniform to look up.
  89180. * @returns the location of the uniform.
  89181. */
  89182. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  89183. /**
  89184. * Returns an array of sampler variable names
  89185. * @returns The array of sampler variable neames.
  89186. */
  89187. getSamplers(): string[];
  89188. /**
  89189. * The error from the last compilation.
  89190. * @returns the error string.
  89191. */
  89192. getCompilationError(): string;
  89193. /**
  89194. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  89195. * @param func The callback to be used.
  89196. */
  89197. executeWhenCompiled(func: (effect: Effect) => void): void;
  89198. private _checkIsReady;
  89199. /** @hidden */
  89200. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  89201. /** @hidden */
  89202. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  89203. /** @hidden */
  89204. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  89205. private _processShaderConversion;
  89206. private _processIncludes;
  89207. private _processPrecision;
  89208. /**
  89209. * Recompiles the webGL program
  89210. * @param vertexSourceCode The source code for the vertex shader.
  89211. * @param fragmentSourceCode The source code for the fragment shader.
  89212. * @param onCompiled Callback called when completed.
  89213. * @param onError Callback called on error.
  89214. * @hidden
  89215. */
  89216. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  89217. /**
  89218. * Prepares the effect
  89219. * @hidden
  89220. */
  89221. _prepareEffect(): void;
  89222. /**
  89223. * Checks if the effect is supported. (Must be called after compilation)
  89224. */
  89225. readonly isSupported: boolean;
  89226. /**
  89227. * Binds a texture to the engine to be used as output of the shader.
  89228. * @param channel Name of the output variable.
  89229. * @param texture Texture to bind.
  89230. * @hidden
  89231. */
  89232. _bindTexture(channel: string, texture: InternalTexture): void;
  89233. /**
  89234. * Sets a texture on the engine to be used in the shader.
  89235. * @param channel Name of the sampler variable.
  89236. * @param texture Texture to set.
  89237. */
  89238. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  89239. /**
  89240. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  89241. * @param channel Name of the sampler variable.
  89242. * @param texture Texture to set.
  89243. */
  89244. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  89245. /**
  89246. * Sets an array of textures on the engine to be used in the shader.
  89247. * @param channel Name of the variable.
  89248. * @param textures Textures to set.
  89249. */
  89250. setTextureArray(channel: string, textures: BaseTexture[]): void;
  89251. /**
  89252. * 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)
  89253. * @param channel Name of the sampler variable.
  89254. * @param postProcess Post process to get the input texture from.
  89255. */
  89256. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  89257. /**
  89258. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  89259. * 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)
  89260. * @param channel Name of the sampler variable.
  89261. * @param postProcess Post process to get the output texture from.
  89262. */
  89263. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  89264. /** @hidden */
  89265. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  89266. /** @hidden */
  89267. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  89268. /** @hidden */
  89269. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  89270. /** @hidden */
  89271. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  89272. /**
  89273. * Binds a buffer to a uniform.
  89274. * @param buffer Buffer to bind.
  89275. * @param name Name of the uniform variable to bind to.
  89276. */
  89277. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  89278. /**
  89279. * Binds block to a uniform.
  89280. * @param blockName Name of the block to bind.
  89281. * @param index Index to bind.
  89282. */
  89283. bindUniformBlock(blockName: string, index: number): void;
  89284. /**
  89285. * Sets an interger value on a uniform variable.
  89286. * @param uniformName Name of the variable.
  89287. * @param value Value to be set.
  89288. * @returns this effect.
  89289. */
  89290. setInt(uniformName: string, value: number): Effect;
  89291. /**
  89292. * Sets an int array on a uniform variable.
  89293. * @param uniformName Name of the variable.
  89294. * @param array array to be set.
  89295. * @returns this effect.
  89296. */
  89297. setIntArray(uniformName: string, array: Int32Array): Effect;
  89298. /**
  89299. * 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)
  89300. * @param uniformName Name of the variable.
  89301. * @param array array to be set.
  89302. * @returns this effect.
  89303. */
  89304. setIntArray2(uniformName: string, array: Int32Array): Effect;
  89305. /**
  89306. * 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)
  89307. * @param uniformName Name of the variable.
  89308. * @param array array to be set.
  89309. * @returns this effect.
  89310. */
  89311. setIntArray3(uniformName: string, array: Int32Array): Effect;
  89312. /**
  89313. * 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)
  89314. * @param uniformName Name of the variable.
  89315. * @param array array to be set.
  89316. * @returns this effect.
  89317. */
  89318. setIntArray4(uniformName: string, array: Int32Array): Effect;
  89319. /**
  89320. * Sets an float array on a uniform variable.
  89321. * @param uniformName Name of the variable.
  89322. * @param array array to be set.
  89323. * @returns this effect.
  89324. */
  89325. setFloatArray(uniformName: string, array: Float32Array): Effect;
  89326. /**
  89327. * 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)
  89328. * @param uniformName Name of the variable.
  89329. * @param array array to be set.
  89330. * @returns this effect.
  89331. */
  89332. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  89333. /**
  89334. * 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)
  89335. * @param uniformName Name of the variable.
  89336. * @param array array to be set.
  89337. * @returns this effect.
  89338. */
  89339. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  89340. /**
  89341. * 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)
  89342. * @param uniformName Name of the variable.
  89343. * @param array array to be set.
  89344. * @returns this effect.
  89345. */
  89346. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  89347. /**
  89348. * Sets an array on a uniform variable.
  89349. * @param uniformName Name of the variable.
  89350. * @param array array to be set.
  89351. * @returns this effect.
  89352. */
  89353. setArray(uniformName: string, array: number[]): Effect;
  89354. /**
  89355. * 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)
  89356. * @param uniformName Name of the variable.
  89357. * @param array array to be set.
  89358. * @returns this effect.
  89359. */
  89360. setArray2(uniformName: string, array: number[]): Effect;
  89361. /**
  89362. * 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)
  89363. * @param uniformName Name of the variable.
  89364. * @param array array to be set.
  89365. * @returns this effect.
  89366. */
  89367. setArray3(uniformName: string, array: number[]): Effect;
  89368. /**
  89369. * 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)
  89370. * @param uniformName Name of the variable.
  89371. * @param array array to be set.
  89372. * @returns this effect.
  89373. */
  89374. setArray4(uniformName: string, array: number[]): Effect;
  89375. /**
  89376. * Sets matrices on a uniform variable.
  89377. * @param uniformName Name of the variable.
  89378. * @param matrices matrices to be set.
  89379. * @returns this effect.
  89380. */
  89381. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  89382. /**
  89383. * Sets matrix on a uniform variable.
  89384. * @param uniformName Name of the variable.
  89385. * @param matrix matrix to be set.
  89386. * @returns this effect.
  89387. */
  89388. setMatrix(uniformName: string, matrix: Matrix): Effect;
  89389. /**
  89390. * 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)
  89391. * @param uniformName Name of the variable.
  89392. * @param matrix matrix to be set.
  89393. * @returns this effect.
  89394. */
  89395. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  89396. /**
  89397. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  89398. * @param uniformName Name of the variable.
  89399. * @param matrix matrix to be set.
  89400. * @returns this effect.
  89401. */
  89402. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  89403. /**
  89404. * Sets a float on a uniform variable.
  89405. * @param uniformName Name of the variable.
  89406. * @param value value to be set.
  89407. * @returns this effect.
  89408. */
  89409. setFloat(uniformName: string, value: number): Effect;
  89410. /**
  89411. * Sets a boolean on a uniform variable.
  89412. * @param uniformName Name of the variable.
  89413. * @param bool value to be set.
  89414. * @returns this effect.
  89415. */
  89416. setBool(uniformName: string, bool: boolean): Effect;
  89417. /**
  89418. * Sets a Vector2 on a uniform variable.
  89419. * @param uniformName Name of the variable.
  89420. * @param vector2 vector2 to be set.
  89421. * @returns this effect.
  89422. */
  89423. setVector2(uniformName: string, vector2: Vector2): Effect;
  89424. /**
  89425. * Sets a float2 on a uniform variable.
  89426. * @param uniformName Name of the variable.
  89427. * @param x First float in float2.
  89428. * @param y Second float in float2.
  89429. * @returns this effect.
  89430. */
  89431. setFloat2(uniformName: string, x: number, y: number): Effect;
  89432. /**
  89433. * Sets a Vector3 on a uniform variable.
  89434. * @param uniformName Name of the variable.
  89435. * @param vector3 Value to be set.
  89436. * @returns this effect.
  89437. */
  89438. setVector3(uniformName: string, vector3: Vector3): Effect;
  89439. /**
  89440. * Sets a float3 on a uniform variable.
  89441. * @param uniformName Name of the variable.
  89442. * @param x First float in float3.
  89443. * @param y Second float in float3.
  89444. * @param z Third float in float3.
  89445. * @returns this effect.
  89446. */
  89447. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  89448. /**
  89449. * Sets a Vector4 on a uniform variable.
  89450. * @param uniformName Name of the variable.
  89451. * @param vector4 Value to be set.
  89452. * @returns this effect.
  89453. */
  89454. setVector4(uniformName: string, vector4: Vector4): Effect;
  89455. /**
  89456. * Sets a float4 on a uniform variable.
  89457. * @param uniformName Name of the variable.
  89458. * @param x First float in float4.
  89459. * @param y Second float in float4.
  89460. * @param z Third float in float4.
  89461. * @param w Fourth float in float4.
  89462. * @returns this effect.
  89463. */
  89464. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  89465. /**
  89466. * Sets a Color3 on a uniform variable.
  89467. * @param uniformName Name of the variable.
  89468. * @param color3 Value to be set.
  89469. * @returns this effect.
  89470. */
  89471. setColor3(uniformName: string, color3: Color3): Effect;
  89472. /**
  89473. * Sets a Color4 on a uniform variable.
  89474. * @param uniformName Name of the variable.
  89475. * @param color3 Value to be set.
  89476. * @param alpha Alpha value to be set.
  89477. * @returns this effect.
  89478. */
  89479. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  89480. /**
  89481. * Sets a Color4 on a uniform variable
  89482. * @param uniformName defines the name of the variable
  89483. * @param color4 defines the value to be set
  89484. * @returns this effect.
  89485. */
  89486. setDirectColor4(uniformName: string, color4: Color4): Effect;
  89487. /** Release all associated resources */
  89488. dispose(): void;
  89489. /**
  89490. * This function will add a new shader to the shader store
  89491. * @param name the name of the shader
  89492. * @param pixelShader optional pixel shader content
  89493. * @param vertexShader optional vertex shader content
  89494. */
  89495. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  89496. /**
  89497. * Store of each shader (The can be looked up using effect.key)
  89498. */
  89499. static ShadersStore: {
  89500. [key: string]: string;
  89501. };
  89502. /**
  89503. * Store of each included file for a shader (The can be looked up using effect.key)
  89504. */
  89505. static IncludesShadersStore: {
  89506. [key: string]: string;
  89507. };
  89508. /**
  89509. * Resets the cache of effects.
  89510. */
  89511. static ResetCache(): void;
  89512. }
  89513. }
  89514. declare module BABYLON {
  89515. /**
  89516. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  89517. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  89518. * 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;
  89519. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  89520. */
  89521. export class ColorCurves {
  89522. private _dirty;
  89523. private _tempColor;
  89524. private _globalCurve;
  89525. private _highlightsCurve;
  89526. private _midtonesCurve;
  89527. private _shadowsCurve;
  89528. private _positiveCurve;
  89529. private _negativeCurve;
  89530. private _globalHue;
  89531. private _globalDensity;
  89532. private _globalSaturation;
  89533. private _globalExposure;
  89534. /**
  89535. * Gets the global Hue value.
  89536. * 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).
  89537. */
  89538. /**
  89539. * Sets the global Hue value.
  89540. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  89541. */
  89542. globalHue: number;
  89543. /**
  89544. * Gets the global Density value.
  89545. * 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.
  89546. * Values less than zero provide a filter of opposite hue.
  89547. */
  89548. /**
  89549. * Sets the global Density value.
  89550. * 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.
  89551. * Values less than zero provide a filter of opposite hue.
  89552. */
  89553. globalDensity: number;
  89554. /**
  89555. * Gets the global Saturation value.
  89556. * 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.
  89557. */
  89558. /**
  89559. * Sets the global Saturation value.
  89560. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  89561. */
  89562. globalSaturation: number;
  89563. /**
  89564. * Gets the global Exposure value.
  89565. * 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.
  89566. */
  89567. /**
  89568. * Sets the global Exposure value.
  89569. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  89570. */
  89571. globalExposure: number;
  89572. private _highlightsHue;
  89573. private _highlightsDensity;
  89574. private _highlightsSaturation;
  89575. private _highlightsExposure;
  89576. /**
  89577. * Gets the highlights Hue value.
  89578. * 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).
  89579. */
  89580. /**
  89581. * Sets the highlights Hue value.
  89582. * 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).
  89583. */
  89584. highlightsHue: number;
  89585. /**
  89586. * Gets the highlights Density value.
  89587. * 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.
  89588. * Values less than zero provide a filter of opposite hue.
  89589. */
  89590. /**
  89591. * Sets the highlights Density value.
  89592. * 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.
  89593. * Values less than zero provide a filter of opposite hue.
  89594. */
  89595. highlightsDensity: number;
  89596. /**
  89597. * Gets the highlights Saturation value.
  89598. * 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.
  89599. */
  89600. /**
  89601. * Sets the highlights Saturation value.
  89602. * 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.
  89603. */
  89604. highlightsSaturation: number;
  89605. /**
  89606. * Gets the highlights Exposure value.
  89607. * 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.
  89608. */
  89609. /**
  89610. * Sets the highlights Exposure value.
  89611. * 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.
  89612. */
  89613. highlightsExposure: number;
  89614. private _midtonesHue;
  89615. private _midtonesDensity;
  89616. private _midtonesSaturation;
  89617. private _midtonesExposure;
  89618. /**
  89619. * Gets the midtones Hue value.
  89620. * 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).
  89621. */
  89622. /**
  89623. * Sets the midtones Hue value.
  89624. * 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).
  89625. */
  89626. midtonesHue: number;
  89627. /**
  89628. * Gets the midtones Density value.
  89629. * 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.
  89630. * Values less than zero provide a filter of opposite hue.
  89631. */
  89632. /**
  89633. * Sets the midtones Density value.
  89634. * 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.
  89635. * Values less than zero provide a filter of opposite hue.
  89636. */
  89637. midtonesDensity: number;
  89638. /**
  89639. * Gets the midtones Saturation value.
  89640. * 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.
  89641. */
  89642. /**
  89643. * Sets the midtones Saturation value.
  89644. * 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.
  89645. */
  89646. midtonesSaturation: number;
  89647. /**
  89648. * Gets the midtones Exposure value.
  89649. * 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.
  89650. */
  89651. /**
  89652. * Sets the midtones Exposure value.
  89653. * 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.
  89654. */
  89655. midtonesExposure: number;
  89656. private _shadowsHue;
  89657. private _shadowsDensity;
  89658. private _shadowsSaturation;
  89659. private _shadowsExposure;
  89660. /**
  89661. * Gets the shadows Hue value.
  89662. * 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).
  89663. */
  89664. /**
  89665. * Sets the shadows Hue value.
  89666. * 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).
  89667. */
  89668. shadowsHue: number;
  89669. /**
  89670. * Gets the shadows Density value.
  89671. * 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.
  89672. * Values less than zero provide a filter of opposite hue.
  89673. */
  89674. /**
  89675. * Sets the shadows Density value.
  89676. * 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.
  89677. * Values less than zero provide a filter of opposite hue.
  89678. */
  89679. shadowsDensity: number;
  89680. /**
  89681. * Gets the shadows Saturation value.
  89682. * 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.
  89683. */
  89684. /**
  89685. * Sets the shadows Saturation value.
  89686. * 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.
  89687. */
  89688. shadowsSaturation: number;
  89689. /**
  89690. * Gets the shadows Exposure value.
  89691. * 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.
  89692. */
  89693. /**
  89694. * Sets the shadows Exposure value.
  89695. * 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.
  89696. */
  89697. shadowsExposure: number;
  89698. /**
  89699. * Returns the class name
  89700. * @returns The class name
  89701. */
  89702. getClassName(): string;
  89703. /**
  89704. * Binds the color curves to the shader.
  89705. * @param colorCurves The color curve to bind
  89706. * @param effect The effect to bind to
  89707. * @param positiveUniform The positive uniform shader parameter
  89708. * @param neutralUniform The neutral uniform shader parameter
  89709. * @param negativeUniform The negative uniform shader parameter
  89710. */
  89711. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  89712. /**
  89713. * Prepare the list of uniforms associated with the ColorCurves effects.
  89714. * @param uniformsList The list of uniforms used in the effect
  89715. */
  89716. static PrepareUniforms(uniformsList: string[]): void;
  89717. /**
  89718. * Returns color grading data based on a hue, density, saturation and exposure value.
  89719. * @param filterHue The hue of the color filter.
  89720. * @param filterDensity The density of the color filter.
  89721. * @param saturation The saturation.
  89722. * @param exposure The exposure.
  89723. * @param result The result data container.
  89724. */
  89725. private getColorGradingDataToRef;
  89726. /**
  89727. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  89728. * @param value The input slider value in range [-100,100].
  89729. * @returns Adjusted value.
  89730. */
  89731. private static applyColorGradingSliderNonlinear;
  89732. /**
  89733. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  89734. * @param hue The hue (H) input.
  89735. * @param saturation The saturation (S) input.
  89736. * @param brightness The brightness (B) input.
  89737. * @result An RGBA color represented as Vector4.
  89738. */
  89739. private static fromHSBToRef;
  89740. /**
  89741. * Returns a value clamped between min and max
  89742. * @param value The value to clamp
  89743. * @param min The minimum of value
  89744. * @param max The maximum of value
  89745. * @returns The clamped value.
  89746. */
  89747. private static clamp;
  89748. /**
  89749. * Clones the current color curve instance.
  89750. * @return The cloned curves
  89751. */
  89752. clone(): ColorCurves;
  89753. /**
  89754. * Serializes the current color curve instance to a json representation.
  89755. * @return a JSON representation
  89756. */
  89757. serialize(): any;
  89758. /**
  89759. * Parses the color curve from a json representation.
  89760. * @param source the JSON source to parse
  89761. * @return The parsed curves
  89762. */
  89763. static Parse(source: any): ColorCurves;
  89764. }
  89765. }
  89766. declare module BABYLON {
  89767. /**
  89768. * Interface to follow in your material defines to integrate easily the
  89769. * Image proccessing functions.
  89770. * @hidden
  89771. */
  89772. export interface IImageProcessingConfigurationDefines {
  89773. IMAGEPROCESSING: boolean;
  89774. VIGNETTE: boolean;
  89775. VIGNETTEBLENDMODEMULTIPLY: boolean;
  89776. VIGNETTEBLENDMODEOPAQUE: boolean;
  89777. TONEMAPPING: boolean;
  89778. TONEMAPPING_ACES: boolean;
  89779. CONTRAST: boolean;
  89780. EXPOSURE: boolean;
  89781. COLORCURVES: boolean;
  89782. COLORGRADING: boolean;
  89783. COLORGRADING3D: boolean;
  89784. SAMPLER3DGREENDEPTH: boolean;
  89785. SAMPLER3DBGRMAP: boolean;
  89786. IMAGEPROCESSINGPOSTPROCESS: boolean;
  89787. }
  89788. /**
  89789. * @hidden
  89790. */
  89791. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  89792. IMAGEPROCESSING: boolean;
  89793. VIGNETTE: boolean;
  89794. VIGNETTEBLENDMODEMULTIPLY: boolean;
  89795. VIGNETTEBLENDMODEOPAQUE: boolean;
  89796. TONEMAPPING: boolean;
  89797. TONEMAPPING_ACES: boolean;
  89798. CONTRAST: boolean;
  89799. COLORCURVES: boolean;
  89800. COLORGRADING: boolean;
  89801. COLORGRADING3D: boolean;
  89802. SAMPLER3DGREENDEPTH: boolean;
  89803. SAMPLER3DBGRMAP: boolean;
  89804. IMAGEPROCESSINGPOSTPROCESS: boolean;
  89805. EXPOSURE: boolean;
  89806. constructor();
  89807. }
  89808. /**
  89809. * This groups together the common properties used for image processing either in direct forward pass
  89810. * or through post processing effect depending on the use of the image processing pipeline in your scene
  89811. * or not.
  89812. */
  89813. export class ImageProcessingConfiguration {
  89814. /**
  89815. * Default tone mapping applied in BabylonJS.
  89816. */
  89817. static readonly TONEMAPPING_STANDARD: number;
  89818. /**
  89819. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  89820. * to other engines rendering to increase portability.
  89821. */
  89822. static readonly TONEMAPPING_ACES: number;
  89823. /**
  89824. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  89825. */
  89826. colorCurves: Nullable<ColorCurves>;
  89827. private _colorCurvesEnabled;
  89828. /**
  89829. * Gets wether the color curves effect is enabled.
  89830. */
  89831. /**
  89832. * Sets wether the color curves effect is enabled.
  89833. */
  89834. colorCurvesEnabled: boolean;
  89835. private _colorGradingTexture;
  89836. /**
  89837. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  89838. */
  89839. /**
  89840. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  89841. */
  89842. colorGradingTexture: Nullable<BaseTexture>;
  89843. private _colorGradingEnabled;
  89844. /**
  89845. * Gets wether the color grading effect is enabled.
  89846. */
  89847. /**
  89848. * Sets wether the color grading effect is enabled.
  89849. */
  89850. colorGradingEnabled: boolean;
  89851. private _colorGradingWithGreenDepth;
  89852. /**
  89853. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  89854. */
  89855. /**
  89856. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  89857. */
  89858. colorGradingWithGreenDepth: boolean;
  89859. private _colorGradingBGR;
  89860. /**
  89861. * Gets wether the color grading texture contains BGR values.
  89862. */
  89863. /**
  89864. * Sets wether the color grading texture contains BGR values.
  89865. */
  89866. colorGradingBGR: boolean;
  89867. /** @hidden */
  89868. _exposure: number;
  89869. /**
  89870. * Gets the Exposure used in the effect.
  89871. */
  89872. /**
  89873. * Sets the Exposure used in the effect.
  89874. */
  89875. exposure: number;
  89876. private _toneMappingEnabled;
  89877. /**
  89878. * Gets wether the tone mapping effect is enabled.
  89879. */
  89880. /**
  89881. * Sets wether the tone mapping effect is enabled.
  89882. */
  89883. toneMappingEnabled: boolean;
  89884. private _toneMappingType;
  89885. /**
  89886. * Gets the type of tone mapping effect.
  89887. */
  89888. /**
  89889. * Sets the type of tone mapping effect used in BabylonJS.
  89890. */
  89891. toneMappingType: number;
  89892. protected _contrast: number;
  89893. /**
  89894. * Gets the contrast used in the effect.
  89895. */
  89896. /**
  89897. * Sets the contrast used in the effect.
  89898. */
  89899. contrast: number;
  89900. /**
  89901. * Vignette stretch size.
  89902. */
  89903. vignetteStretch: number;
  89904. /**
  89905. * Vignette centre X Offset.
  89906. */
  89907. vignetteCentreX: number;
  89908. /**
  89909. * Vignette centre Y Offset.
  89910. */
  89911. vignetteCentreY: number;
  89912. /**
  89913. * Vignette weight or intensity of the vignette effect.
  89914. */
  89915. vignetteWeight: number;
  89916. /**
  89917. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  89918. * if vignetteEnabled is set to true.
  89919. */
  89920. vignetteColor: Color4;
  89921. /**
  89922. * Camera field of view used by the Vignette effect.
  89923. */
  89924. vignetteCameraFov: number;
  89925. private _vignetteBlendMode;
  89926. /**
  89927. * Gets the vignette blend mode allowing different kind of effect.
  89928. */
  89929. /**
  89930. * Sets the vignette blend mode allowing different kind of effect.
  89931. */
  89932. vignetteBlendMode: number;
  89933. private _vignetteEnabled;
  89934. /**
  89935. * Gets wether the vignette effect is enabled.
  89936. */
  89937. /**
  89938. * Sets wether the vignette effect is enabled.
  89939. */
  89940. vignetteEnabled: boolean;
  89941. private _applyByPostProcess;
  89942. /**
  89943. * Gets wether the image processing is applied through a post process or not.
  89944. */
  89945. /**
  89946. * Sets wether the image processing is applied through a post process or not.
  89947. */
  89948. applyByPostProcess: boolean;
  89949. private _isEnabled;
  89950. /**
  89951. * Gets wether the image processing is enabled or not.
  89952. */
  89953. /**
  89954. * Sets wether the image processing is enabled or not.
  89955. */
  89956. isEnabled: boolean;
  89957. /**
  89958. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  89959. */
  89960. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  89961. /**
  89962. * Method called each time the image processing information changes requires to recompile the effect.
  89963. */
  89964. protected _updateParameters(): void;
  89965. /**
  89966. * Gets the current class name.
  89967. * @return "ImageProcessingConfiguration"
  89968. */
  89969. getClassName(): string;
  89970. /**
  89971. * Prepare the list of uniforms associated with the Image Processing effects.
  89972. * @param uniforms The list of uniforms used in the effect
  89973. * @param defines the list of defines currently in use
  89974. */
  89975. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  89976. /**
  89977. * Prepare the list of samplers associated with the Image Processing effects.
  89978. * @param samplersList The list of uniforms used in the effect
  89979. * @param defines the list of defines currently in use
  89980. */
  89981. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  89982. /**
  89983. * Prepare the list of defines associated to the shader.
  89984. * @param defines the list of defines to complete
  89985. * @param forPostProcess Define if we are currently in post process mode or not
  89986. */
  89987. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  89988. /**
  89989. * Returns true if all the image processing information are ready.
  89990. * @returns True if ready, otherwise, false
  89991. */
  89992. isReady(): boolean;
  89993. /**
  89994. * Binds the image processing to the shader.
  89995. * @param effect The effect to bind to
  89996. * @param aspectRatio Define the current aspect ratio of the effect
  89997. */
  89998. bind(effect: Effect, aspectRatio?: number): void;
  89999. /**
  90000. * Clones the current image processing instance.
  90001. * @return The cloned image processing
  90002. */
  90003. clone(): ImageProcessingConfiguration;
  90004. /**
  90005. * Serializes the current image processing instance to a json representation.
  90006. * @return a JSON representation
  90007. */
  90008. serialize(): any;
  90009. /**
  90010. * Parses the image processing from a json representation.
  90011. * @param source the JSON source to parse
  90012. * @return The parsed image processing
  90013. */
  90014. static Parse(source: any): ImageProcessingConfiguration;
  90015. private static _VIGNETTEMODE_MULTIPLY;
  90016. private static _VIGNETTEMODE_OPAQUE;
  90017. /**
  90018. * Used to apply the vignette as a mix with the pixel color.
  90019. */
  90020. static readonly VIGNETTEMODE_MULTIPLY: number;
  90021. /**
  90022. * Used to apply the vignette as a replacement of the pixel color.
  90023. */
  90024. static readonly VIGNETTEMODE_OPAQUE: number;
  90025. }
  90026. }
  90027. declare module BABYLON {
  90028. /**
  90029. * This represents all the required information to add a fresnel effect on a material:
  90030. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  90031. */
  90032. export class FresnelParameters {
  90033. private _isEnabled;
  90034. /**
  90035. * Define if the fresnel effect is enable or not.
  90036. */
  90037. isEnabled: boolean;
  90038. /**
  90039. * Define the color used on edges (grazing angle)
  90040. */
  90041. leftColor: Color3;
  90042. /**
  90043. * Define the color used on center
  90044. */
  90045. rightColor: Color3;
  90046. /**
  90047. * Define bias applied to computed fresnel term
  90048. */
  90049. bias: number;
  90050. /**
  90051. * Defined the power exponent applied to fresnel term
  90052. */
  90053. power: number;
  90054. /**
  90055. * Clones the current fresnel and its valuues
  90056. * @returns a clone fresnel configuration
  90057. */
  90058. clone(): FresnelParameters;
  90059. /**
  90060. * Serializes the current fresnel parameters to a JSON representation.
  90061. * @return the JSON serialization
  90062. */
  90063. serialize(): any;
  90064. /**
  90065. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  90066. * @param parsedFresnelParameters Define the JSON representation
  90067. * @returns the parsed parameters
  90068. */
  90069. static Parse(parsedFresnelParameters: any): FresnelParameters;
  90070. }
  90071. }
  90072. declare module BABYLON {
  90073. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  90074. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90075. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90076. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90077. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90078. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90079. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90080. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90081. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90082. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90083. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90084. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90085. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90086. /**
  90087. * Decorator used to define property that can be serialized as reference to a camera
  90088. * @param sourceName defines the name of the property to decorate
  90089. */
  90090. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90091. /**
  90092. * Class used to help serialization objects
  90093. */
  90094. export class SerializationHelper {
  90095. /** hidden */
  90096. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  90097. /** hidden */
  90098. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  90099. /** hidden */
  90100. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  90101. /** hidden */
  90102. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  90103. /**
  90104. * Appends the serialized animations from the source animations
  90105. * @param source Source containing the animations
  90106. * @param destination Target to store the animations
  90107. */
  90108. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  90109. /**
  90110. * Static function used to serialized a specific entity
  90111. * @param entity defines the entity to serialize
  90112. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  90113. * @returns a JSON compatible object representing the serialization of the entity
  90114. */
  90115. static Serialize<T>(entity: T, serializationObject?: any): any;
  90116. /**
  90117. * Creates a new entity from a serialization data object
  90118. * @param creationFunction defines a function used to instanciated the new entity
  90119. * @param source defines the source serialization data
  90120. * @param scene defines the hosting scene
  90121. * @param rootUrl defines the root url for resources
  90122. * @returns a new entity
  90123. */
  90124. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  90125. /**
  90126. * Clones an object
  90127. * @param creationFunction defines the function used to instanciate the new object
  90128. * @param source defines the source object
  90129. * @returns the cloned object
  90130. */
  90131. static Clone<T>(creationFunction: () => T, source: T): T;
  90132. /**
  90133. * Instanciates a new object based on a source one (some data will be shared between both object)
  90134. * @param creationFunction defines the function used to instanciate the new object
  90135. * @param source defines the source object
  90136. * @returns the new object
  90137. */
  90138. static Instanciate<T>(creationFunction: () => T, source: T): T;
  90139. }
  90140. }
  90141. declare module BABYLON {
  90142. /**
  90143. * This is the base class of all the camera used in the application.
  90144. * @see http://doc.babylonjs.com/features/cameras
  90145. */
  90146. export class Camera extends Node {
  90147. /** @hidden */
  90148. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  90149. /**
  90150. * This is the default projection mode used by the cameras.
  90151. * It helps recreating a feeling of perspective and better appreciate depth.
  90152. * This is the best way to simulate real life cameras.
  90153. */
  90154. static readonly PERSPECTIVE_CAMERA: number;
  90155. /**
  90156. * This helps creating camera with an orthographic mode.
  90157. * 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.
  90158. */
  90159. static readonly ORTHOGRAPHIC_CAMERA: number;
  90160. /**
  90161. * This is the default FOV mode for perspective cameras.
  90162. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  90163. */
  90164. static readonly FOVMODE_VERTICAL_FIXED: number;
  90165. /**
  90166. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  90167. */
  90168. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  90169. /**
  90170. * This specifies ther is no need for a camera rig.
  90171. * Basically only one eye is rendered corresponding to the camera.
  90172. */
  90173. static readonly RIG_MODE_NONE: number;
  90174. /**
  90175. * Simulates a camera Rig with one blue eye and one red eye.
  90176. * This can be use with 3d blue and red glasses.
  90177. */
  90178. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  90179. /**
  90180. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  90181. */
  90182. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  90183. /**
  90184. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  90185. */
  90186. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  90187. /**
  90188. * Defines that both eyes of the camera will be rendered over under each other.
  90189. */
  90190. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  90191. /**
  90192. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  90193. */
  90194. static readonly RIG_MODE_VR: number;
  90195. /**
  90196. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  90197. */
  90198. static readonly RIG_MODE_WEBVR: number;
  90199. /**
  90200. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  90201. */
  90202. static readonly RIG_MODE_CUSTOM: number;
  90203. /**
  90204. * Defines if by default attaching controls should prevent the default javascript event to continue.
  90205. */
  90206. static ForceAttachControlToAlwaysPreventDefault: boolean;
  90207. /**
  90208. * Define the input manager associated with the camera.
  90209. */
  90210. inputs: CameraInputsManager<Camera>;
  90211. /** @hidden */
  90212. _position: Vector3;
  90213. /**
  90214. * Define the current local position of the camera in the scene
  90215. */
  90216. position: Vector3;
  90217. /**
  90218. * The vector the camera should consider as up.
  90219. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  90220. */
  90221. upVector: Vector3;
  90222. /**
  90223. * Define the current limit on the left side for an orthographic camera
  90224. * In scene unit
  90225. */
  90226. orthoLeft: Nullable<number>;
  90227. /**
  90228. * Define the current limit on the right side for an orthographic camera
  90229. * In scene unit
  90230. */
  90231. orthoRight: Nullable<number>;
  90232. /**
  90233. * Define the current limit on the bottom side for an orthographic camera
  90234. * In scene unit
  90235. */
  90236. orthoBottom: Nullable<number>;
  90237. /**
  90238. * Define the current limit on the top side for an orthographic camera
  90239. * In scene unit
  90240. */
  90241. orthoTop: Nullable<number>;
  90242. /**
  90243. * Field Of View is set in Radians. (default is 0.8)
  90244. */
  90245. fov: number;
  90246. /**
  90247. * Define the minimum distance the camera can see from.
  90248. * This is important to note that the depth buffer are not infinite and the closer it starts
  90249. * the more your scene might encounter depth fighting issue.
  90250. */
  90251. minZ: number;
  90252. /**
  90253. * Define the maximum distance the camera can see to.
  90254. * This is important to note that the depth buffer are not infinite and the further it end
  90255. * the more your scene might encounter depth fighting issue.
  90256. */
  90257. maxZ: number;
  90258. /**
  90259. * Define the default inertia of the camera.
  90260. * This helps giving a smooth feeling to the camera movement.
  90261. */
  90262. inertia: number;
  90263. /**
  90264. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  90265. */
  90266. mode: number;
  90267. /**
  90268. * Define wether the camera is intermediate.
  90269. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  90270. */
  90271. isIntermediate: boolean;
  90272. /**
  90273. * Define the viewport of the camera.
  90274. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  90275. */
  90276. viewport: Viewport;
  90277. /**
  90278. * Restricts the camera to viewing objects with the same layerMask.
  90279. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  90280. */
  90281. layerMask: number;
  90282. /**
  90283. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  90284. */
  90285. fovMode: number;
  90286. /**
  90287. * Rig mode of the camera.
  90288. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  90289. * This is normally controlled byt the camera themselves as internal use.
  90290. */
  90291. cameraRigMode: number;
  90292. /**
  90293. * Defines the distance between both "eyes" in case of a RIG
  90294. */
  90295. interaxialDistance: number;
  90296. /**
  90297. * Defines if stereoscopic rendering is done side by side or over under.
  90298. */
  90299. isStereoscopicSideBySide: boolean;
  90300. /**
  90301. * 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
  90302. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  90303. * else in the scene.
  90304. */
  90305. customRenderTargets: RenderTargetTexture[];
  90306. /**
  90307. * When set, the camera will render to this render target instead of the default canvas
  90308. */
  90309. outputRenderTarget: Nullable<RenderTargetTexture>;
  90310. /**
  90311. * Observable triggered when the camera view matrix has changed.
  90312. */
  90313. onViewMatrixChangedObservable: Observable<Camera>;
  90314. /**
  90315. * Observable triggered when the camera Projection matrix has changed.
  90316. */
  90317. onProjectionMatrixChangedObservable: Observable<Camera>;
  90318. /**
  90319. * Observable triggered when the inputs have been processed.
  90320. */
  90321. onAfterCheckInputsObservable: Observable<Camera>;
  90322. /**
  90323. * Observable triggered when reset has been called and applied to the camera.
  90324. */
  90325. onRestoreStateObservable: Observable<Camera>;
  90326. /** @hidden */
  90327. _cameraRigParams: any;
  90328. /** @hidden */
  90329. _rigCameras: Camera[];
  90330. /** @hidden */
  90331. _rigPostProcess: Nullable<PostProcess>;
  90332. protected _webvrViewMatrix: Matrix;
  90333. /** @hidden */
  90334. _skipRendering: boolean;
  90335. /** @hidden */
  90336. _projectionMatrix: Matrix;
  90337. /** @hidden */
  90338. _postProcesses: Nullable<PostProcess>[];
  90339. /** @hidden */
  90340. _activeMeshes: SmartArray<AbstractMesh>;
  90341. protected _globalPosition: Vector3;
  90342. /** hidden */
  90343. _computedViewMatrix: Matrix;
  90344. private _doNotComputeProjectionMatrix;
  90345. private _transformMatrix;
  90346. private _frustumPlanes;
  90347. private _refreshFrustumPlanes;
  90348. private _storedFov;
  90349. private _stateStored;
  90350. /**
  90351. * Instantiates a new camera object.
  90352. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  90353. * @see http://doc.babylonjs.com/features/cameras
  90354. * @param name Defines the name of the camera in the scene
  90355. * @param position Defines the position of the camera
  90356. * @param scene Defines the scene the camera belongs too
  90357. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  90358. */
  90359. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  90360. /**
  90361. * Store current camera state (fov, position, etc..)
  90362. * @returns the camera
  90363. */
  90364. storeState(): Camera;
  90365. /**
  90366. * Restores the camera state values if it has been stored. You must call storeState() first
  90367. */
  90368. protected _restoreStateValues(): boolean;
  90369. /**
  90370. * Restored camera state. You must call storeState() first.
  90371. * @returns true if restored and false otherwise
  90372. */
  90373. restoreState(): boolean;
  90374. /**
  90375. * Gets the class name of the camera.
  90376. * @returns the class name
  90377. */
  90378. getClassName(): string;
  90379. /** @hidden */
  90380. readonly _isCamera: boolean;
  90381. /**
  90382. * Gets a string representation of the camera useful for debug purpose.
  90383. * @param fullDetails Defines that a more verboe level of logging is required
  90384. * @returns the string representation
  90385. */
  90386. toString(fullDetails?: boolean): string;
  90387. /**
  90388. * Gets the current world space position of the camera.
  90389. */
  90390. readonly globalPosition: Vector3;
  90391. /**
  90392. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  90393. * @returns the active meshe list
  90394. */
  90395. getActiveMeshes(): SmartArray<AbstractMesh>;
  90396. /**
  90397. * Check wether a mesh is part of the current active mesh list of the camera
  90398. * @param mesh Defines the mesh to check
  90399. * @returns true if active, false otherwise
  90400. */
  90401. isActiveMesh(mesh: Mesh): boolean;
  90402. /**
  90403. * Is this camera ready to be used/rendered
  90404. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  90405. * @return true if the camera is ready
  90406. */
  90407. isReady(completeCheck?: boolean): boolean;
  90408. /** @hidden */
  90409. _initCache(): void;
  90410. /** @hidden */
  90411. _updateCache(ignoreParentClass?: boolean): void;
  90412. /** @hidden */
  90413. _isSynchronized(): boolean;
  90414. /** @hidden */
  90415. _isSynchronizedViewMatrix(): boolean;
  90416. /** @hidden */
  90417. _isSynchronizedProjectionMatrix(): boolean;
  90418. /**
  90419. * Attach the input controls to a specific dom element to get the input from.
  90420. * @param element Defines the element the controls should be listened from
  90421. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  90422. */
  90423. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  90424. /**
  90425. * Detach the current controls from the specified dom element.
  90426. * @param element Defines the element to stop listening the inputs from
  90427. */
  90428. detachControl(element: HTMLElement): void;
  90429. /**
  90430. * Update the camera state according to the different inputs gathered during the frame.
  90431. */
  90432. update(): void;
  90433. /** @hidden */
  90434. _checkInputs(): void;
  90435. /** @hidden */
  90436. readonly rigCameras: Camera[];
  90437. /**
  90438. * Gets the post process used by the rig cameras
  90439. */
  90440. readonly rigPostProcess: Nullable<PostProcess>;
  90441. /**
  90442. * Internal, gets the first post proces.
  90443. * @returns the first post process to be run on this camera.
  90444. */
  90445. _getFirstPostProcess(): Nullable<PostProcess>;
  90446. private _cascadePostProcessesToRigCams;
  90447. /**
  90448. * Attach a post process to the camera.
  90449. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  90450. * @param postProcess The post process to attach to the camera
  90451. * @param insertAt The position of the post process in case several of them are in use in the scene
  90452. * @returns the position the post process has been inserted at
  90453. */
  90454. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  90455. /**
  90456. * Detach a post process to the camera.
  90457. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  90458. * @param postProcess The post process to detach from the camera
  90459. */
  90460. detachPostProcess(postProcess: PostProcess): void;
  90461. /**
  90462. * Gets the current world matrix of the camera
  90463. */
  90464. getWorldMatrix(): Matrix;
  90465. /** @hidden */
  90466. _getViewMatrix(): Matrix;
  90467. /**
  90468. * Gets the current view matrix of the camera.
  90469. * @param force forces the camera to recompute the matrix without looking at the cached state
  90470. * @returns the view matrix
  90471. */
  90472. getViewMatrix(force?: boolean): Matrix;
  90473. /**
  90474. * Freeze the projection matrix.
  90475. * It will prevent the cache check of the camera projection compute and can speed up perf
  90476. * if no parameter of the camera are meant to change
  90477. * @param projection Defines manually a projection if necessary
  90478. */
  90479. freezeProjectionMatrix(projection?: Matrix): void;
  90480. /**
  90481. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  90482. */
  90483. unfreezeProjectionMatrix(): void;
  90484. /**
  90485. * Gets the current projection matrix of the camera.
  90486. * @param force forces the camera to recompute the matrix without looking at the cached state
  90487. * @returns the projection matrix
  90488. */
  90489. getProjectionMatrix(force?: boolean): Matrix;
  90490. /**
  90491. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  90492. * @returns a Matrix
  90493. */
  90494. getTransformationMatrix(): Matrix;
  90495. private _updateFrustumPlanes;
  90496. /**
  90497. * Checks if a cullable object (mesh...) is in the camera frustum
  90498. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  90499. * @param target The object to check
  90500. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  90501. * @returns true if the object is in frustum otherwise false
  90502. */
  90503. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  90504. /**
  90505. * Checks if a cullable object (mesh...) is in the camera frustum
  90506. * Unlike isInFrustum this cheks the full bounding box
  90507. * @param target The object to check
  90508. * @returns true if the object is in frustum otherwise false
  90509. */
  90510. isCompletelyInFrustum(target: ICullable): boolean;
  90511. /**
  90512. * Gets a ray in the forward direction from the camera.
  90513. * @param length Defines the length of the ray to create
  90514. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  90515. * @param origin Defines the start point of the ray which defaults to the camera position
  90516. * @returns the forward ray
  90517. */
  90518. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  90519. /**
  90520. * Releases resources associated with this node.
  90521. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  90522. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  90523. */
  90524. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  90525. /** @hidden */
  90526. _isLeftCamera: boolean;
  90527. /**
  90528. * Gets the left camera of a rig setup in case of Rigged Camera
  90529. */
  90530. readonly isLeftCamera: boolean;
  90531. /** @hidden */
  90532. _isRightCamera: boolean;
  90533. /**
  90534. * Gets the right camera of a rig setup in case of Rigged Camera
  90535. */
  90536. readonly isRightCamera: boolean;
  90537. /**
  90538. * Gets the left camera of a rig setup in case of Rigged Camera
  90539. */
  90540. readonly leftCamera: Nullable<FreeCamera>;
  90541. /**
  90542. * Gets the right camera of a rig setup in case of Rigged Camera
  90543. */
  90544. readonly rightCamera: Nullable<FreeCamera>;
  90545. /**
  90546. * Gets the left camera target of a rig setup in case of Rigged Camera
  90547. * @returns the target position
  90548. */
  90549. getLeftTarget(): Nullable<Vector3>;
  90550. /**
  90551. * Gets the right camera target of a rig setup in case of Rigged Camera
  90552. * @returns the target position
  90553. */
  90554. getRightTarget(): Nullable<Vector3>;
  90555. /**
  90556. * @hidden
  90557. */
  90558. setCameraRigMode(mode: number, rigParams: any): void;
  90559. /** @hidden */
  90560. static _setStereoscopicRigMode(camera: Camera): void;
  90561. /** @hidden */
  90562. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  90563. /** @hidden */
  90564. static _setVRRigMode(camera: Camera, rigParams: any): void;
  90565. /** @hidden */
  90566. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  90567. /** @hidden */
  90568. _getVRProjectionMatrix(): Matrix;
  90569. protected _updateCameraRotationMatrix(): void;
  90570. protected _updateWebVRCameraRotationMatrix(): void;
  90571. /**
  90572. * This function MUST be overwritten by the different WebVR cameras available.
  90573. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  90574. * @hidden
  90575. */
  90576. _getWebVRProjectionMatrix(): Matrix;
  90577. /**
  90578. * This function MUST be overwritten by the different WebVR cameras available.
  90579. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  90580. * @hidden
  90581. */
  90582. _getWebVRViewMatrix(): Matrix;
  90583. /** @hidden */
  90584. setCameraRigParameter(name: string, value: any): void;
  90585. /**
  90586. * needs to be overridden by children so sub has required properties to be copied
  90587. * @hidden
  90588. */
  90589. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  90590. /**
  90591. * May need to be overridden by children
  90592. * @hidden
  90593. */
  90594. _updateRigCameras(): void;
  90595. /** @hidden */
  90596. _setupInputs(): void;
  90597. /**
  90598. * Serialiaze the camera setup to a json represention
  90599. * @returns the JSON representation
  90600. */
  90601. serialize(): any;
  90602. /**
  90603. * Clones the current camera.
  90604. * @param name The cloned camera name
  90605. * @returns the cloned camera
  90606. */
  90607. clone(name: string): Camera;
  90608. /**
  90609. * Gets the direction of the camera relative to a given local axis.
  90610. * @param localAxis Defines the reference axis to provide a relative direction.
  90611. * @return the direction
  90612. */
  90613. getDirection(localAxis: Vector3): Vector3;
  90614. /**
  90615. * Gets the direction of the camera relative to a given local axis into a passed vector.
  90616. * @param localAxis Defines the reference axis to provide a relative direction.
  90617. * @param result Defines the vector to store the result in
  90618. */
  90619. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  90620. /**
  90621. * Gets a camera constructor for a given camera type
  90622. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  90623. * @param name The name of the camera the result will be able to instantiate
  90624. * @param scene The scene the result will construct the camera in
  90625. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  90626. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  90627. * @returns a factory method to construc the camera
  90628. */
  90629. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  90630. /**
  90631. * Compute the world matrix of the camera.
  90632. * @returns the camera workd matrix
  90633. */
  90634. computeWorldMatrix(): Matrix;
  90635. /**
  90636. * Parse a JSON and creates the camera from the parsed information
  90637. * @param parsedCamera The JSON to parse
  90638. * @param scene The scene to instantiate the camera in
  90639. * @returns the newly constructed camera
  90640. */
  90641. static Parse(parsedCamera: any, scene: Scene): Camera;
  90642. }
  90643. }
  90644. declare module BABYLON {
  90645. /**
  90646. * Interface for any object that can request an animation frame
  90647. */
  90648. export interface ICustomAnimationFrameRequester {
  90649. /**
  90650. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  90651. */
  90652. renderFunction?: Function;
  90653. /**
  90654. * Called to request the next frame to render to
  90655. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  90656. */
  90657. requestAnimationFrame: Function;
  90658. /**
  90659. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  90660. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  90661. */
  90662. requestID?: number;
  90663. }
  90664. /**
  90665. * Interface containing an array of animations
  90666. */
  90667. export interface IAnimatable {
  90668. /**
  90669. * Array of animations
  90670. */
  90671. animations: Nullable<Array<Animation>>;
  90672. }
  90673. /** Interface used by value gradients (color, factor, ...) */
  90674. export interface IValueGradient {
  90675. /**
  90676. * Gets or sets the gradient value (between 0 and 1)
  90677. */
  90678. gradient: number;
  90679. }
  90680. /** Class used to store color4 gradient */
  90681. export class ColorGradient implements IValueGradient {
  90682. /**
  90683. * Gets or sets the gradient value (between 0 and 1)
  90684. */
  90685. gradient: number;
  90686. /**
  90687. * Gets or sets first associated color
  90688. */
  90689. color1: Color4;
  90690. /**
  90691. * Gets or sets second associated color
  90692. */
  90693. color2?: Color4;
  90694. /**
  90695. * Will get a color picked randomly between color1 and color2.
  90696. * If color2 is undefined then color1 will be used
  90697. * @param result defines the target Color4 to store the result in
  90698. */
  90699. getColorToRef(result: Color4): void;
  90700. }
  90701. /** Class used to store color 3 gradient */
  90702. export class Color3Gradient implements IValueGradient {
  90703. /**
  90704. * Gets or sets the gradient value (between 0 and 1)
  90705. */
  90706. gradient: number;
  90707. /**
  90708. * Gets or sets the associated color
  90709. */
  90710. color: Color3;
  90711. }
  90712. /** Class used to store factor gradient */
  90713. export class FactorGradient implements IValueGradient {
  90714. /**
  90715. * Gets or sets the gradient value (between 0 and 1)
  90716. */
  90717. gradient: number;
  90718. /**
  90719. * Gets or sets first associated factor
  90720. */
  90721. factor1: number;
  90722. /**
  90723. * Gets or sets second associated factor
  90724. */
  90725. factor2?: number;
  90726. /**
  90727. * Will get a number picked randomly between factor1 and factor2.
  90728. * If factor2 is undefined then factor1 will be used
  90729. * @returns the picked number
  90730. */
  90731. getFactor(): number;
  90732. }
  90733. /**
  90734. * @ignore
  90735. * Application error to support additional information when loading a file
  90736. */
  90737. export class LoadFileError extends Error {
  90738. /** defines the optional web request */
  90739. request?: WebRequest | undefined;
  90740. private static _setPrototypeOf;
  90741. /**
  90742. * Creates a new LoadFileError
  90743. * @param message defines the message of the error
  90744. * @param request defines the optional web request
  90745. */
  90746. constructor(message: string,
  90747. /** defines the optional web request */
  90748. request?: WebRequest | undefined);
  90749. }
  90750. /**
  90751. * Class used to define a retry strategy when error happens while loading assets
  90752. */
  90753. export class RetryStrategy {
  90754. /**
  90755. * Function used to defines an exponential back off strategy
  90756. * @param maxRetries defines the maximum number of retries (3 by default)
  90757. * @param baseInterval defines the interval between retries
  90758. * @returns the strategy function to use
  90759. */
  90760. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  90761. }
  90762. /**
  90763. * File request interface
  90764. */
  90765. export interface IFileRequest {
  90766. /**
  90767. * Raised when the request is complete (success or error).
  90768. */
  90769. onCompleteObservable: Observable<IFileRequest>;
  90770. /**
  90771. * Aborts the request for a file.
  90772. */
  90773. abort: () => void;
  90774. }
  90775. /**
  90776. * Class containing a set of static utilities functions
  90777. */
  90778. export class Tools {
  90779. /**
  90780. * Gets or sets the base URL to use to load assets
  90781. */
  90782. static BaseUrl: string;
  90783. /**
  90784. * Enable/Disable Custom HTTP Request Headers globally.
  90785. * default = false
  90786. * @see CustomRequestHeaders
  90787. */
  90788. static UseCustomRequestHeaders: boolean;
  90789. /**
  90790. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  90791. * i.e. when loading files, where the server/service expects an Authorization header
  90792. */
  90793. static CustomRequestHeaders: {
  90794. [key: string]: string;
  90795. };
  90796. /**
  90797. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  90798. */
  90799. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  90800. /**
  90801. * Default behaviour for cors in the application.
  90802. * It can be a string if the expected behavior is identical in the entire app.
  90803. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  90804. */
  90805. static CorsBehavior: string | ((url: string | string[]) => string);
  90806. /**
  90807. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  90808. * @ignorenaming
  90809. */
  90810. static UseFallbackTexture: boolean;
  90811. /**
  90812. * Use this object to register external classes like custom textures or material
  90813. * to allow the laoders to instantiate them
  90814. */
  90815. static RegisteredExternalClasses: {
  90816. [key: string]: Object;
  90817. };
  90818. /**
  90819. * Texture content used if a texture cannot loaded
  90820. * @ignorenaming
  90821. */
  90822. static fallbackTexture: string;
  90823. /**
  90824. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  90825. * @param u defines the coordinate on X axis
  90826. * @param v defines the coordinate on Y axis
  90827. * @param width defines the width of the source data
  90828. * @param height defines the height of the source data
  90829. * @param pixels defines the source byte array
  90830. * @param color defines the output color
  90831. */
  90832. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  90833. /**
  90834. * Interpolates between a and b via alpha
  90835. * @param a The lower value (returned when alpha = 0)
  90836. * @param b The upper value (returned when alpha = 1)
  90837. * @param alpha The interpolation-factor
  90838. * @return The mixed value
  90839. */
  90840. static Mix(a: number, b: number, alpha: number): number;
  90841. /**
  90842. * Tries to instantiate a new object from a given class name
  90843. * @param className defines the class name to instantiate
  90844. * @returns the new object or null if the system was not able to do the instantiation
  90845. */
  90846. static Instantiate(className: string): any;
  90847. /**
  90848. * Provides a slice function that will work even on IE
  90849. * @param data defines the array to slice
  90850. * @param start defines the start of the data (optional)
  90851. * @param end defines the end of the data (optional)
  90852. * @returns the new sliced array
  90853. */
  90854. static Slice<T>(data: T, start?: number, end?: number): T;
  90855. /**
  90856. * Polyfill for setImmediate
  90857. * @param action defines the action to execute after the current execution block
  90858. */
  90859. static SetImmediate(action: () => void): void;
  90860. /**
  90861. * Function indicating if a number is an exponent of 2
  90862. * @param value defines the value to test
  90863. * @returns true if the value is an exponent of 2
  90864. */
  90865. static IsExponentOfTwo(value: number): boolean;
  90866. private static _tmpFloatArray;
  90867. /**
  90868. * Returns the nearest 32-bit single precision float representation of a Number
  90869. * @param value A Number. If the parameter is of a different type, it will get converted
  90870. * to a number or to NaN if it cannot be converted
  90871. * @returns number
  90872. */
  90873. static FloatRound(value: number): number;
  90874. /**
  90875. * Find the next highest power of two.
  90876. * @param x Number to start search from.
  90877. * @return Next highest power of two.
  90878. */
  90879. static CeilingPOT(x: number): number;
  90880. /**
  90881. * Find the next lowest power of two.
  90882. * @param x Number to start search from.
  90883. * @return Next lowest power of two.
  90884. */
  90885. static FloorPOT(x: number): number;
  90886. /**
  90887. * Find the nearest power of two.
  90888. * @param x Number to start search from.
  90889. * @return Next nearest power of two.
  90890. */
  90891. static NearestPOT(x: number): number;
  90892. /**
  90893. * Get the closest exponent of two
  90894. * @param value defines the value to approximate
  90895. * @param max defines the maximum value to return
  90896. * @param mode defines how to define the closest value
  90897. * @returns closest exponent of two of the given value
  90898. */
  90899. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  90900. /**
  90901. * Extracts the filename from a path
  90902. * @param path defines the path to use
  90903. * @returns the filename
  90904. */
  90905. static GetFilename(path: string): string;
  90906. /**
  90907. * Extracts the "folder" part of a path (everything before the filename).
  90908. * @param uri The URI to extract the info from
  90909. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  90910. * @returns The "folder" part of the path
  90911. */
  90912. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  90913. /**
  90914. * Extracts text content from a DOM element hierarchy
  90915. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  90916. */
  90917. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  90918. /**
  90919. * Convert an angle in radians to degrees
  90920. * @param angle defines the angle to convert
  90921. * @returns the angle in degrees
  90922. */
  90923. static ToDegrees(angle: number): number;
  90924. /**
  90925. * Convert an angle in degrees to radians
  90926. * @param angle defines the angle to convert
  90927. * @returns the angle in radians
  90928. */
  90929. static ToRadians(angle: number): number;
  90930. /**
  90931. * Encode a buffer to a base64 string
  90932. * @param buffer defines the buffer to encode
  90933. * @returns the encoded string
  90934. */
  90935. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  90936. /**
  90937. * Extracts minimum and maximum values from a list of indexed positions
  90938. * @param positions defines the positions to use
  90939. * @param indices defines the indices to the positions
  90940. * @param indexStart defines the start index
  90941. * @param indexCount defines the end index
  90942. * @param bias defines bias value to add to the result
  90943. * @return minimum and maximum values
  90944. */
  90945. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  90946. minimum: Vector3;
  90947. maximum: Vector3;
  90948. };
  90949. /**
  90950. * Extracts minimum and maximum values from a list of positions
  90951. * @param positions defines the positions to use
  90952. * @param start defines the start index in the positions array
  90953. * @param count defines the number of positions to handle
  90954. * @param bias defines bias value to add to the result
  90955. * @param stride defines the stride size to use (distance between two positions in the positions array)
  90956. * @return minimum and maximum values
  90957. */
  90958. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  90959. minimum: Vector3;
  90960. maximum: Vector3;
  90961. };
  90962. /**
  90963. * Returns an array if obj is not an array
  90964. * @param obj defines the object to evaluate as an array
  90965. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  90966. * @returns either obj directly if obj is an array or a new array containing obj
  90967. */
  90968. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  90969. /**
  90970. * Gets the pointer prefix to use
  90971. * @returns "pointer" if touch is enabled. Else returns "mouse"
  90972. */
  90973. static GetPointerPrefix(): string;
  90974. /**
  90975. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  90976. * @param func - the function to be called
  90977. * @param requester - the object that will request the next frame. Falls back to window.
  90978. * @returns frame number
  90979. */
  90980. static QueueNewFrame(func: () => void, requester?: any): number;
  90981. /**
  90982. * Ask the browser to promote the current element to fullscreen rendering mode
  90983. * @param element defines the DOM element to promote
  90984. */
  90985. static RequestFullscreen(element: HTMLElement): void;
  90986. /**
  90987. * Asks the browser to exit fullscreen mode
  90988. */
  90989. static ExitFullscreen(): void;
  90990. /**
  90991. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  90992. * @param url define the url we are trying
  90993. * @param element define the dom element where to configure the cors policy
  90994. */
  90995. static SetCorsBehavior(url: string | string[], element: {
  90996. crossOrigin: string | null;
  90997. }): void;
  90998. /**
  90999. * Removes unwanted characters from an url
  91000. * @param url defines the url to clean
  91001. * @returns the cleaned url
  91002. */
  91003. static CleanUrl(url: string): string;
  91004. /**
  91005. * Gets or sets a function used to pre-process url before using them to load assets
  91006. */
  91007. static PreprocessUrl: (url: string) => string;
  91008. /**
  91009. * Loads an image as an HTMLImageElement.
  91010. * @param input url string, ArrayBuffer, or Blob to load
  91011. * @param onLoad callback called when the image successfully loads
  91012. * @param onError callback called when the image fails to load
  91013. * @param offlineProvider offline provider for caching
  91014. * @returns the HTMLImageElement of the loaded image
  91015. */
  91016. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  91017. /**
  91018. * Loads a file
  91019. * @param url url string, ArrayBuffer, or Blob to load
  91020. * @param onSuccess callback called when the file successfully loads
  91021. * @param onProgress callback called while file is loading (if the server supports this mode)
  91022. * @param offlineProvider defines the offline provider for caching
  91023. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  91024. * @param onError callback called when the file fails to load
  91025. * @returns a file request object
  91026. */
  91027. 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;
  91028. /**
  91029. * Load a script (identified by an url). When the url returns, the
  91030. * content of this file is added into a new script element, attached to the DOM (body element)
  91031. * @param scriptUrl defines the url of the script to laod
  91032. * @param onSuccess defines the callback called when the script is loaded
  91033. * @param onError defines the callback to call if an error occurs
  91034. * @param scriptId defines the id of the script element
  91035. */
  91036. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  91037. /**
  91038. * Load an asynchronous script (identified by an url). When the url returns, the
  91039. * content of this file is added into a new script element, attached to the DOM (body element)
  91040. * @param scriptUrl defines the url of the script to laod
  91041. * @param scriptId defines the id of the script element
  91042. * @returns a promise request object
  91043. */
  91044. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Nullable<Promise<boolean>>;
  91045. /**
  91046. * Loads a file from a blob
  91047. * @param fileToLoad defines the blob to use
  91048. * @param callback defines the callback to call when data is loaded
  91049. * @param progressCallback defines the callback to call during loading process
  91050. * @returns a file request object
  91051. */
  91052. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  91053. /**
  91054. * Loads a file
  91055. * @param fileToLoad defines the file to load
  91056. * @param callback defines the callback to call when data is loaded
  91057. * @param progressCallBack defines the callback to call during loading process
  91058. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  91059. * @returns a file request object
  91060. */
  91061. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  91062. /**
  91063. * Creates a data url from a given string content
  91064. * @param content defines the content to convert
  91065. * @returns the new data url link
  91066. */
  91067. static FileAsURL(content: string): string;
  91068. /**
  91069. * Format the given number to a specific decimal format
  91070. * @param value defines the number to format
  91071. * @param decimals defines the number of decimals to use
  91072. * @returns the formatted string
  91073. */
  91074. static Format(value: number, decimals?: number): string;
  91075. /**
  91076. * Checks if a given vector is inside a specific range
  91077. * @param v defines the vector to test
  91078. * @param min defines the minimum range
  91079. * @param max defines the maximum range
  91080. */
  91081. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  91082. /**
  91083. * Tries to copy an object by duplicating every property
  91084. * @param source defines the source object
  91085. * @param destination defines the target object
  91086. * @param doNotCopyList defines a list of properties to avoid
  91087. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  91088. */
  91089. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  91090. /**
  91091. * Gets a boolean indicating if the given object has no own property
  91092. * @param obj defines the object to test
  91093. * @returns true if object has no own property
  91094. */
  91095. static IsEmpty(obj: any): boolean;
  91096. /**
  91097. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  91098. * @param str Source string
  91099. * @param suffix Suffix to search for in the source string
  91100. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  91101. */
  91102. static EndsWith(str: string, suffix: string): boolean;
  91103. /**
  91104. * Function used to register events at window level
  91105. * @param events defines the events to register
  91106. */
  91107. static RegisterTopRootEvents(events: {
  91108. name: string;
  91109. handler: Nullable<(e: FocusEvent) => any>;
  91110. }[]): void;
  91111. /**
  91112. * Function used to unregister events from window level
  91113. * @param events defines the events to unregister
  91114. */
  91115. static UnregisterTopRootEvents(events: {
  91116. name: string;
  91117. handler: Nullable<(e: FocusEvent) => any>;
  91118. }[]): void;
  91119. /**
  91120. * @ignore
  91121. */
  91122. static _ScreenshotCanvas: HTMLCanvasElement;
  91123. /**
  91124. * Dumps the current bound framebuffer
  91125. * @param width defines the rendering width
  91126. * @param height defines the rendering height
  91127. * @param engine defines the hosting engine
  91128. * @param successCallback defines the callback triggered once the data are available
  91129. * @param mimeType defines the mime type of the result
  91130. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  91131. */
  91132. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  91133. /**
  91134. * Converts the canvas data to blob.
  91135. * This acts as a polyfill for browsers not supporting the to blob function.
  91136. * @param canvas Defines the canvas to extract the data from
  91137. * @param successCallback Defines the callback triggered once the data are available
  91138. * @param mimeType Defines the mime type of the result
  91139. */
  91140. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  91141. /**
  91142. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  91143. * @param successCallback defines the callback triggered once the data are available
  91144. * @param mimeType defines the mime type of the result
  91145. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  91146. */
  91147. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  91148. /**
  91149. * Downloads a blob in the browser
  91150. * @param blob defines the blob to download
  91151. * @param fileName defines the name of the downloaded file
  91152. */
  91153. static Download(blob: Blob, fileName: string): void;
  91154. /**
  91155. * Captures a screenshot of the current rendering
  91156. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  91157. * @param engine defines the rendering engine
  91158. * @param camera defines the source camera
  91159. * @param size This parameter can be set to a single number or to an object with the
  91160. * following (optional) properties: precision, width, height. If a single number is passed,
  91161. * it will be used for both width and height. If an object is passed, the screenshot size
  91162. * will be derived from the parameters. The precision property is a multiplier allowing
  91163. * rendering at a higher or lower resolution
  91164. * @param successCallback defines the callback receives a single parameter which contains the
  91165. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  91166. * src parameter of an <img> to display it
  91167. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  91168. * Check your browser for supported MIME types
  91169. */
  91170. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  91171. /**
  91172. * Generates an image screenshot from the specified camera.
  91173. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  91174. * @param engine The engine to use for rendering
  91175. * @param camera The camera to use for rendering
  91176. * @param size This parameter can be set to a single number or to an object with the
  91177. * following (optional) properties: precision, width, height. If a single number is passed,
  91178. * it will be used for both width and height. If an object is passed, the screenshot size
  91179. * will be derived from the parameters. The precision property is a multiplier allowing
  91180. * rendering at a higher or lower resolution
  91181. * @param successCallback The callback receives a single parameter which contains the
  91182. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  91183. * src parameter of an <img> to display it
  91184. * @param mimeType The MIME type of the screenshot image (default: image/png).
  91185. * Check your browser for supported MIME types
  91186. * @param samples Texture samples (default: 1)
  91187. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  91188. * @param fileName A name for for the downloaded file.
  91189. */
  91190. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  91191. /**
  91192. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  91193. * Be aware Math.random() could cause collisions, but:
  91194. * "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"
  91195. * @returns a pseudo random id
  91196. */
  91197. static RandomId(): string;
  91198. /**
  91199. * Test if the given uri is a base64 string
  91200. * @param uri The uri to test
  91201. * @return True if the uri is a base64 string or false otherwise
  91202. */
  91203. static IsBase64(uri: string): boolean;
  91204. /**
  91205. * Decode the given base64 uri.
  91206. * @param uri The uri to decode
  91207. * @return The decoded base64 data.
  91208. */
  91209. static DecodeBase64(uri: string): ArrayBuffer;
  91210. /**
  91211. * Gets the absolute url.
  91212. * @param url the input url
  91213. * @return the absolute url
  91214. */
  91215. static GetAbsoluteUrl(url: string): string;
  91216. /**
  91217. * No log
  91218. */
  91219. static readonly NoneLogLevel: number;
  91220. /**
  91221. * Only message logs
  91222. */
  91223. static readonly MessageLogLevel: number;
  91224. /**
  91225. * Only warning logs
  91226. */
  91227. static readonly WarningLogLevel: number;
  91228. /**
  91229. * Only error logs
  91230. */
  91231. static readonly ErrorLogLevel: number;
  91232. /**
  91233. * All logs
  91234. */
  91235. static readonly AllLogLevel: number;
  91236. /**
  91237. * Gets a value indicating the number of loading errors
  91238. * @ignorenaming
  91239. */
  91240. static readonly errorsCount: number;
  91241. /**
  91242. * Callback called when a new log is added
  91243. */
  91244. static OnNewCacheEntry: (entry: string) => void;
  91245. /**
  91246. * Log a message to the console
  91247. * @param message defines the message to log
  91248. */
  91249. static Log(message: string): void;
  91250. /**
  91251. * Write a warning message to the console
  91252. * @param message defines the message to log
  91253. */
  91254. static Warn(message: string): void;
  91255. /**
  91256. * Write an error message to the console
  91257. * @param message defines the message to log
  91258. */
  91259. static Error(message: string): void;
  91260. /**
  91261. * Gets current log cache (list of logs)
  91262. */
  91263. static readonly LogCache: string;
  91264. /**
  91265. * Clears the log cache
  91266. */
  91267. static ClearLogCache(): void;
  91268. /**
  91269. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  91270. */
  91271. static LogLevels: number;
  91272. /**
  91273. * Checks if the loaded document was accessed via `file:`-Protocol.
  91274. * @returns boolean
  91275. */
  91276. static IsFileURL(): boolean;
  91277. /**
  91278. * Checks if the window object exists
  91279. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  91280. */
  91281. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  91282. /**
  91283. * No performance log
  91284. */
  91285. static readonly PerformanceNoneLogLevel: number;
  91286. /**
  91287. * Use user marks to log performance
  91288. */
  91289. static readonly PerformanceUserMarkLogLevel: number;
  91290. /**
  91291. * Log performance to the console
  91292. */
  91293. static readonly PerformanceConsoleLogLevel: number;
  91294. private static _performance;
  91295. /**
  91296. * Sets the current performance log level
  91297. */
  91298. static PerformanceLogLevel: number;
  91299. private static _StartPerformanceCounterDisabled;
  91300. private static _EndPerformanceCounterDisabled;
  91301. private static _StartUserMark;
  91302. private static _EndUserMark;
  91303. private static _StartPerformanceConsole;
  91304. private static _EndPerformanceConsole;
  91305. /**
  91306. * Starts a performance counter
  91307. */
  91308. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  91309. /**
  91310. * Ends a specific performance coutner
  91311. */
  91312. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  91313. /**
  91314. * Gets either window.performance.now() if supported or Date.now() else
  91315. */
  91316. static readonly Now: number;
  91317. /**
  91318. * This method will return the name of the class used to create the instance of the given object.
  91319. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  91320. * @param object the object to get the class name from
  91321. * @param isType defines if the object is actually a type
  91322. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  91323. */
  91324. static GetClassName(object: any, isType?: boolean): string;
  91325. /**
  91326. * Gets the first element of an array satisfying a given predicate
  91327. * @param array defines the array to browse
  91328. * @param predicate defines the predicate to use
  91329. * @returns null if not found or the element
  91330. */
  91331. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  91332. /**
  91333. * This method will return the name of the full name of the class, including its owning module (if any).
  91334. * 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).
  91335. * @param object the object to get the class name from
  91336. * @param isType defines if the object is actually a type
  91337. * @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.
  91338. * @ignorenaming
  91339. */
  91340. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  91341. /**
  91342. * Returns a promise that resolves after the given amount of time.
  91343. * @param delay Number of milliseconds to delay
  91344. * @returns Promise that resolves after the given amount of time
  91345. */
  91346. static DelayAsync(delay: number): Promise<void>;
  91347. /**
  91348. * Gets the current gradient from an array of IValueGradient
  91349. * @param ratio defines the current ratio to get
  91350. * @param gradients defines the array of IValueGradient
  91351. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  91352. */
  91353. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  91354. }
  91355. /**
  91356. * This class is used to track a performance counter which is number based.
  91357. * The user has access to many properties which give statistics of different nature.
  91358. *
  91359. * The implementer can track two kinds of Performance Counter: time and count.
  91360. * 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.
  91361. * 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.
  91362. */
  91363. export class PerfCounter {
  91364. /**
  91365. * Gets or sets a global boolean to turn on and off all the counters
  91366. */
  91367. static Enabled: boolean;
  91368. /**
  91369. * Returns the smallest value ever
  91370. */
  91371. readonly min: number;
  91372. /**
  91373. * Returns the biggest value ever
  91374. */
  91375. readonly max: number;
  91376. /**
  91377. * Returns the average value since the performance counter is running
  91378. */
  91379. readonly average: number;
  91380. /**
  91381. * Returns the average value of the last second the counter was monitored
  91382. */
  91383. readonly lastSecAverage: number;
  91384. /**
  91385. * Returns the current value
  91386. */
  91387. readonly current: number;
  91388. /**
  91389. * Gets the accumulated total
  91390. */
  91391. readonly total: number;
  91392. /**
  91393. * Gets the total value count
  91394. */
  91395. readonly count: number;
  91396. /**
  91397. * Creates a new counter
  91398. */
  91399. constructor();
  91400. /**
  91401. * Call this method to start monitoring a new frame.
  91402. * 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.
  91403. */
  91404. fetchNewFrame(): void;
  91405. /**
  91406. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  91407. * @param newCount the count value to add to the monitored count
  91408. * @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.
  91409. */
  91410. addCount(newCount: number, fetchResult: boolean): void;
  91411. /**
  91412. * Start monitoring this performance counter
  91413. */
  91414. beginMonitoring(): void;
  91415. /**
  91416. * Compute the time lapsed since the previous beginMonitoring() call.
  91417. * @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
  91418. */
  91419. endMonitoring(newFrame?: boolean): void;
  91420. private _fetchResult;
  91421. private _startMonitoringTime;
  91422. private _min;
  91423. private _max;
  91424. private _average;
  91425. private _current;
  91426. private _totalValueCount;
  91427. private _totalAccumulated;
  91428. private _lastSecAverage;
  91429. private _lastSecAccumulated;
  91430. private _lastSecTime;
  91431. private _lastSecValueCount;
  91432. }
  91433. /**
  91434. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  91435. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  91436. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  91437. * @param name The name of the class, case should be preserved
  91438. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  91439. */
  91440. export function className(name: string, module?: string): (target: Object) => void;
  91441. /**
  91442. * An implementation of a loop for asynchronous functions.
  91443. */
  91444. export class AsyncLoop {
  91445. /**
  91446. * Defines the number of iterations for the loop
  91447. */
  91448. iterations: number;
  91449. /**
  91450. * Defines the current index of the loop.
  91451. */
  91452. index: number;
  91453. private _done;
  91454. private _fn;
  91455. private _successCallback;
  91456. /**
  91457. * Constructor.
  91458. * @param iterations the number of iterations.
  91459. * @param func the function to run each iteration
  91460. * @param successCallback the callback that will be called upon succesful execution
  91461. * @param offset starting offset.
  91462. */
  91463. constructor(
  91464. /**
  91465. * Defines the number of iterations for the loop
  91466. */
  91467. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  91468. /**
  91469. * Execute the next iteration. Must be called after the last iteration was finished.
  91470. */
  91471. executeNext(): void;
  91472. /**
  91473. * Break the loop and run the success callback.
  91474. */
  91475. breakLoop(): void;
  91476. /**
  91477. * Create and run an async loop.
  91478. * @param iterations the number of iterations.
  91479. * @param fn the function to run each iteration
  91480. * @param successCallback the callback that will be called upon succesful execution
  91481. * @param offset starting offset.
  91482. * @returns the created async loop object
  91483. */
  91484. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  91485. /**
  91486. * A for-loop that will run a given number of iterations synchronous and the rest async.
  91487. * @param iterations total number of iterations
  91488. * @param syncedIterations number of synchronous iterations in each async iteration.
  91489. * @param fn the function to call each iteration.
  91490. * @param callback a success call back that will be called when iterating stops.
  91491. * @param breakFunction a break condition (optional)
  91492. * @param timeout timeout settings for the setTimeout function. default - 0.
  91493. * @returns the created async loop object
  91494. */
  91495. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  91496. }
  91497. }
  91498. declare module BABYLON {
  91499. /** @hidden */
  91500. export interface ICollisionCoordinator {
  91501. createCollider(): Collider;
  91502. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  91503. init(scene: Scene): void;
  91504. }
  91505. /** @hidden */
  91506. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  91507. private _scene;
  91508. private _scaledPosition;
  91509. private _scaledVelocity;
  91510. private _finalPosition;
  91511. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  91512. createCollider(): Collider;
  91513. init(scene: Scene): void;
  91514. private _collideWithWorld;
  91515. }
  91516. }
  91517. declare module BABYLON {
  91518. /**
  91519. * Class used to manage all inputs for the scene.
  91520. */
  91521. export class InputManager {
  91522. /** The distance in pixel that you have to move to prevent some events */
  91523. static DragMovementThreshold: number;
  91524. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  91525. static LongPressDelay: number;
  91526. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  91527. static DoubleClickDelay: number;
  91528. /** If you need to check double click without raising a single click at first click, enable this flag */
  91529. static ExclusiveDoubleClickMode: boolean;
  91530. private _wheelEventName;
  91531. private _onPointerMove;
  91532. private _onPointerDown;
  91533. private _onPointerUp;
  91534. private _initClickEvent;
  91535. private _initActionManager;
  91536. private _delayedSimpleClick;
  91537. private _delayedSimpleClickTimeout;
  91538. private _previousDelayedSimpleClickTimeout;
  91539. private _meshPickProceed;
  91540. private _previousButtonPressed;
  91541. private _currentPickResult;
  91542. private _previousPickResult;
  91543. private _totalPointersPressed;
  91544. private _doubleClickOccured;
  91545. private _pointerOverMesh;
  91546. private _pickedDownMesh;
  91547. private _pickedUpMesh;
  91548. private _pointerX;
  91549. private _pointerY;
  91550. private _unTranslatedPointerX;
  91551. private _unTranslatedPointerY;
  91552. private _startingPointerPosition;
  91553. private _previousStartingPointerPosition;
  91554. private _startingPointerTime;
  91555. private _previousStartingPointerTime;
  91556. private _pointerCaptures;
  91557. private _onKeyDown;
  91558. private _onKeyUp;
  91559. private _onCanvasFocusObserver;
  91560. private _onCanvasBlurObserver;
  91561. private _scene;
  91562. /**
  91563. * Creates a new InputManager
  91564. * @param scene defines the hosting scene
  91565. */
  91566. constructor(scene: Scene);
  91567. /**
  91568. * Gets the mesh that is currently under the pointer
  91569. */
  91570. readonly meshUnderPointer: Nullable<AbstractMesh>;
  91571. /**
  91572. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  91573. */
  91574. readonly unTranslatedPointer: Vector2;
  91575. /**
  91576. * Gets or sets the current on-screen X position of the pointer
  91577. */
  91578. pointerX: number;
  91579. /**
  91580. * Gets or sets the current on-screen Y position of the pointer
  91581. */
  91582. pointerY: number;
  91583. private _updatePointerPosition;
  91584. private _processPointerMove;
  91585. private _setRayOnPointerInfo;
  91586. private _checkPrePointerObservable;
  91587. /**
  91588. * Use this method to simulate a pointer move on a mesh
  91589. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  91590. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  91591. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  91592. */
  91593. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  91594. /**
  91595. * Use this method to simulate a pointer down on a mesh
  91596. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  91597. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  91598. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  91599. */
  91600. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  91601. private _processPointerDown;
  91602. /** @hidden */
  91603. _isPointerSwiping(): boolean;
  91604. /**
  91605. * Use this method to simulate a pointer up on a mesh
  91606. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  91607. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  91608. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  91609. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  91610. */
  91611. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  91612. private _processPointerUp;
  91613. /**
  91614. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  91615. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  91616. * @returns true if the pointer was captured
  91617. */
  91618. isPointerCaptured(pointerId?: number): boolean;
  91619. /**
  91620. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  91621. * @param attachUp defines if you want to attach events to pointerup
  91622. * @param attachDown defines if you want to attach events to pointerdown
  91623. * @param attachMove defines if you want to attach events to pointermove
  91624. */
  91625. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  91626. /**
  91627. * Detaches all event handlers
  91628. */
  91629. detachControl(): void;
  91630. /**
  91631. * Force the value of meshUnderPointer
  91632. * @param mesh defines the mesh to use
  91633. */
  91634. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  91635. /**
  91636. * Gets the mesh under the pointer
  91637. * @returns a Mesh or null if no mesh is under the pointer
  91638. */
  91639. getPointerOverMesh(): Nullable<AbstractMesh>;
  91640. }
  91641. }
  91642. declare module BABYLON {
  91643. /**
  91644. * This class defines the direct association between an animation and a target
  91645. */
  91646. export class TargetedAnimation {
  91647. /**
  91648. * Animation to perform
  91649. */
  91650. animation: Animation;
  91651. /**
  91652. * Target to animate
  91653. */
  91654. target: any;
  91655. }
  91656. /**
  91657. * Use this class to create coordinated animations on multiple targets
  91658. */
  91659. export class AnimationGroup implements IDisposable {
  91660. /** The name of the animation group */
  91661. name: string;
  91662. private _scene;
  91663. private _targetedAnimations;
  91664. private _animatables;
  91665. private _from;
  91666. private _to;
  91667. private _isStarted;
  91668. private _isPaused;
  91669. private _speedRatio;
  91670. private _loopAnimation;
  91671. /**
  91672. * Gets or sets the unique id of the node
  91673. */
  91674. uniqueId: number;
  91675. /**
  91676. * This observable will notify when one animation have ended
  91677. */
  91678. onAnimationEndObservable: Observable<TargetedAnimation>;
  91679. /**
  91680. * Observer raised when one animation loops
  91681. */
  91682. onAnimationLoopObservable: Observable<TargetedAnimation>;
  91683. /**
  91684. * This observable will notify when all animations have ended.
  91685. */
  91686. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  91687. /**
  91688. * This observable will notify when all animations have paused.
  91689. */
  91690. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  91691. /**
  91692. * This observable will notify when all animations are playing.
  91693. */
  91694. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  91695. /**
  91696. * Gets the first frame
  91697. */
  91698. readonly from: number;
  91699. /**
  91700. * Gets the last frame
  91701. */
  91702. readonly to: number;
  91703. /**
  91704. * Define if the animations are started
  91705. */
  91706. readonly isStarted: boolean;
  91707. /**
  91708. * Gets a value indicating that the current group is playing
  91709. */
  91710. readonly isPlaying: boolean;
  91711. /**
  91712. * Gets or sets the speed ratio to use for all animations
  91713. */
  91714. /**
  91715. * Gets or sets the speed ratio to use for all animations
  91716. */
  91717. speedRatio: number;
  91718. /**
  91719. * Gets or sets if all animations should loop or not
  91720. */
  91721. loopAnimation: boolean;
  91722. /**
  91723. * Gets the targeted animations for this animation group
  91724. */
  91725. readonly targetedAnimations: Array<TargetedAnimation>;
  91726. /**
  91727. * returning the list of animatables controlled by this animation group.
  91728. */
  91729. readonly animatables: Array<Animatable>;
  91730. /**
  91731. * Instantiates a new Animation Group.
  91732. * This helps managing several animations at once.
  91733. * @see http://doc.babylonjs.com/how_to/group
  91734. * @param name Defines the name of the group
  91735. * @param scene Defines the scene the group belongs to
  91736. */
  91737. constructor(
  91738. /** The name of the animation group */
  91739. name: string, scene?: Nullable<Scene>);
  91740. /**
  91741. * Add an animation (with its target) in the group
  91742. * @param animation defines the animation we want to add
  91743. * @param target defines the target of the animation
  91744. * @returns the TargetedAnimation object
  91745. */
  91746. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  91747. /**
  91748. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  91749. * It can add constant keys at begin or end
  91750. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  91751. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  91752. * @returns the animation group
  91753. */
  91754. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  91755. /**
  91756. * Start all animations on given targets
  91757. * @param loop defines if animations must loop
  91758. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  91759. * @param from defines the from key (optional)
  91760. * @param to defines the to key (optional)
  91761. * @returns the current animation group
  91762. */
  91763. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  91764. /**
  91765. * Pause all animations
  91766. * @returns the animation group
  91767. */
  91768. pause(): AnimationGroup;
  91769. /**
  91770. * Play all animations to initial state
  91771. * This function will start() the animations if they were not started or will restart() them if they were paused
  91772. * @param loop defines if animations must loop
  91773. * @returns the animation group
  91774. */
  91775. play(loop?: boolean): AnimationGroup;
  91776. /**
  91777. * Reset all animations to initial state
  91778. * @returns the animation group
  91779. */
  91780. reset(): AnimationGroup;
  91781. /**
  91782. * Restart animations from key 0
  91783. * @returns the animation group
  91784. */
  91785. restart(): AnimationGroup;
  91786. /**
  91787. * Stop all animations
  91788. * @returns the animation group
  91789. */
  91790. stop(): AnimationGroup;
  91791. /**
  91792. * Set animation weight for all animatables
  91793. * @param weight defines the weight to use
  91794. * @return the animationGroup
  91795. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  91796. */
  91797. setWeightForAllAnimatables(weight: number): AnimationGroup;
  91798. /**
  91799. * Synchronize and normalize all animatables with a source animatable
  91800. * @param root defines the root animatable to synchronize with
  91801. * @return the animationGroup
  91802. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  91803. */
  91804. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  91805. /**
  91806. * Goes to a specific frame in this animation group
  91807. * @param frame the frame number to go to
  91808. * @return the animationGroup
  91809. */
  91810. goToFrame(frame: number): AnimationGroup;
  91811. /**
  91812. * Dispose all associated resources
  91813. */
  91814. dispose(): void;
  91815. private _checkAnimationGroupEnded;
  91816. /**
  91817. * Clone the current animation group and returns a copy
  91818. * @param newName defines the name of the new group
  91819. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  91820. * @returns the new aniamtion group
  91821. */
  91822. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  91823. /**
  91824. * Returns a new AnimationGroup object parsed from the source provided.
  91825. * @param parsedAnimationGroup defines the source
  91826. * @param scene defines the scene that will receive the animationGroup
  91827. * @returns a new AnimationGroup
  91828. */
  91829. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  91830. /**
  91831. * Returns the string "AnimationGroup"
  91832. * @returns "AnimationGroup"
  91833. */
  91834. getClassName(): string;
  91835. /**
  91836. * Creates a detailled string about the object
  91837. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  91838. * @returns a string representing the object
  91839. */
  91840. toString(fullDetails?: boolean): string;
  91841. }
  91842. }
  91843. declare module BABYLON {
  91844. /**
  91845. * Define an interface for all classes that will hold resources
  91846. */
  91847. export interface IDisposable {
  91848. /**
  91849. * Releases all held resources
  91850. */
  91851. dispose(): void;
  91852. }
  91853. /** Interface defining initialization parameters for Scene class */
  91854. export interface SceneOptions {
  91855. /**
  91856. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  91857. * It will improve performance when the number of geometries becomes important.
  91858. */
  91859. useGeometryUniqueIdsMap?: boolean;
  91860. /**
  91861. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  91862. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  91863. */
  91864. useMaterialMeshMap?: boolean;
  91865. /**
  91866. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  91867. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  91868. */
  91869. useClonedMeshhMap?: boolean;
  91870. }
  91871. /**
  91872. * Represents a scene to be rendered by the engine.
  91873. * @see http://doc.babylonjs.com/features/scene
  91874. */
  91875. export class Scene extends AbstractScene implements IAnimatable {
  91876. private static _uniqueIdCounter;
  91877. /** The fog is deactivated */
  91878. static readonly FOGMODE_NONE: number;
  91879. /** The fog density is following an exponential function */
  91880. static readonly FOGMODE_EXP: number;
  91881. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  91882. static readonly FOGMODE_EXP2: number;
  91883. /** The fog density is following a linear function. */
  91884. static readonly FOGMODE_LINEAR: number;
  91885. /**
  91886. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  91887. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  91888. */
  91889. static MinDeltaTime: number;
  91890. /**
  91891. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  91892. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  91893. */
  91894. static MaxDeltaTime: number;
  91895. /**
  91896. * Factory used to create the default material.
  91897. * @param name The name of the material to create
  91898. * @param scene The scene to create the material for
  91899. * @returns The default material
  91900. */
  91901. static DefaultMaterialFactory(scene: Scene): Material;
  91902. /**
  91903. * Factory used to create the a collision coordinator.
  91904. * @returns The collision coordinator
  91905. */
  91906. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  91907. /** @hidden */
  91908. _inputManager: InputManager;
  91909. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  91910. cameraToUseForPointers: Nullable<Camera>;
  91911. /** @hidden */
  91912. readonly _isScene: boolean;
  91913. /**
  91914. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  91915. */
  91916. autoClear: boolean;
  91917. /**
  91918. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  91919. */
  91920. autoClearDepthAndStencil: boolean;
  91921. /**
  91922. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  91923. */
  91924. clearColor: Color4;
  91925. /**
  91926. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  91927. */
  91928. ambientColor: Color3;
  91929. /**
  91930. * This is use to store the default BRDF lookup for PBR materials in your scene.
  91931. * It should only be one of the following (if not the default embedded one):
  91932. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  91933. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  91934. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  91935. * The material properties need to be setup according to the type of texture in use.
  91936. */
  91937. environmentBRDFTexture: BaseTexture;
  91938. /** @hidden */
  91939. protected _environmentTexture: Nullable<BaseTexture>;
  91940. /**
  91941. * Texture used in all pbr material as the reflection texture.
  91942. * As in the majority of the scene they are the same (exception for multi room and so on),
  91943. * this is easier to reference from here than from all the materials.
  91944. */
  91945. /**
  91946. * Texture used in all pbr material as the reflection texture.
  91947. * As in the majority of the scene they are the same (exception for multi room and so on),
  91948. * this is easier to set here than in all the materials.
  91949. */
  91950. environmentTexture: Nullable<BaseTexture>;
  91951. /** @hidden */
  91952. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  91953. /**
  91954. * Default image processing configuration used either in the rendering
  91955. * Forward main pass or through the imageProcessingPostProcess if present.
  91956. * As in the majority of the scene they are the same (exception for multi camera),
  91957. * this is easier to reference from here than from all the materials and post process.
  91958. *
  91959. * No setter as we it is a shared configuration, you can set the values instead.
  91960. */
  91961. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  91962. private _forceWireframe;
  91963. /**
  91964. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  91965. */
  91966. forceWireframe: boolean;
  91967. private _forcePointsCloud;
  91968. /**
  91969. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  91970. */
  91971. forcePointsCloud: boolean;
  91972. /**
  91973. * Gets or sets the active clipplane 1
  91974. */
  91975. clipPlane: Nullable<Plane>;
  91976. /**
  91977. * Gets or sets the active clipplane 2
  91978. */
  91979. clipPlane2: Nullable<Plane>;
  91980. /**
  91981. * Gets or sets the active clipplane 3
  91982. */
  91983. clipPlane3: Nullable<Plane>;
  91984. /**
  91985. * Gets or sets the active clipplane 4
  91986. */
  91987. clipPlane4: Nullable<Plane>;
  91988. /**
  91989. * Gets or sets a boolean indicating if animations are enabled
  91990. */
  91991. animationsEnabled: boolean;
  91992. private _animationPropertiesOverride;
  91993. /**
  91994. * Gets or sets the animation properties override
  91995. */
  91996. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  91997. /**
  91998. * Gets or sets a boolean indicating if a constant deltatime has to be used
  91999. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  92000. */
  92001. useConstantAnimationDeltaTime: boolean;
  92002. /**
  92003. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  92004. * Please note that it requires to run a ray cast through the scene on every frame
  92005. */
  92006. constantlyUpdateMeshUnderPointer: boolean;
  92007. /**
  92008. * Defines the HTML cursor to use when hovering over interactive elements
  92009. */
  92010. hoverCursor: string;
  92011. /**
  92012. * Defines the HTML default cursor to use (empty by default)
  92013. */
  92014. defaultCursor: string;
  92015. /**
  92016. * This is used to call preventDefault() on pointer down
  92017. * in order to block unwanted artifacts like system double clicks
  92018. */
  92019. preventDefaultOnPointerDown: boolean;
  92020. /**
  92021. * This is used to call preventDefault() on pointer up
  92022. * in order to block unwanted artifacts like system double clicks
  92023. */
  92024. preventDefaultOnPointerUp: boolean;
  92025. /**
  92026. * Gets or sets user defined metadata
  92027. */
  92028. metadata: any;
  92029. /**
  92030. * For internal use only. Please do not use.
  92031. */
  92032. reservedDataStore: any;
  92033. /**
  92034. * Gets the name of the plugin used to load this scene (null by default)
  92035. */
  92036. loadingPluginName: string;
  92037. /**
  92038. * Use this array to add regular expressions used to disable offline support for specific urls
  92039. */
  92040. disableOfflineSupportExceptionRules: RegExp[];
  92041. /**
  92042. * An event triggered when the scene is disposed.
  92043. */
  92044. onDisposeObservable: Observable<Scene>;
  92045. private _onDisposeObserver;
  92046. /** Sets a function to be executed when this scene is disposed. */
  92047. onDispose: () => void;
  92048. /**
  92049. * An event triggered before rendering the scene (right after animations and physics)
  92050. */
  92051. onBeforeRenderObservable: Observable<Scene>;
  92052. private _onBeforeRenderObserver;
  92053. /** Sets a function to be executed before rendering this scene */
  92054. beforeRender: Nullable<() => void>;
  92055. /**
  92056. * An event triggered after rendering the scene
  92057. */
  92058. onAfterRenderObservable: Observable<Scene>;
  92059. private _onAfterRenderObserver;
  92060. /** Sets a function to be executed after rendering this scene */
  92061. afterRender: Nullable<() => void>;
  92062. /**
  92063. * An event triggered before animating the scene
  92064. */
  92065. onBeforeAnimationsObservable: Observable<Scene>;
  92066. /**
  92067. * An event triggered after animations processing
  92068. */
  92069. onAfterAnimationsObservable: Observable<Scene>;
  92070. /**
  92071. * An event triggered before draw calls are ready to be sent
  92072. */
  92073. onBeforeDrawPhaseObservable: Observable<Scene>;
  92074. /**
  92075. * An event triggered after draw calls have been sent
  92076. */
  92077. onAfterDrawPhaseObservable: Observable<Scene>;
  92078. /**
  92079. * An event triggered when the scene is ready
  92080. */
  92081. onReadyObservable: Observable<Scene>;
  92082. /**
  92083. * An event triggered before rendering a camera
  92084. */
  92085. onBeforeCameraRenderObservable: Observable<Camera>;
  92086. private _onBeforeCameraRenderObserver;
  92087. /** Sets a function to be executed before rendering a camera*/
  92088. beforeCameraRender: () => void;
  92089. /**
  92090. * An event triggered after rendering a camera
  92091. */
  92092. onAfterCameraRenderObservable: Observable<Camera>;
  92093. private _onAfterCameraRenderObserver;
  92094. /** Sets a function to be executed after rendering a camera*/
  92095. afterCameraRender: () => void;
  92096. /**
  92097. * An event triggered when active meshes evaluation is about to start
  92098. */
  92099. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  92100. /**
  92101. * An event triggered when active meshes evaluation is done
  92102. */
  92103. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  92104. /**
  92105. * An event triggered when particles rendering is about to start
  92106. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  92107. */
  92108. onBeforeParticlesRenderingObservable: Observable<Scene>;
  92109. /**
  92110. * An event triggered when particles rendering is done
  92111. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  92112. */
  92113. onAfterParticlesRenderingObservable: Observable<Scene>;
  92114. /**
  92115. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  92116. */
  92117. onDataLoadedObservable: Observable<Scene>;
  92118. /**
  92119. * An event triggered when a camera is created
  92120. */
  92121. onNewCameraAddedObservable: Observable<Camera>;
  92122. /**
  92123. * An event triggered when a camera is removed
  92124. */
  92125. onCameraRemovedObservable: Observable<Camera>;
  92126. /**
  92127. * An event triggered when a light is created
  92128. */
  92129. onNewLightAddedObservable: Observable<Light>;
  92130. /**
  92131. * An event triggered when a light is removed
  92132. */
  92133. onLightRemovedObservable: Observable<Light>;
  92134. /**
  92135. * An event triggered when a geometry is created
  92136. */
  92137. onNewGeometryAddedObservable: Observable<Geometry>;
  92138. /**
  92139. * An event triggered when a geometry is removed
  92140. */
  92141. onGeometryRemovedObservable: Observable<Geometry>;
  92142. /**
  92143. * An event triggered when a transform node is created
  92144. */
  92145. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  92146. /**
  92147. * An event triggered when a transform node is removed
  92148. */
  92149. onTransformNodeRemovedObservable: Observable<TransformNode>;
  92150. /**
  92151. * An event triggered when a mesh is created
  92152. */
  92153. onNewMeshAddedObservable: Observable<AbstractMesh>;
  92154. /**
  92155. * An event triggered when a mesh is removed
  92156. */
  92157. onMeshRemovedObservable: Observable<AbstractMesh>;
  92158. /**
  92159. * An event triggered when a skeleton is created
  92160. */
  92161. onNewSkeletonAddedObservable: Observable<Skeleton>;
  92162. /**
  92163. * An event triggered when a skeleton is removed
  92164. */
  92165. onSkeletonRemovedObservable: Observable<Skeleton>;
  92166. /**
  92167. * An event triggered when a material is created
  92168. */
  92169. onNewMaterialAddedObservable: Observable<Material>;
  92170. /**
  92171. * An event triggered when a material is removed
  92172. */
  92173. onMaterialRemovedObservable: Observable<Material>;
  92174. /**
  92175. * An event triggered when a texture is created
  92176. */
  92177. onNewTextureAddedObservable: Observable<BaseTexture>;
  92178. /**
  92179. * An event triggered when a texture is removed
  92180. */
  92181. onTextureRemovedObservable: Observable<BaseTexture>;
  92182. /**
  92183. * An event triggered when render targets are about to be rendered
  92184. * Can happen multiple times per frame.
  92185. */
  92186. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  92187. /**
  92188. * An event triggered when render targets were rendered.
  92189. * Can happen multiple times per frame.
  92190. */
  92191. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  92192. /**
  92193. * An event triggered before calculating deterministic simulation step
  92194. */
  92195. onBeforeStepObservable: Observable<Scene>;
  92196. /**
  92197. * An event triggered after calculating deterministic simulation step
  92198. */
  92199. onAfterStepObservable: Observable<Scene>;
  92200. /**
  92201. * An event triggered when the activeCamera property is updated
  92202. */
  92203. onActiveCameraChanged: Observable<Scene>;
  92204. /**
  92205. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  92206. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  92207. * 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)
  92208. */
  92209. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  92210. /**
  92211. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  92212. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  92213. * 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)
  92214. */
  92215. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  92216. /**
  92217. * This Observable will when a mesh has been imported into the scene.
  92218. */
  92219. onMeshImportedObservable: Observable<AbstractMesh>;
  92220. /**
  92221. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  92222. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  92223. */
  92224. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  92225. /** @hidden */
  92226. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  92227. /**
  92228. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  92229. */
  92230. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  92231. /**
  92232. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  92233. */
  92234. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  92235. /**
  92236. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  92237. */
  92238. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  92239. /** Callback called when a pointer move is detected */
  92240. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  92241. /** Callback called when a pointer down is detected */
  92242. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  92243. /** Callback called when a pointer up is detected */
  92244. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  92245. /** Callback called when a pointer pick is detected */
  92246. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  92247. /**
  92248. * 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).
  92249. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  92250. */
  92251. onPrePointerObservable: Observable<PointerInfoPre>;
  92252. /**
  92253. * Observable event triggered each time an input event is received from the rendering canvas
  92254. */
  92255. onPointerObservable: Observable<PointerInfo>;
  92256. /**
  92257. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  92258. */
  92259. readonly unTranslatedPointer: Vector2;
  92260. /**
  92261. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  92262. */
  92263. static DragMovementThreshold: number;
  92264. /**
  92265. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  92266. */
  92267. static LongPressDelay: number;
  92268. /**
  92269. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  92270. */
  92271. static DoubleClickDelay: number;
  92272. /** If you need to check double click without raising a single click at first click, enable this flag */
  92273. static ExclusiveDoubleClickMode: boolean;
  92274. /** @hidden */
  92275. _mirroredCameraPosition: Nullable<Vector3>;
  92276. /**
  92277. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  92278. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  92279. */
  92280. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  92281. /**
  92282. * Observable event triggered each time an keyboard event is received from the hosting window
  92283. */
  92284. onKeyboardObservable: Observable<KeyboardInfo>;
  92285. private _useRightHandedSystem;
  92286. /**
  92287. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  92288. */
  92289. useRightHandedSystem: boolean;
  92290. private _timeAccumulator;
  92291. private _currentStepId;
  92292. private _currentInternalStep;
  92293. /**
  92294. * Sets the step Id used by deterministic lock step
  92295. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  92296. * @param newStepId defines the step Id
  92297. */
  92298. setStepId(newStepId: number): void;
  92299. /**
  92300. * Gets the step Id used by deterministic lock step
  92301. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  92302. * @returns the step Id
  92303. */
  92304. getStepId(): number;
  92305. /**
  92306. * Gets the internal step used by deterministic lock step
  92307. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  92308. * @returns the internal step
  92309. */
  92310. getInternalStep(): number;
  92311. private _fogEnabled;
  92312. /**
  92313. * Gets or sets a boolean indicating if fog is enabled on this scene
  92314. * @see http://doc.babylonjs.com/babylon101/environment#fog
  92315. * (Default is true)
  92316. */
  92317. fogEnabled: boolean;
  92318. private _fogMode;
  92319. /**
  92320. * Gets or sets the fog mode to use
  92321. * @see http://doc.babylonjs.com/babylon101/environment#fog
  92322. * | mode | value |
  92323. * | --- | --- |
  92324. * | FOGMODE_NONE | 0 |
  92325. * | FOGMODE_EXP | 1 |
  92326. * | FOGMODE_EXP2 | 2 |
  92327. * | FOGMODE_LINEAR | 3 |
  92328. */
  92329. fogMode: number;
  92330. /**
  92331. * Gets or sets the fog color to use
  92332. * @see http://doc.babylonjs.com/babylon101/environment#fog
  92333. * (Default is Color3(0.2, 0.2, 0.3))
  92334. */
  92335. fogColor: Color3;
  92336. /**
  92337. * Gets or sets the fog density to use
  92338. * @see http://doc.babylonjs.com/babylon101/environment#fog
  92339. * (Default is 0.1)
  92340. */
  92341. fogDensity: number;
  92342. /**
  92343. * Gets or sets the fog start distance to use
  92344. * @see http://doc.babylonjs.com/babylon101/environment#fog
  92345. * (Default is 0)
  92346. */
  92347. fogStart: number;
  92348. /**
  92349. * Gets or sets the fog end distance to use
  92350. * @see http://doc.babylonjs.com/babylon101/environment#fog
  92351. * (Default is 1000)
  92352. */
  92353. fogEnd: number;
  92354. private _shadowsEnabled;
  92355. /**
  92356. * Gets or sets a boolean indicating if shadows are enabled on this scene
  92357. */
  92358. shadowsEnabled: boolean;
  92359. private _lightsEnabled;
  92360. /**
  92361. * Gets or sets a boolean indicating if lights are enabled on this scene
  92362. */
  92363. lightsEnabled: boolean;
  92364. /** All of the active cameras added to this scene. */
  92365. activeCameras: Camera[];
  92366. /** @hidden */
  92367. _activeCamera: Nullable<Camera>;
  92368. /** Gets or sets the current active camera */
  92369. activeCamera: Nullable<Camera>;
  92370. private _defaultMaterial;
  92371. /** The default material used on meshes when no material is affected */
  92372. /** The default material used on meshes when no material is affected */
  92373. defaultMaterial: Material;
  92374. private _texturesEnabled;
  92375. /**
  92376. * Gets or sets a boolean indicating if textures are enabled on this scene
  92377. */
  92378. texturesEnabled: boolean;
  92379. /**
  92380. * Gets or sets a boolean indicating if particles are enabled on this scene
  92381. */
  92382. particlesEnabled: boolean;
  92383. /**
  92384. * Gets or sets a boolean indicating if sprites are enabled on this scene
  92385. */
  92386. spritesEnabled: boolean;
  92387. private _skeletonsEnabled;
  92388. /**
  92389. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  92390. */
  92391. skeletonsEnabled: boolean;
  92392. /**
  92393. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  92394. */
  92395. lensFlaresEnabled: boolean;
  92396. /**
  92397. * Gets or sets a boolean indicating if collisions are enabled on this scene
  92398. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  92399. */
  92400. collisionsEnabled: boolean;
  92401. private _collisionCoordinator;
  92402. /** @hidden */
  92403. readonly collisionCoordinator: ICollisionCoordinator;
  92404. /**
  92405. * Defines the gravity applied to this scene (used only for collisions)
  92406. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  92407. */
  92408. gravity: Vector3;
  92409. /**
  92410. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  92411. */
  92412. postProcessesEnabled: boolean;
  92413. /**
  92414. * The list of postprocesses added to the scene
  92415. */
  92416. postProcesses: PostProcess[];
  92417. /**
  92418. * Gets the current postprocess manager
  92419. */
  92420. postProcessManager: PostProcessManager;
  92421. /**
  92422. * Gets or sets a boolean indicating if render targets are enabled on this scene
  92423. */
  92424. renderTargetsEnabled: boolean;
  92425. /**
  92426. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  92427. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  92428. */
  92429. dumpNextRenderTargets: boolean;
  92430. /**
  92431. * The list of user defined render targets added to the scene
  92432. */
  92433. customRenderTargets: RenderTargetTexture[];
  92434. /**
  92435. * Defines if texture loading must be delayed
  92436. * If true, textures will only be loaded when they need to be rendered
  92437. */
  92438. useDelayedTextureLoading: boolean;
  92439. /**
  92440. * Gets the list of meshes imported to the scene through SceneLoader
  92441. */
  92442. importedMeshesFiles: String[];
  92443. /**
  92444. * Gets or sets a boolean indicating if probes are enabled on this scene
  92445. */
  92446. probesEnabled: boolean;
  92447. /**
  92448. * Gets or sets the current offline provider to use to store scene data
  92449. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  92450. */
  92451. offlineProvider: IOfflineProvider;
  92452. /**
  92453. * Gets or sets the action manager associated with the scene
  92454. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  92455. */
  92456. actionManager: AbstractActionManager;
  92457. private _meshesForIntersections;
  92458. /**
  92459. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  92460. */
  92461. proceduralTexturesEnabled: boolean;
  92462. private _engine;
  92463. private _totalVertices;
  92464. /** @hidden */
  92465. _activeIndices: PerfCounter;
  92466. /** @hidden */
  92467. _activeParticles: PerfCounter;
  92468. /** @hidden */
  92469. _activeBones: PerfCounter;
  92470. private _animationRatio;
  92471. /** @hidden */
  92472. _animationTimeLast: number;
  92473. /** @hidden */
  92474. _animationTime: number;
  92475. /**
  92476. * Gets or sets a general scale for animation speed
  92477. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  92478. */
  92479. animationTimeScale: number;
  92480. /** @hidden */
  92481. _cachedMaterial: Nullable<Material>;
  92482. /** @hidden */
  92483. _cachedEffect: Nullable<Effect>;
  92484. /** @hidden */
  92485. _cachedVisibility: Nullable<number>;
  92486. private _renderId;
  92487. private _frameId;
  92488. private _executeWhenReadyTimeoutId;
  92489. private _intermediateRendering;
  92490. private _viewUpdateFlag;
  92491. private _projectionUpdateFlag;
  92492. /** @hidden */
  92493. _toBeDisposed: Nullable<IDisposable>[];
  92494. private _activeRequests;
  92495. /** @hidden */
  92496. _pendingData: any[];
  92497. private _isDisposed;
  92498. /**
  92499. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  92500. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  92501. */
  92502. dispatchAllSubMeshesOfActiveMeshes: boolean;
  92503. private _activeMeshes;
  92504. private _processedMaterials;
  92505. private _renderTargets;
  92506. /** @hidden */
  92507. _activeParticleSystems: SmartArray<IParticleSystem>;
  92508. private _activeSkeletons;
  92509. private _softwareSkinnedMeshes;
  92510. private _renderingManager;
  92511. /** @hidden */
  92512. _activeAnimatables: Animatable[];
  92513. private _transformMatrix;
  92514. private _sceneUbo;
  92515. /** @hidden */
  92516. _viewMatrix: Matrix;
  92517. private _projectionMatrix;
  92518. /** @hidden */
  92519. _forcedViewPosition: Nullable<Vector3>;
  92520. /** @hidden */
  92521. _frustumPlanes: Plane[];
  92522. /**
  92523. * Gets the list of frustum planes (built from the active camera)
  92524. */
  92525. readonly frustumPlanes: Plane[];
  92526. /**
  92527. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  92528. * This is useful if there are more lights that the maximum simulteanous authorized
  92529. */
  92530. requireLightSorting: boolean;
  92531. /** @hidden */
  92532. readonly useMaterialMeshMap: boolean;
  92533. /** @hidden */
  92534. readonly useClonedMeshhMap: boolean;
  92535. private _externalData;
  92536. private _uid;
  92537. /**
  92538. * @hidden
  92539. * Backing store of defined scene components.
  92540. */
  92541. _components: ISceneComponent[];
  92542. /**
  92543. * @hidden
  92544. * Backing store of defined scene components.
  92545. */
  92546. _serializableComponents: ISceneSerializableComponent[];
  92547. /**
  92548. * List of components to register on the next registration step.
  92549. */
  92550. private _transientComponents;
  92551. /**
  92552. * Registers the transient components if needed.
  92553. */
  92554. private _registerTransientComponents;
  92555. /**
  92556. * @hidden
  92557. * Add a component to the scene.
  92558. * Note that the ccomponent could be registered on th next frame if this is called after
  92559. * the register component stage.
  92560. * @param component Defines the component to add to the scene
  92561. */
  92562. _addComponent(component: ISceneComponent): void;
  92563. /**
  92564. * @hidden
  92565. * Gets a component from the scene.
  92566. * @param name defines the name of the component to retrieve
  92567. * @returns the component or null if not present
  92568. */
  92569. _getComponent(name: string): Nullable<ISceneComponent>;
  92570. /**
  92571. * @hidden
  92572. * Defines the actions happening before camera updates.
  92573. */
  92574. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  92575. /**
  92576. * @hidden
  92577. * Defines the actions happening before clear the canvas.
  92578. */
  92579. _beforeClearStage: Stage<SimpleStageAction>;
  92580. /**
  92581. * @hidden
  92582. * Defines the actions when collecting render targets for the frame.
  92583. */
  92584. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  92585. /**
  92586. * @hidden
  92587. * Defines the actions happening for one camera in the frame.
  92588. */
  92589. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  92590. /**
  92591. * @hidden
  92592. * Defines the actions happening during the per mesh ready checks.
  92593. */
  92594. _isReadyForMeshStage: Stage<MeshStageAction>;
  92595. /**
  92596. * @hidden
  92597. * Defines the actions happening before evaluate active mesh checks.
  92598. */
  92599. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  92600. /**
  92601. * @hidden
  92602. * Defines the actions happening during the evaluate sub mesh checks.
  92603. */
  92604. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  92605. /**
  92606. * @hidden
  92607. * Defines the actions happening during the active mesh stage.
  92608. */
  92609. _activeMeshStage: Stage<ActiveMeshStageAction>;
  92610. /**
  92611. * @hidden
  92612. * Defines the actions happening during the per camera render target step.
  92613. */
  92614. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  92615. /**
  92616. * @hidden
  92617. * Defines the actions happening just before the active camera is drawing.
  92618. */
  92619. _beforeCameraDrawStage: Stage<CameraStageAction>;
  92620. /**
  92621. * @hidden
  92622. * Defines the actions happening just before a render target is drawing.
  92623. */
  92624. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  92625. /**
  92626. * @hidden
  92627. * Defines the actions happening just before a rendering group is drawing.
  92628. */
  92629. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  92630. /**
  92631. * @hidden
  92632. * Defines the actions happening just before a mesh is drawing.
  92633. */
  92634. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  92635. /**
  92636. * @hidden
  92637. * Defines the actions happening just after a mesh has been drawn.
  92638. */
  92639. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  92640. /**
  92641. * @hidden
  92642. * Defines the actions happening just after a rendering group has been drawn.
  92643. */
  92644. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  92645. /**
  92646. * @hidden
  92647. * Defines the actions happening just after the active camera has been drawn.
  92648. */
  92649. _afterCameraDrawStage: Stage<CameraStageAction>;
  92650. /**
  92651. * @hidden
  92652. * Defines the actions happening just after a render target has been drawn.
  92653. */
  92654. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  92655. /**
  92656. * @hidden
  92657. * Defines the actions happening just after rendering all cameras and computing intersections.
  92658. */
  92659. _afterRenderStage: Stage<SimpleStageAction>;
  92660. /**
  92661. * @hidden
  92662. * Defines the actions happening when a pointer move event happens.
  92663. */
  92664. _pointerMoveStage: Stage<PointerMoveStageAction>;
  92665. /**
  92666. * @hidden
  92667. * Defines the actions happening when a pointer down event happens.
  92668. */
  92669. _pointerDownStage: Stage<PointerUpDownStageAction>;
  92670. /**
  92671. * @hidden
  92672. * Defines the actions happening when a pointer up event happens.
  92673. */
  92674. _pointerUpStage: Stage<PointerUpDownStageAction>;
  92675. /**
  92676. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  92677. */
  92678. private geometriesByUniqueId;
  92679. /**
  92680. * Creates a new Scene
  92681. * @param engine defines the engine to use to render this scene
  92682. * @param options defines the scene options
  92683. */
  92684. constructor(engine: Engine, options?: SceneOptions);
  92685. /**
  92686. * Gets a string idenfifying the name of the class
  92687. * @returns "Scene" string
  92688. */
  92689. getClassName(): string;
  92690. private _defaultMeshCandidates;
  92691. /**
  92692. * @hidden
  92693. */
  92694. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  92695. private _defaultSubMeshCandidates;
  92696. /**
  92697. * @hidden
  92698. */
  92699. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  92700. /**
  92701. * Sets the default candidate providers for the scene.
  92702. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  92703. * and getCollidingSubMeshCandidates to their default function
  92704. */
  92705. setDefaultCandidateProviders(): void;
  92706. /**
  92707. * Gets the mesh that is currently under the pointer
  92708. */
  92709. readonly meshUnderPointer: Nullable<AbstractMesh>;
  92710. /**
  92711. * Gets or sets the current on-screen X position of the pointer
  92712. */
  92713. pointerX: number;
  92714. /**
  92715. * Gets or sets the current on-screen Y position of the pointer
  92716. */
  92717. pointerY: number;
  92718. /**
  92719. * Gets the cached material (ie. the latest rendered one)
  92720. * @returns the cached material
  92721. */
  92722. getCachedMaterial(): Nullable<Material>;
  92723. /**
  92724. * Gets the cached effect (ie. the latest rendered one)
  92725. * @returns the cached effect
  92726. */
  92727. getCachedEffect(): Nullable<Effect>;
  92728. /**
  92729. * Gets the cached visibility state (ie. the latest rendered one)
  92730. * @returns the cached visibility state
  92731. */
  92732. getCachedVisibility(): Nullable<number>;
  92733. /**
  92734. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  92735. * @param material defines the current material
  92736. * @param effect defines the current effect
  92737. * @param visibility defines the current visibility state
  92738. * @returns true if one parameter is not cached
  92739. */
  92740. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  92741. /**
  92742. * Gets the engine associated with the scene
  92743. * @returns an Engine
  92744. */
  92745. getEngine(): Engine;
  92746. /**
  92747. * Gets the total number of vertices rendered per frame
  92748. * @returns the total number of vertices rendered per frame
  92749. */
  92750. getTotalVertices(): number;
  92751. /**
  92752. * Gets the performance counter for total vertices
  92753. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  92754. */
  92755. readonly totalVerticesPerfCounter: PerfCounter;
  92756. /**
  92757. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  92758. * @returns the total number of active indices rendered per frame
  92759. */
  92760. getActiveIndices(): number;
  92761. /**
  92762. * Gets the performance counter for active indices
  92763. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  92764. */
  92765. readonly totalActiveIndicesPerfCounter: PerfCounter;
  92766. /**
  92767. * Gets the total number of active particles rendered per frame
  92768. * @returns the total number of active particles rendered per frame
  92769. */
  92770. getActiveParticles(): number;
  92771. /**
  92772. * Gets the performance counter for active particles
  92773. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  92774. */
  92775. readonly activeParticlesPerfCounter: PerfCounter;
  92776. /**
  92777. * Gets the total number of active bones rendered per frame
  92778. * @returns the total number of active bones rendered per frame
  92779. */
  92780. getActiveBones(): number;
  92781. /**
  92782. * Gets the performance counter for active bones
  92783. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  92784. */
  92785. readonly activeBonesPerfCounter: PerfCounter;
  92786. /**
  92787. * Gets the array of active meshes
  92788. * @returns an array of AbstractMesh
  92789. */
  92790. getActiveMeshes(): SmartArray<AbstractMesh>;
  92791. /**
  92792. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  92793. * @returns a number
  92794. */
  92795. getAnimationRatio(): number;
  92796. /**
  92797. * Gets an unique Id for the current render phase
  92798. * @returns a number
  92799. */
  92800. getRenderId(): number;
  92801. /**
  92802. * Gets an unique Id for the current frame
  92803. * @returns a number
  92804. */
  92805. getFrameId(): number;
  92806. /** Call this function if you want to manually increment the render Id*/
  92807. incrementRenderId(): void;
  92808. private _createUbo;
  92809. /**
  92810. * Use this method to simulate a pointer move on a mesh
  92811. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  92812. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  92813. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  92814. * @returns the current scene
  92815. */
  92816. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  92817. /**
  92818. * Use this method to simulate a pointer down on a mesh
  92819. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  92820. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  92821. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  92822. * @returns the current scene
  92823. */
  92824. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  92825. /**
  92826. * Use this method to simulate a pointer up on a mesh
  92827. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  92828. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  92829. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  92830. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  92831. * @returns the current scene
  92832. */
  92833. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  92834. /**
  92835. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  92836. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  92837. * @returns true if the pointer was captured
  92838. */
  92839. isPointerCaptured(pointerId?: number): boolean;
  92840. /**
  92841. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  92842. * @param attachUp defines if you want to attach events to pointerup
  92843. * @param attachDown defines if you want to attach events to pointerdown
  92844. * @param attachMove defines if you want to attach events to pointermove
  92845. */
  92846. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  92847. /** Detaches all event handlers*/
  92848. detachControl(): void;
  92849. /**
  92850. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  92851. * Delay loaded resources are not taking in account
  92852. * @return true if all required resources are ready
  92853. */
  92854. isReady(): boolean;
  92855. /** Resets all cached information relative to material (including effect and visibility) */
  92856. resetCachedMaterial(): void;
  92857. /**
  92858. * Registers a function to be called before every frame render
  92859. * @param func defines the function to register
  92860. */
  92861. registerBeforeRender(func: () => void): void;
  92862. /**
  92863. * Unregisters a function called before every frame render
  92864. * @param func defines the function to unregister
  92865. */
  92866. unregisterBeforeRender(func: () => void): void;
  92867. /**
  92868. * Registers a function to be called after every frame render
  92869. * @param func defines the function to register
  92870. */
  92871. registerAfterRender(func: () => void): void;
  92872. /**
  92873. * Unregisters a function called after every frame render
  92874. * @param func defines the function to unregister
  92875. */
  92876. unregisterAfterRender(func: () => void): void;
  92877. private _executeOnceBeforeRender;
  92878. /**
  92879. * The provided function will run before render once and will be disposed afterwards.
  92880. * A timeout delay can be provided so that the function will be executed in N ms.
  92881. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  92882. * @param func The function to be executed.
  92883. * @param timeout optional delay in ms
  92884. */
  92885. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  92886. /** @hidden */
  92887. _addPendingData(data: any): void;
  92888. /** @hidden */
  92889. _removePendingData(data: any): void;
  92890. /**
  92891. * Returns the number of items waiting to be loaded
  92892. * @returns the number of items waiting to be loaded
  92893. */
  92894. getWaitingItemsCount(): number;
  92895. /**
  92896. * Returns a boolean indicating if the scene is still loading data
  92897. */
  92898. readonly isLoading: boolean;
  92899. /**
  92900. * Registers a function to be executed when the scene is ready
  92901. * @param {Function} func - the function to be executed
  92902. */
  92903. executeWhenReady(func: () => void): void;
  92904. /**
  92905. * Returns a promise that resolves when the scene is ready
  92906. * @returns A promise that resolves when the scene is ready
  92907. */
  92908. whenReadyAsync(): Promise<void>;
  92909. /** @hidden */
  92910. _checkIsReady(): void;
  92911. /**
  92912. * Gets all animatable attached to the scene
  92913. */
  92914. readonly animatables: Animatable[];
  92915. /**
  92916. * Resets the last animation time frame.
  92917. * Useful to override when animations start running when loading a scene for the first time.
  92918. */
  92919. resetLastAnimationTimeFrame(): void;
  92920. /**
  92921. * Gets the current view matrix
  92922. * @returns a Matrix
  92923. */
  92924. getViewMatrix(): Matrix;
  92925. /**
  92926. * Gets the current projection matrix
  92927. * @returns a Matrix
  92928. */
  92929. getProjectionMatrix(): Matrix;
  92930. /**
  92931. * Gets the current transform matrix
  92932. * @returns a Matrix made of View * Projection
  92933. */
  92934. getTransformMatrix(): Matrix;
  92935. /**
  92936. * Sets the current transform matrix
  92937. * @param viewL defines the View matrix to use
  92938. * @param projectionL defines the Projection matrix to use
  92939. * @param viewR defines the right View matrix to use (if provided)
  92940. * @param projectionR defines the right Projection matrix to use (if provided)
  92941. */
  92942. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  92943. /**
  92944. * Gets the uniform buffer used to store scene data
  92945. * @returns a UniformBuffer
  92946. */
  92947. getSceneUniformBuffer(): UniformBuffer;
  92948. /**
  92949. * Gets an unique (relatively to the current scene) Id
  92950. * @returns an unique number for the scene
  92951. */
  92952. getUniqueId(): number;
  92953. /**
  92954. * Add a mesh to the list of scene's meshes
  92955. * @param newMesh defines the mesh to add
  92956. * @param recursive if all child meshes should also be added to the scene
  92957. */
  92958. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  92959. /**
  92960. * Remove a mesh for the list of scene's meshes
  92961. * @param toRemove defines the mesh to remove
  92962. * @param recursive if all child meshes should also be removed from the scene
  92963. * @returns the index where the mesh was in the mesh list
  92964. */
  92965. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  92966. /**
  92967. * Add a transform node to the list of scene's transform nodes
  92968. * @param newTransformNode defines the transform node to add
  92969. */
  92970. addTransformNode(newTransformNode: TransformNode): void;
  92971. /**
  92972. * Remove a transform node for the list of scene's transform nodes
  92973. * @param toRemove defines the transform node to remove
  92974. * @returns the index where the transform node was in the transform node list
  92975. */
  92976. removeTransformNode(toRemove: TransformNode): number;
  92977. /**
  92978. * Remove a skeleton for the list of scene's skeletons
  92979. * @param toRemove defines the skeleton to remove
  92980. * @returns the index where the skeleton was in the skeleton list
  92981. */
  92982. removeSkeleton(toRemove: Skeleton): number;
  92983. /**
  92984. * Remove a morph target for the list of scene's morph targets
  92985. * @param toRemove defines the morph target to remove
  92986. * @returns the index where the morph target was in the morph target list
  92987. */
  92988. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  92989. /**
  92990. * Remove a light for the list of scene's lights
  92991. * @param toRemove defines the light to remove
  92992. * @returns the index where the light was in the light list
  92993. */
  92994. removeLight(toRemove: Light): number;
  92995. /**
  92996. * Remove a camera for the list of scene's cameras
  92997. * @param toRemove defines the camera to remove
  92998. * @returns the index where the camera was in the camera list
  92999. */
  93000. removeCamera(toRemove: Camera): number;
  93001. /**
  93002. * Remove a particle system for the list of scene's particle systems
  93003. * @param toRemove defines the particle system to remove
  93004. * @returns the index where the particle system was in the particle system list
  93005. */
  93006. removeParticleSystem(toRemove: IParticleSystem): number;
  93007. /**
  93008. * Remove a animation for the list of scene's animations
  93009. * @param toRemove defines the animation to remove
  93010. * @returns the index where the animation was in the animation list
  93011. */
  93012. removeAnimation(toRemove: Animation): number;
  93013. /**
  93014. * Will stop the animation of the given target
  93015. * @param target - the target
  93016. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  93017. * @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)
  93018. */
  93019. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  93020. /**
  93021. * Removes the given animation group from this scene.
  93022. * @param toRemove The animation group to remove
  93023. * @returns The index of the removed animation group
  93024. */
  93025. removeAnimationGroup(toRemove: AnimationGroup): number;
  93026. /**
  93027. * Removes the given multi-material from this scene.
  93028. * @param toRemove The multi-material to remove
  93029. * @returns The index of the removed multi-material
  93030. */
  93031. removeMultiMaterial(toRemove: MultiMaterial): number;
  93032. /**
  93033. * Removes the given material from this scene.
  93034. * @param toRemove The material to remove
  93035. * @returns The index of the removed material
  93036. */
  93037. removeMaterial(toRemove: Material): number;
  93038. /**
  93039. * Removes the given action manager from this scene.
  93040. * @param toRemove The action manager to remove
  93041. * @returns The index of the removed action manager
  93042. */
  93043. removeActionManager(toRemove: AbstractActionManager): number;
  93044. /**
  93045. * Removes the given texture from this scene.
  93046. * @param toRemove The texture to remove
  93047. * @returns The index of the removed texture
  93048. */
  93049. removeTexture(toRemove: BaseTexture): number;
  93050. /**
  93051. * Adds the given light to this scene
  93052. * @param newLight The light to add
  93053. */
  93054. addLight(newLight: Light): void;
  93055. /**
  93056. * Sorts the list list based on light priorities
  93057. */
  93058. sortLightsByPriority(): void;
  93059. /**
  93060. * Adds the given camera to this scene
  93061. * @param newCamera The camera to add
  93062. */
  93063. addCamera(newCamera: Camera): void;
  93064. /**
  93065. * Adds the given skeleton to this scene
  93066. * @param newSkeleton The skeleton to add
  93067. */
  93068. addSkeleton(newSkeleton: Skeleton): void;
  93069. /**
  93070. * Adds the given particle system to this scene
  93071. * @param newParticleSystem The particle system to add
  93072. */
  93073. addParticleSystem(newParticleSystem: IParticleSystem): void;
  93074. /**
  93075. * Adds the given animation to this scene
  93076. * @param newAnimation The animation to add
  93077. */
  93078. addAnimation(newAnimation: Animation): void;
  93079. /**
  93080. * Adds the given animation group to this scene.
  93081. * @param newAnimationGroup The animation group to add
  93082. */
  93083. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  93084. /**
  93085. * Adds the given multi-material to this scene
  93086. * @param newMultiMaterial The multi-material to add
  93087. */
  93088. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  93089. /**
  93090. * Adds the given material to this scene
  93091. * @param newMaterial The material to add
  93092. */
  93093. addMaterial(newMaterial: Material): void;
  93094. /**
  93095. * Adds the given morph target to this scene
  93096. * @param newMorphTargetManager The morph target to add
  93097. */
  93098. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  93099. /**
  93100. * Adds the given geometry to this scene
  93101. * @param newGeometry The geometry to add
  93102. */
  93103. addGeometry(newGeometry: Geometry): void;
  93104. /**
  93105. * Adds the given action manager to this scene
  93106. * @param newActionManager The action manager to add
  93107. */
  93108. addActionManager(newActionManager: AbstractActionManager): void;
  93109. /**
  93110. * Adds the given texture to this scene.
  93111. * @param newTexture The texture to add
  93112. */
  93113. addTexture(newTexture: BaseTexture): void;
  93114. /**
  93115. * Switch active camera
  93116. * @param newCamera defines the new active camera
  93117. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  93118. */
  93119. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  93120. /**
  93121. * sets the active camera of the scene using its ID
  93122. * @param id defines the camera's ID
  93123. * @return the new active camera or null if none found.
  93124. */
  93125. setActiveCameraByID(id: string): Nullable<Camera>;
  93126. /**
  93127. * sets the active camera of the scene using its name
  93128. * @param name defines the camera's name
  93129. * @returns the new active camera or null if none found.
  93130. */
  93131. setActiveCameraByName(name: string): Nullable<Camera>;
  93132. /**
  93133. * get an animation group using its name
  93134. * @param name defines the material's name
  93135. * @return the animation group or null if none found.
  93136. */
  93137. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  93138. /**
  93139. * Get a material using its unique id
  93140. * @param uniqueId defines the material's unique id
  93141. * @return the material or null if none found.
  93142. */
  93143. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  93144. /**
  93145. * get a material using its id
  93146. * @param id defines the material's ID
  93147. * @return the material or null if none found.
  93148. */
  93149. getMaterialByID(id: string): Nullable<Material>;
  93150. /**
  93151. * Gets a material using its name
  93152. * @param name defines the material's name
  93153. * @return the material or null if none found.
  93154. */
  93155. getMaterialByName(name: string): Nullable<Material>;
  93156. /**
  93157. * Gets a camera using its id
  93158. * @param id defines the id to look for
  93159. * @returns the camera or null if not found
  93160. */
  93161. getCameraByID(id: string): Nullable<Camera>;
  93162. /**
  93163. * Gets a camera using its unique id
  93164. * @param uniqueId defines the unique id to look for
  93165. * @returns the camera or null if not found
  93166. */
  93167. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  93168. /**
  93169. * Gets a camera using its name
  93170. * @param name defines the camera's name
  93171. * @return the camera or null if none found.
  93172. */
  93173. getCameraByName(name: string): Nullable<Camera>;
  93174. /**
  93175. * Gets a bone using its id
  93176. * @param id defines the bone's id
  93177. * @return the bone or null if not found
  93178. */
  93179. getBoneByID(id: string): Nullable<Bone>;
  93180. /**
  93181. * Gets a bone using its id
  93182. * @param name defines the bone's name
  93183. * @return the bone or null if not found
  93184. */
  93185. getBoneByName(name: string): Nullable<Bone>;
  93186. /**
  93187. * Gets a light node using its name
  93188. * @param name defines the the light's name
  93189. * @return the light or null if none found.
  93190. */
  93191. getLightByName(name: string): Nullable<Light>;
  93192. /**
  93193. * Gets a light node using its id
  93194. * @param id defines the light's id
  93195. * @return the light or null if none found.
  93196. */
  93197. getLightByID(id: string): Nullable<Light>;
  93198. /**
  93199. * Gets a light node using its scene-generated unique ID
  93200. * @param uniqueId defines the light's unique id
  93201. * @return the light or null if none found.
  93202. */
  93203. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  93204. /**
  93205. * Gets a particle system by id
  93206. * @param id defines the particle system id
  93207. * @return the corresponding system or null if none found
  93208. */
  93209. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  93210. /**
  93211. * Gets a geometry using its ID
  93212. * @param id defines the geometry's id
  93213. * @return the geometry or null if none found.
  93214. */
  93215. getGeometryByID(id: string): Nullable<Geometry>;
  93216. private _getGeometryByUniqueID;
  93217. /**
  93218. * Add a new geometry to this scene
  93219. * @param geometry defines the geometry to be added to the scene.
  93220. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  93221. * @return a boolean defining if the geometry was added or not
  93222. */
  93223. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  93224. /**
  93225. * Removes an existing geometry
  93226. * @param geometry defines the geometry to be removed from the scene
  93227. * @return a boolean defining if the geometry was removed or not
  93228. */
  93229. removeGeometry(geometry: Geometry): boolean;
  93230. /**
  93231. * Gets the list of geometries attached to the scene
  93232. * @returns an array of Geometry
  93233. */
  93234. getGeometries(): Geometry[];
  93235. /**
  93236. * Gets the first added mesh found of a given ID
  93237. * @param id defines the id to search for
  93238. * @return the mesh found or null if not found at all
  93239. */
  93240. getMeshByID(id: string): Nullable<AbstractMesh>;
  93241. /**
  93242. * Gets a list of meshes using their id
  93243. * @param id defines the id to search for
  93244. * @returns a list of meshes
  93245. */
  93246. getMeshesByID(id: string): Array<AbstractMesh>;
  93247. /**
  93248. * Gets the first added transform node found of a given ID
  93249. * @param id defines the id to search for
  93250. * @return the found transform node or null if not found at all.
  93251. */
  93252. getTransformNodeByID(id: string): Nullable<TransformNode>;
  93253. /**
  93254. * Gets a transform node with its auto-generated unique id
  93255. * @param uniqueId efines the unique id to search for
  93256. * @return the found transform node or null if not found at all.
  93257. */
  93258. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  93259. /**
  93260. * Gets a list of transform nodes using their id
  93261. * @param id defines the id to search for
  93262. * @returns a list of transform nodes
  93263. */
  93264. getTransformNodesByID(id: string): Array<TransformNode>;
  93265. /**
  93266. * Gets a mesh with its auto-generated unique id
  93267. * @param uniqueId defines the unique id to search for
  93268. * @return the found mesh or null if not found at all.
  93269. */
  93270. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  93271. /**
  93272. * Gets a the last added mesh using a given id
  93273. * @param id defines the id to search for
  93274. * @return the found mesh or null if not found at all.
  93275. */
  93276. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  93277. /**
  93278. * Gets a the last added node (Mesh, Camera, Light) using a given id
  93279. * @param id defines the id to search for
  93280. * @return the found node or null if not found at all
  93281. */
  93282. getLastEntryByID(id: string): Nullable<Node>;
  93283. /**
  93284. * Gets a node (Mesh, Camera, Light) using a given id
  93285. * @param id defines the id to search for
  93286. * @return the found node or null if not found at all
  93287. */
  93288. getNodeByID(id: string): Nullable<Node>;
  93289. /**
  93290. * Gets a node (Mesh, Camera, Light) using a given name
  93291. * @param name defines the name to search for
  93292. * @return the found node or null if not found at all.
  93293. */
  93294. getNodeByName(name: string): Nullable<Node>;
  93295. /**
  93296. * Gets a mesh using a given name
  93297. * @param name defines the name to search for
  93298. * @return the found mesh or null if not found at all.
  93299. */
  93300. getMeshByName(name: string): Nullable<AbstractMesh>;
  93301. /**
  93302. * Gets a transform node using a given name
  93303. * @param name defines the name to search for
  93304. * @return the found transform node or null if not found at all.
  93305. */
  93306. getTransformNodeByName(name: string): Nullable<TransformNode>;
  93307. /**
  93308. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  93309. * @param id defines the id to search for
  93310. * @return the found skeleton or null if not found at all.
  93311. */
  93312. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  93313. /**
  93314. * Gets a skeleton using a given auto generated unique id
  93315. * @param uniqueId defines the unique id to search for
  93316. * @return the found skeleton or null if not found at all.
  93317. */
  93318. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  93319. /**
  93320. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  93321. * @param id defines the id to search for
  93322. * @return the found skeleton or null if not found at all.
  93323. */
  93324. getSkeletonById(id: string): Nullable<Skeleton>;
  93325. /**
  93326. * Gets a skeleton using a given name
  93327. * @param name defines the name to search for
  93328. * @return the found skeleton or null if not found at all.
  93329. */
  93330. getSkeletonByName(name: string): Nullable<Skeleton>;
  93331. /**
  93332. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  93333. * @param id defines the id to search for
  93334. * @return the found morph target manager or null if not found at all.
  93335. */
  93336. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  93337. /**
  93338. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  93339. * @param id defines the id to search for
  93340. * @return the found morph target or null if not found at all.
  93341. */
  93342. getMorphTargetById(id: string): Nullable<MorphTarget>;
  93343. /**
  93344. * Gets a boolean indicating if the given mesh is active
  93345. * @param mesh defines the mesh to look for
  93346. * @returns true if the mesh is in the active list
  93347. */
  93348. isActiveMesh(mesh: AbstractMesh): boolean;
  93349. /**
  93350. * Return a unique id as a string which can serve as an identifier for the scene
  93351. */
  93352. readonly uid: string;
  93353. /**
  93354. * Add an externaly attached data from its key.
  93355. * This method call will fail and return false, if such key already exists.
  93356. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  93357. * @param key the unique key that identifies the data
  93358. * @param data the data object to associate to the key for this Engine instance
  93359. * @return true if no such key were already present and the data was added successfully, false otherwise
  93360. */
  93361. addExternalData<T>(key: string, data: T): boolean;
  93362. /**
  93363. * Get an externaly attached data from its key
  93364. * @param key the unique key that identifies the data
  93365. * @return the associated data, if present (can be null), or undefined if not present
  93366. */
  93367. getExternalData<T>(key: string): Nullable<T>;
  93368. /**
  93369. * Get an externaly attached data from its key, create it using a factory if it's not already present
  93370. * @param key the unique key that identifies the data
  93371. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  93372. * @return the associated data, can be null if the factory returned null.
  93373. */
  93374. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  93375. /**
  93376. * Remove an externaly attached data from the Engine instance
  93377. * @param key the unique key that identifies the data
  93378. * @return true if the data was successfully removed, false if it doesn't exist
  93379. */
  93380. removeExternalData(key: string): boolean;
  93381. private _evaluateSubMesh;
  93382. /**
  93383. * Clear the processed materials smart array preventing retention point in material dispose.
  93384. */
  93385. freeProcessedMaterials(): void;
  93386. private _preventFreeActiveMeshesAndRenderingGroups;
  93387. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  93388. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  93389. * when disposing several meshes in a row or a hierarchy of meshes.
  93390. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  93391. */
  93392. blockfreeActiveMeshesAndRenderingGroups: boolean;
  93393. /**
  93394. * Clear the active meshes smart array preventing retention point in mesh dispose.
  93395. */
  93396. freeActiveMeshes(): void;
  93397. /**
  93398. * Clear the info related to rendering groups preventing retention points during dispose.
  93399. */
  93400. freeRenderingGroups(): void;
  93401. /** @hidden */
  93402. _isInIntermediateRendering(): boolean;
  93403. /**
  93404. * Lambda returning the list of potentially active meshes.
  93405. */
  93406. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  93407. /**
  93408. * Lambda returning the list of potentially active sub meshes.
  93409. */
  93410. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  93411. /**
  93412. * Lambda returning the list of potentially intersecting sub meshes.
  93413. */
  93414. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  93415. /**
  93416. * Lambda returning the list of potentially colliding sub meshes.
  93417. */
  93418. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  93419. private _activeMeshesFrozen;
  93420. /**
  93421. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  93422. * @returns the current scene
  93423. */
  93424. freezeActiveMeshes(): Scene;
  93425. /**
  93426. * Use this function to restart evaluating active meshes on every frame
  93427. * @returns the current scene
  93428. */
  93429. unfreezeActiveMeshes(): Scene;
  93430. private _evaluateActiveMeshes;
  93431. private _activeMesh;
  93432. /**
  93433. * Update the transform matrix to update from the current active camera
  93434. * @param force defines a boolean used to force the update even if cache is up to date
  93435. */
  93436. updateTransformMatrix(force?: boolean): void;
  93437. private _bindFrameBuffer;
  93438. /** @hidden */
  93439. _allowPostProcessClearColor: boolean;
  93440. /** @hidden */
  93441. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  93442. private _processSubCameras;
  93443. private _checkIntersections;
  93444. /** @hidden */
  93445. _advancePhysicsEngineStep(step: number): void;
  93446. /**
  93447. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  93448. */
  93449. getDeterministicFrameTime: () => number;
  93450. /** @hidden */
  93451. _animate(): void;
  93452. /** Execute all animations (for a frame) */
  93453. animate(): void;
  93454. /**
  93455. * Render the scene
  93456. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  93457. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  93458. */
  93459. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  93460. /**
  93461. * Freeze all materials
  93462. * A frozen material will not be updatable but should be faster to render
  93463. */
  93464. freezeMaterials(): void;
  93465. /**
  93466. * Unfreeze all materials
  93467. * A frozen material will not be updatable but should be faster to render
  93468. */
  93469. unfreezeMaterials(): void;
  93470. /**
  93471. * Releases all held ressources
  93472. */
  93473. dispose(): void;
  93474. /**
  93475. * Gets if the scene is already disposed
  93476. */
  93477. readonly isDisposed: boolean;
  93478. /**
  93479. * Call this function to reduce memory footprint of the scene.
  93480. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  93481. */
  93482. clearCachedVertexData(): void;
  93483. /**
  93484. * This function will remove the local cached buffer data from texture.
  93485. * It will save memory but will prevent the texture from being rebuilt
  93486. */
  93487. cleanCachedTextureBuffer(): void;
  93488. /**
  93489. * Get the world extend vectors with an optional filter
  93490. *
  93491. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  93492. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  93493. */
  93494. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  93495. min: Vector3;
  93496. max: Vector3;
  93497. };
  93498. /**
  93499. * Creates a ray that can be used to pick in the scene
  93500. * @param x defines the x coordinate of the origin (on-screen)
  93501. * @param y defines the y coordinate of the origin (on-screen)
  93502. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  93503. * @param camera defines the camera to use for the picking
  93504. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  93505. * @returns a Ray
  93506. */
  93507. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  93508. /**
  93509. * Creates a ray that can be used to pick in the scene
  93510. * @param x defines the x coordinate of the origin (on-screen)
  93511. * @param y defines the y coordinate of the origin (on-screen)
  93512. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  93513. * @param result defines the ray where to store the picking ray
  93514. * @param camera defines the camera to use for the picking
  93515. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  93516. * @returns the current scene
  93517. */
  93518. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  93519. /**
  93520. * Creates a ray that can be used to pick in the scene
  93521. * @param x defines the x coordinate of the origin (on-screen)
  93522. * @param y defines the y coordinate of the origin (on-screen)
  93523. * @param camera defines the camera to use for the picking
  93524. * @returns a Ray
  93525. */
  93526. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  93527. /**
  93528. * Creates a ray that can be used to pick in the scene
  93529. * @param x defines the x coordinate of the origin (on-screen)
  93530. * @param y defines the y coordinate of the origin (on-screen)
  93531. * @param result defines the ray where to store the picking ray
  93532. * @param camera defines the camera to use for the picking
  93533. * @returns the current scene
  93534. */
  93535. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  93536. /** Launch a ray to try to pick a mesh in the scene
  93537. * @param x position on screen
  93538. * @param y position on screen
  93539. * @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
  93540. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  93541. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  93542. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  93543. * @returns a PickingInfo
  93544. */
  93545. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  93546. /** Use the given ray to pick a mesh in the scene
  93547. * @param ray The ray to use to pick meshes
  93548. * @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
  93549. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  93550. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  93551. * @returns a PickingInfo
  93552. */
  93553. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  93554. /**
  93555. * Launch a ray to try to pick a mesh in the scene
  93556. * @param x X position on screen
  93557. * @param y Y position on screen
  93558. * @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
  93559. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  93560. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  93561. * @returns an array of PickingInfo
  93562. */
  93563. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  93564. /**
  93565. * Launch a ray to try to pick a mesh in the scene
  93566. * @param ray Ray to use
  93567. * @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
  93568. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  93569. * @returns an array of PickingInfo
  93570. */
  93571. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  93572. /**
  93573. * Force the value of meshUnderPointer
  93574. * @param mesh defines the mesh to use
  93575. */
  93576. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  93577. /**
  93578. * Gets the mesh under the pointer
  93579. * @returns a Mesh or null if no mesh is under the pointer
  93580. */
  93581. getPointerOverMesh(): Nullable<AbstractMesh>;
  93582. /** @hidden */
  93583. _rebuildGeometries(): void;
  93584. /** @hidden */
  93585. _rebuildTextures(): void;
  93586. private _getByTags;
  93587. /**
  93588. * Get a list of meshes by tags
  93589. * @param tagsQuery defines the tags query to use
  93590. * @param forEach defines a predicate used to filter results
  93591. * @returns an array of Mesh
  93592. */
  93593. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  93594. /**
  93595. * Get a list of cameras by tags
  93596. * @param tagsQuery defines the tags query to use
  93597. * @param forEach defines a predicate used to filter results
  93598. * @returns an array of Camera
  93599. */
  93600. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  93601. /**
  93602. * Get a list of lights by tags
  93603. * @param tagsQuery defines the tags query to use
  93604. * @param forEach defines a predicate used to filter results
  93605. * @returns an array of Light
  93606. */
  93607. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  93608. /**
  93609. * Get a list of materials by tags
  93610. * @param tagsQuery defines the tags query to use
  93611. * @param forEach defines a predicate used to filter results
  93612. * @returns an array of Material
  93613. */
  93614. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  93615. /**
  93616. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  93617. * This allowed control for front to back rendering or reversly depending of the special needs.
  93618. *
  93619. * @param renderingGroupId The rendering group id corresponding to its index
  93620. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  93621. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  93622. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  93623. */
  93624. 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;
  93625. /**
  93626. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  93627. *
  93628. * @param renderingGroupId The rendering group id corresponding to its index
  93629. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  93630. * @param depth Automatically clears depth between groups if true and autoClear is true.
  93631. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  93632. */
  93633. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  93634. /**
  93635. * Gets the current auto clear configuration for one rendering group of the rendering
  93636. * manager.
  93637. * @param index the rendering group index to get the information for
  93638. * @returns The auto clear setup for the requested rendering group
  93639. */
  93640. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  93641. private _blockMaterialDirtyMechanism;
  93642. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  93643. blockMaterialDirtyMechanism: boolean;
  93644. /**
  93645. * Will flag all materials as dirty to trigger new shader compilation
  93646. * @param flag defines the flag used to specify which material part must be marked as dirty
  93647. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  93648. */
  93649. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  93650. /** @hidden */
  93651. _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;
  93652. /** @hidden */
  93653. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  93654. }
  93655. }
  93656. declare module BABYLON {
  93657. /**
  93658. * Set of assets to keep when moving a scene into an asset container.
  93659. */
  93660. export class KeepAssets extends AbstractScene {
  93661. }
  93662. /**
  93663. * Container with a set of assets that can be added or removed from a scene.
  93664. */
  93665. export class AssetContainer extends AbstractScene {
  93666. /**
  93667. * The scene the AssetContainer belongs to.
  93668. */
  93669. scene: Scene;
  93670. /**
  93671. * Instantiates an AssetContainer.
  93672. * @param scene The scene the AssetContainer belongs to.
  93673. */
  93674. constructor(scene: Scene);
  93675. /**
  93676. * Adds all the assets from the container to the scene.
  93677. */
  93678. addAllToScene(): void;
  93679. /**
  93680. * Removes all the assets in the container from the scene
  93681. */
  93682. removeAllFromScene(): void;
  93683. /**
  93684. * Disposes all the assets in the container
  93685. */
  93686. dispose(): void;
  93687. private _moveAssets;
  93688. /**
  93689. * Removes all the assets contained in the scene and adds them to the container.
  93690. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  93691. */
  93692. moveAllFromScene(keepAssets?: KeepAssets): void;
  93693. /**
  93694. * 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.
  93695. * @returns the root mesh
  93696. */
  93697. createRootMesh(): Mesh;
  93698. }
  93699. }
  93700. declare module BABYLON {
  93701. /**
  93702. * Defines how the parser contract is defined.
  93703. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  93704. */
  93705. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  93706. /**
  93707. * Defines how the individual parser contract is defined.
  93708. * These parser can parse an individual asset
  93709. */
  93710. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  93711. /**
  93712. * Base class of the scene acting as a container for the different elements composing a scene.
  93713. * This class is dynamically extended by the different components of the scene increasing
  93714. * flexibility and reducing coupling
  93715. */
  93716. export abstract class AbstractScene {
  93717. /**
  93718. * Stores the list of available parsers in the application.
  93719. */
  93720. private static _BabylonFileParsers;
  93721. /**
  93722. * Stores the list of available individual parsers in the application.
  93723. */
  93724. private static _IndividualBabylonFileParsers;
  93725. /**
  93726. * Adds a parser in the list of available ones
  93727. * @param name Defines the name of the parser
  93728. * @param parser Defines the parser to add
  93729. */
  93730. static AddParser(name: string, parser: BabylonFileParser): void;
  93731. /**
  93732. * Gets a general parser from the list of avaialble ones
  93733. * @param name Defines the name of the parser
  93734. * @returns the requested parser or null
  93735. */
  93736. static GetParser(name: string): Nullable<BabylonFileParser>;
  93737. /**
  93738. * Adds n individual parser in the list of available ones
  93739. * @param name Defines the name of the parser
  93740. * @param parser Defines the parser to add
  93741. */
  93742. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  93743. /**
  93744. * Gets an individual parser from the list of avaialble ones
  93745. * @param name Defines the name of the parser
  93746. * @returns the requested parser or null
  93747. */
  93748. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  93749. /**
  93750. * Parser json data and populate both a scene and its associated container object
  93751. * @param jsonData Defines the data to parse
  93752. * @param scene Defines the scene to parse the data for
  93753. * @param container Defines the container attached to the parsing sequence
  93754. * @param rootUrl Defines the root url of the data
  93755. */
  93756. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  93757. /**
  93758. * Gets the list of root nodes (ie. nodes with no parent)
  93759. */
  93760. rootNodes: Node[];
  93761. /** All of the cameras added to this scene
  93762. * @see http://doc.babylonjs.com/babylon101/cameras
  93763. */
  93764. cameras: Camera[];
  93765. /**
  93766. * All of the lights added to this scene
  93767. * @see http://doc.babylonjs.com/babylon101/lights
  93768. */
  93769. lights: Light[];
  93770. /**
  93771. * All of the (abstract) meshes added to this scene
  93772. */
  93773. meshes: AbstractMesh[];
  93774. /**
  93775. * The list of skeletons added to the scene
  93776. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  93777. */
  93778. skeletons: Skeleton[];
  93779. /**
  93780. * All of the particle systems added to this scene
  93781. * @see http://doc.babylonjs.com/babylon101/particles
  93782. */
  93783. particleSystems: IParticleSystem[];
  93784. /**
  93785. * Gets a list of Animations associated with the scene
  93786. */
  93787. animations: Animation[];
  93788. /**
  93789. * All of the animation groups added to this scene
  93790. * @see http://doc.babylonjs.com/how_to/group
  93791. */
  93792. animationGroups: AnimationGroup[];
  93793. /**
  93794. * All of the multi-materials added to this scene
  93795. * @see http://doc.babylonjs.com/how_to/multi_materials
  93796. */
  93797. multiMaterials: MultiMaterial[];
  93798. /**
  93799. * All of the materials added to this scene
  93800. * In the context of a Scene, it is not supposed to be modified manually.
  93801. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  93802. * Note also that the order of the Material wihin the array is not significant and might change.
  93803. * @see http://doc.babylonjs.com/babylon101/materials
  93804. */
  93805. materials: Material[];
  93806. /**
  93807. * The list of morph target managers added to the scene
  93808. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  93809. */
  93810. morphTargetManagers: MorphTargetManager[];
  93811. /**
  93812. * The list of geometries used in the scene.
  93813. */
  93814. geometries: Geometry[];
  93815. /**
  93816. * All of the tranform nodes added to this scene
  93817. * In the context of a Scene, it is not supposed to be modified manually.
  93818. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  93819. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  93820. * @see http://doc.babylonjs.com/how_to/transformnode
  93821. */
  93822. transformNodes: TransformNode[];
  93823. /**
  93824. * ActionManagers available on the scene.
  93825. */
  93826. actionManagers: AbstractActionManager[];
  93827. /**
  93828. * Textures to keep.
  93829. */
  93830. textures: BaseTexture[];
  93831. /**
  93832. * Environment texture for the scene
  93833. */
  93834. environmentTexture: Nullable<BaseTexture>;
  93835. }
  93836. }
  93837. declare module BABYLON {
  93838. /**
  93839. * Defines a sound that can be played in the application.
  93840. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  93841. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  93842. */
  93843. export class Sound {
  93844. /**
  93845. * The name of the sound in the scene.
  93846. */
  93847. name: string;
  93848. /**
  93849. * Does the sound autoplay once loaded.
  93850. */
  93851. autoplay: boolean;
  93852. /**
  93853. * Does the sound loop after it finishes playing once.
  93854. */
  93855. loop: boolean;
  93856. /**
  93857. * Does the sound use a custom attenuation curve to simulate the falloff
  93858. * happening when the source gets further away from the camera.
  93859. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  93860. */
  93861. useCustomAttenuation: boolean;
  93862. /**
  93863. * The sound track id this sound belongs to.
  93864. */
  93865. soundTrackId: number;
  93866. /**
  93867. * Is this sound currently played.
  93868. */
  93869. isPlaying: boolean;
  93870. /**
  93871. * Is this sound currently paused.
  93872. */
  93873. isPaused: boolean;
  93874. /**
  93875. * Does this sound enables spatial sound.
  93876. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93877. */
  93878. spatialSound: boolean;
  93879. /**
  93880. * Define the reference distance the sound should be heard perfectly.
  93881. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93882. */
  93883. refDistance: number;
  93884. /**
  93885. * Define the roll off factor of spatial sounds.
  93886. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93887. */
  93888. rolloffFactor: number;
  93889. /**
  93890. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  93891. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93892. */
  93893. maxDistance: number;
  93894. /**
  93895. * Define the distance attenuation model the sound will follow.
  93896. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93897. */
  93898. distanceModel: string;
  93899. /**
  93900. * @hidden
  93901. * Back Compat
  93902. **/
  93903. onended: () => any;
  93904. /**
  93905. * Observable event when the current playing sound finishes.
  93906. */
  93907. onEndedObservable: Observable<Sound>;
  93908. private _panningModel;
  93909. private _playbackRate;
  93910. private _streaming;
  93911. private _startTime;
  93912. private _startOffset;
  93913. private _position;
  93914. /** @hidden */
  93915. _positionInEmitterSpace: boolean;
  93916. private _localDirection;
  93917. private _volume;
  93918. private _isReadyToPlay;
  93919. private _isDirectional;
  93920. private _readyToPlayCallback;
  93921. private _audioBuffer;
  93922. private _soundSource;
  93923. private _streamingSource;
  93924. private _soundPanner;
  93925. private _soundGain;
  93926. private _inputAudioNode;
  93927. private _outputAudioNode;
  93928. private _coneInnerAngle;
  93929. private _coneOuterAngle;
  93930. private _coneOuterGain;
  93931. private _scene;
  93932. private _connectedTransformNode;
  93933. private _customAttenuationFunction;
  93934. private _registerFunc;
  93935. private _isOutputConnected;
  93936. private _htmlAudioElement;
  93937. private _urlType;
  93938. /** @hidden */
  93939. static _SceneComponentInitialization: (scene: Scene) => void;
  93940. /**
  93941. * Create a sound and attach it to a scene
  93942. * @param name Name of your sound
  93943. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  93944. * @param scene defines the scene the sound belongs to
  93945. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  93946. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  93947. */
  93948. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  93949. /**
  93950. * Release the sound and its associated resources
  93951. */
  93952. dispose(): void;
  93953. /**
  93954. * Gets if the sounds is ready to be played or not.
  93955. * @returns true if ready, otherwise false
  93956. */
  93957. isReady(): boolean;
  93958. private _soundLoaded;
  93959. /**
  93960. * Sets the data of the sound from an audiobuffer
  93961. * @param audioBuffer The audioBuffer containing the data
  93962. */
  93963. setAudioBuffer(audioBuffer: AudioBuffer): void;
  93964. /**
  93965. * Updates the current sounds options such as maxdistance, loop...
  93966. * @param options A JSON object containing values named as the object properties
  93967. */
  93968. updateOptions(options: any): void;
  93969. private _createSpatialParameters;
  93970. private _updateSpatialParameters;
  93971. /**
  93972. * Switch the panning model to HRTF:
  93973. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  93974. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93975. */
  93976. switchPanningModelToHRTF(): void;
  93977. /**
  93978. * Switch the panning model to Equal Power:
  93979. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  93980. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93981. */
  93982. switchPanningModelToEqualPower(): void;
  93983. private _switchPanningModel;
  93984. /**
  93985. * Connect this sound to a sound track audio node like gain...
  93986. * @param soundTrackAudioNode the sound track audio node to connect to
  93987. */
  93988. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  93989. /**
  93990. * Transform this sound into a directional source
  93991. * @param coneInnerAngle Size of the inner cone in degree
  93992. * @param coneOuterAngle Size of the outer cone in degree
  93993. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  93994. */
  93995. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  93996. /**
  93997. * Gets or sets the inner angle for the directional cone.
  93998. */
  93999. /**
  94000. * Gets or sets the inner angle for the directional cone.
  94001. */
  94002. directionalConeInnerAngle: number;
  94003. /**
  94004. * Gets or sets the outer angle for the directional cone.
  94005. */
  94006. /**
  94007. * Gets or sets the outer angle for the directional cone.
  94008. */
  94009. directionalConeOuterAngle: number;
  94010. /**
  94011. * Sets the position of the emitter if spatial sound is enabled
  94012. * @param newPosition Defines the new posisiton
  94013. */
  94014. setPosition(newPosition: Vector3): void;
  94015. /**
  94016. * Sets the local direction of the emitter if spatial sound is enabled
  94017. * @param newLocalDirection Defines the new local direction
  94018. */
  94019. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  94020. private _updateDirection;
  94021. /** @hidden */
  94022. updateDistanceFromListener(): void;
  94023. /**
  94024. * Sets a new custom attenuation function for the sound.
  94025. * @param callback Defines the function used for the attenuation
  94026. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  94027. */
  94028. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  94029. /**
  94030. * Play the sound
  94031. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  94032. * @param offset (optional) Start the sound setting it at a specific time
  94033. */
  94034. play(time?: number, offset?: number): void;
  94035. private _onended;
  94036. /**
  94037. * Stop the sound
  94038. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  94039. */
  94040. stop(time?: number): void;
  94041. /**
  94042. * Put the sound in pause
  94043. */
  94044. pause(): void;
  94045. /**
  94046. * Sets a dedicated volume for this sounds
  94047. * @param newVolume Define the new volume of the sound
  94048. * @param time Define in how long the sound should be at this value
  94049. */
  94050. setVolume(newVolume: number, time?: number): void;
  94051. /**
  94052. * Set the sound play back rate
  94053. * @param newPlaybackRate Define the playback rate the sound should be played at
  94054. */
  94055. setPlaybackRate(newPlaybackRate: number): void;
  94056. /**
  94057. * Gets the volume of the sound.
  94058. * @returns the volume of the sound
  94059. */
  94060. getVolume(): number;
  94061. /**
  94062. * Attach the sound to a dedicated mesh
  94063. * @param transformNode The transform node to connect the sound with
  94064. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  94065. */
  94066. attachToMesh(transformNode: TransformNode): void;
  94067. /**
  94068. * Detach the sound from the previously attached mesh
  94069. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  94070. */
  94071. detachFromMesh(): void;
  94072. private _onRegisterAfterWorldMatrixUpdate;
  94073. /**
  94074. * Clone the current sound in the scene.
  94075. * @returns the new sound clone
  94076. */
  94077. clone(): Nullable<Sound>;
  94078. /**
  94079. * Gets the current underlying audio buffer containing the data
  94080. * @returns the audio buffer
  94081. */
  94082. getAudioBuffer(): Nullable<AudioBuffer>;
  94083. /**
  94084. * Serializes the Sound in a JSON representation
  94085. * @returns the JSON representation of the sound
  94086. */
  94087. serialize(): any;
  94088. /**
  94089. * Parse a JSON representation of a sound to innstantiate in a given scene
  94090. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  94091. * @param scene Define the scene the new parsed sound should be created in
  94092. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  94093. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  94094. * @returns the newly parsed sound
  94095. */
  94096. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  94097. }
  94098. }
  94099. declare module BABYLON {
  94100. /**
  94101. * This defines an action helpful to play a defined sound on a triggered action.
  94102. */
  94103. export class PlaySoundAction extends Action {
  94104. private _sound;
  94105. /**
  94106. * Instantiate the action
  94107. * @param triggerOptions defines the trigger options
  94108. * @param sound defines the sound to play
  94109. * @param condition defines the trigger related conditions
  94110. */
  94111. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  94112. /** @hidden */
  94113. _prepare(): void;
  94114. /**
  94115. * Execute the action and play the sound.
  94116. */
  94117. execute(): void;
  94118. /**
  94119. * Serializes the actions and its related information.
  94120. * @param parent defines the object to serialize in
  94121. * @returns the serialized object
  94122. */
  94123. serialize(parent: any): any;
  94124. }
  94125. /**
  94126. * This defines an action helpful to stop a defined sound on a triggered action.
  94127. */
  94128. export class StopSoundAction extends Action {
  94129. private _sound;
  94130. /**
  94131. * Instantiate the action
  94132. * @param triggerOptions defines the trigger options
  94133. * @param sound defines the sound to stop
  94134. * @param condition defines the trigger related conditions
  94135. */
  94136. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  94137. /** @hidden */
  94138. _prepare(): void;
  94139. /**
  94140. * Execute the action and stop the sound.
  94141. */
  94142. execute(): void;
  94143. /**
  94144. * Serializes the actions and its related information.
  94145. * @param parent defines the object to serialize in
  94146. * @returns the serialized object
  94147. */
  94148. serialize(parent: any): any;
  94149. }
  94150. }
  94151. declare module BABYLON {
  94152. /**
  94153. * This defines an action responsible to change the value of a property
  94154. * by interpolating between its current value and the newly set one once triggered.
  94155. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  94156. */
  94157. export class InterpolateValueAction extends Action {
  94158. /**
  94159. * Defines the path of the property where the value should be interpolated
  94160. */
  94161. propertyPath: string;
  94162. /**
  94163. * Defines the target value at the end of the interpolation.
  94164. */
  94165. value: any;
  94166. /**
  94167. * Defines the time it will take for the property to interpolate to the value.
  94168. */
  94169. duration: number;
  94170. /**
  94171. * Defines if the other scene animations should be stopped when the action has been triggered
  94172. */
  94173. stopOtherAnimations?: boolean;
  94174. /**
  94175. * Defines a callback raised once the interpolation animation has been done.
  94176. */
  94177. onInterpolationDone?: () => void;
  94178. /**
  94179. * Observable triggered once the interpolation animation has been done.
  94180. */
  94181. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  94182. private _target;
  94183. private _effectiveTarget;
  94184. private _property;
  94185. /**
  94186. * Instantiate the action
  94187. * @param triggerOptions defines the trigger options
  94188. * @param target defines the object containing the value to interpolate
  94189. * @param propertyPath defines the path to the property in the target object
  94190. * @param value defines the target value at the end of the interpolation
  94191. * @param duration deines the time it will take for the property to interpolate to the value.
  94192. * @param condition defines the trigger related conditions
  94193. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  94194. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  94195. */
  94196. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  94197. /** @hidden */
  94198. _prepare(): void;
  94199. /**
  94200. * Execute the action starts the value interpolation.
  94201. */
  94202. execute(): void;
  94203. /**
  94204. * Serializes the actions and its related information.
  94205. * @param parent defines the object to serialize in
  94206. * @returns the serialized object
  94207. */
  94208. serialize(parent: any): any;
  94209. }
  94210. }
  94211. declare module BABYLON {
  94212. /**
  94213. * Options allowed during the creation of a sound track.
  94214. */
  94215. export interface ISoundTrackOptions {
  94216. /**
  94217. * The volume the sound track should take during creation
  94218. */
  94219. volume?: number;
  94220. /**
  94221. * Define if the sound track is the main sound track of the scene
  94222. */
  94223. mainTrack?: boolean;
  94224. }
  94225. /**
  94226. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  94227. * It will be also used in a future release to apply effects on a specific track.
  94228. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  94229. */
  94230. export class SoundTrack {
  94231. /**
  94232. * The unique identifier of the sound track in the scene.
  94233. */
  94234. id: number;
  94235. /**
  94236. * The list of sounds included in the sound track.
  94237. */
  94238. soundCollection: Array<Sound>;
  94239. private _outputAudioNode;
  94240. private _scene;
  94241. private _isMainTrack;
  94242. private _connectedAnalyser;
  94243. private _options;
  94244. private _isInitialized;
  94245. /**
  94246. * Creates a new sound track.
  94247. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  94248. * @param scene Define the scene the sound track belongs to
  94249. * @param options
  94250. */
  94251. constructor(scene: Scene, options?: ISoundTrackOptions);
  94252. private _initializeSoundTrackAudioGraph;
  94253. /**
  94254. * Release the sound track and its associated resources
  94255. */
  94256. dispose(): void;
  94257. /**
  94258. * Adds a sound to this sound track
  94259. * @param sound define the cound to add
  94260. * @ignoreNaming
  94261. */
  94262. AddSound(sound: Sound): void;
  94263. /**
  94264. * Removes a sound to this sound track
  94265. * @param sound define the cound to remove
  94266. * @ignoreNaming
  94267. */
  94268. RemoveSound(sound: Sound): void;
  94269. /**
  94270. * Set a global volume for the full sound track.
  94271. * @param newVolume Define the new volume of the sound track
  94272. */
  94273. setVolume(newVolume: number): void;
  94274. /**
  94275. * Switch the panning model to HRTF:
  94276. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  94277. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  94278. */
  94279. switchPanningModelToHRTF(): void;
  94280. /**
  94281. * Switch the panning model to Equal Power:
  94282. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  94283. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  94284. */
  94285. switchPanningModelToEqualPower(): void;
  94286. /**
  94287. * Connect the sound track to an audio analyser allowing some amazing
  94288. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  94289. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  94290. * @param analyser The analyser to connect to the engine
  94291. */
  94292. connectToAnalyser(analyser: Analyser): void;
  94293. }
  94294. }
  94295. declare module BABYLON {
  94296. interface AbstractScene {
  94297. /**
  94298. * The list of sounds used in the scene.
  94299. */
  94300. sounds: Nullable<Array<Sound>>;
  94301. }
  94302. interface Scene {
  94303. /**
  94304. * @hidden
  94305. * Backing field
  94306. */
  94307. _mainSoundTrack: SoundTrack;
  94308. /**
  94309. * The main sound track played by the scene.
  94310. * It cotains your primary collection of sounds.
  94311. */
  94312. mainSoundTrack: SoundTrack;
  94313. /**
  94314. * The list of sound tracks added to the scene
  94315. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  94316. */
  94317. soundTracks: Nullable<Array<SoundTrack>>;
  94318. /**
  94319. * Gets a sound using a given name
  94320. * @param name defines the name to search for
  94321. * @return the found sound or null if not found at all.
  94322. */
  94323. getSoundByName(name: string): Nullable<Sound>;
  94324. /**
  94325. * Gets or sets if audio support is enabled
  94326. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  94327. */
  94328. audioEnabled: boolean;
  94329. /**
  94330. * Gets or sets if audio will be output to headphones
  94331. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  94332. */
  94333. headphone: boolean;
  94334. }
  94335. /**
  94336. * Defines the sound scene component responsible to manage any sounds
  94337. * in a given scene.
  94338. */
  94339. export class AudioSceneComponent implements ISceneSerializableComponent {
  94340. /**
  94341. * The component name helpfull to identify the component in the list of scene components.
  94342. */
  94343. readonly name: string;
  94344. /**
  94345. * The scene the component belongs to.
  94346. */
  94347. scene: Scene;
  94348. private _audioEnabled;
  94349. /**
  94350. * Gets whether audio is enabled or not.
  94351. * Please use related enable/disable method to switch state.
  94352. */
  94353. readonly audioEnabled: boolean;
  94354. private _headphone;
  94355. /**
  94356. * Gets whether audio is outputing to headphone or not.
  94357. * Please use the according Switch methods to change output.
  94358. */
  94359. readonly headphone: boolean;
  94360. /**
  94361. * Creates a new instance of the component for the given scene
  94362. * @param scene Defines the scene to register the component in
  94363. */
  94364. constructor(scene: Scene);
  94365. /**
  94366. * Registers the component in a given scene
  94367. */
  94368. register(): void;
  94369. /**
  94370. * Rebuilds the elements related to this component in case of
  94371. * context lost for instance.
  94372. */
  94373. rebuild(): void;
  94374. /**
  94375. * Serializes the component data to the specified json object
  94376. * @param serializationObject The object to serialize to
  94377. */
  94378. serialize(serializationObject: any): void;
  94379. /**
  94380. * Adds all the element from the container to the scene
  94381. * @param container the container holding the elements
  94382. */
  94383. addFromContainer(container: AbstractScene): void;
  94384. /**
  94385. * Removes all the elements in the container from the scene
  94386. * @param container contains the elements to remove
  94387. * @param dispose if the removed element should be disposed (default: false)
  94388. */
  94389. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  94390. /**
  94391. * Disposes the component and the associated ressources.
  94392. */
  94393. dispose(): void;
  94394. /**
  94395. * Disables audio in the associated scene.
  94396. */
  94397. disableAudio(): void;
  94398. /**
  94399. * Enables audio in the associated scene.
  94400. */
  94401. enableAudio(): void;
  94402. /**
  94403. * Switch audio to headphone output.
  94404. */
  94405. switchAudioModeForHeadphones(): void;
  94406. /**
  94407. * Switch audio to normal speakers.
  94408. */
  94409. switchAudioModeForNormalSpeakers(): void;
  94410. private _afterRender;
  94411. }
  94412. }
  94413. declare module BABYLON {
  94414. /**
  94415. * Wraps one or more Sound objects and selects one with random weight for playback.
  94416. */
  94417. export class WeightedSound {
  94418. /** When true a Sound will be selected and played when the current playing Sound completes. */
  94419. loop: boolean;
  94420. private _coneInnerAngle;
  94421. private _coneOuterAngle;
  94422. private _volume;
  94423. /** A Sound is currently playing. */
  94424. isPlaying: boolean;
  94425. /** A Sound is currently paused. */
  94426. isPaused: boolean;
  94427. private _sounds;
  94428. private _weights;
  94429. private _currentIndex?;
  94430. /**
  94431. * Creates a new WeightedSound from the list of sounds given.
  94432. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  94433. * @param sounds Array of Sounds that will be selected from.
  94434. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  94435. */
  94436. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  94437. /**
  94438. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  94439. */
  94440. /**
  94441. * The size of cone in degress for a directional sound in which there will be no attenuation.
  94442. */
  94443. directionalConeInnerAngle: number;
  94444. /**
  94445. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  94446. * Listener angles between innerAngle and outerAngle will falloff linearly.
  94447. */
  94448. /**
  94449. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  94450. * Listener angles between innerAngle and outerAngle will falloff linearly.
  94451. */
  94452. directionalConeOuterAngle: number;
  94453. /**
  94454. * Playback volume.
  94455. */
  94456. /**
  94457. * Playback volume.
  94458. */
  94459. volume: number;
  94460. private _onended;
  94461. /**
  94462. * Suspend playback
  94463. */
  94464. pause(): void;
  94465. /**
  94466. * Stop playback
  94467. */
  94468. stop(): void;
  94469. /**
  94470. * Start playback.
  94471. * @param startOffset Position the clip head at a specific time in seconds.
  94472. */
  94473. play(startOffset?: number): void;
  94474. }
  94475. }
  94476. declare module BABYLON {
  94477. /**
  94478. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  94479. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  94480. */
  94481. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  94482. /**
  94483. * Gets the name of the behavior.
  94484. */
  94485. readonly name: string;
  94486. /**
  94487. * The easing function used by animations
  94488. */
  94489. static EasingFunction: BackEase;
  94490. /**
  94491. * The easing mode used by animations
  94492. */
  94493. static EasingMode: number;
  94494. /**
  94495. * The duration of the animation, in milliseconds
  94496. */
  94497. transitionDuration: number;
  94498. /**
  94499. * Length of the distance animated by the transition when lower radius is reached
  94500. */
  94501. lowerRadiusTransitionRange: number;
  94502. /**
  94503. * Length of the distance animated by the transition when upper radius is reached
  94504. */
  94505. upperRadiusTransitionRange: number;
  94506. private _autoTransitionRange;
  94507. /**
  94508. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  94509. */
  94510. /**
  94511. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  94512. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  94513. */
  94514. autoTransitionRange: boolean;
  94515. private _attachedCamera;
  94516. private _onAfterCheckInputsObserver;
  94517. private _onMeshTargetChangedObserver;
  94518. /**
  94519. * Initializes the behavior.
  94520. */
  94521. init(): void;
  94522. /**
  94523. * Attaches the behavior to its arc rotate camera.
  94524. * @param camera Defines the camera to attach the behavior to
  94525. */
  94526. attach(camera: ArcRotateCamera): void;
  94527. /**
  94528. * Detaches the behavior from its current arc rotate camera.
  94529. */
  94530. detach(): void;
  94531. private _radiusIsAnimating;
  94532. private _radiusBounceTransition;
  94533. private _animatables;
  94534. private _cachedWheelPrecision;
  94535. /**
  94536. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  94537. * @param radiusLimit The limit to check against.
  94538. * @return Bool to indicate if at limit.
  94539. */
  94540. private _isRadiusAtLimit;
  94541. /**
  94542. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  94543. * @param radiusDelta The delta by which to animate to. Can be negative.
  94544. */
  94545. private _applyBoundRadiusAnimation;
  94546. /**
  94547. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  94548. */
  94549. protected _clearAnimationLocks(): void;
  94550. /**
  94551. * Stops and removes all animations that have been applied to the camera
  94552. */
  94553. stopAllAnimations(): void;
  94554. }
  94555. }
  94556. declare module BABYLON {
  94557. /**
  94558. * 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.
  94559. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  94560. */
  94561. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  94562. /**
  94563. * Gets the name of the behavior.
  94564. */
  94565. readonly name: string;
  94566. private _mode;
  94567. private _radiusScale;
  94568. private _positionScale;
  94569. private _defaultElevation;
  94570. private _elevationReturnTime;
  94571. private _elevationReturnWaitTime;
  94572. private _zoomStopsAnimation;
  94573. private _framingTime;
  94574. /**
  94575. * The easing function used by animations
  94576. */
  94577. static EasingFunction: ExponentialEase;
  94578. /**
  94579. * The easing mode used by animations
  94580. */
  94581. static EasingMode: number;
  94582. /**
  94583. * Sets the current mode used by the behavior
  94584. */
  94585. /**
  94586. * Gets current mode used by the behavior.
  94587. */
  94588. mode: number;
  94589. /**
  94590. * Sets the scale applied to the radius (1 by default)
  94591. */
  94592. /**
  94593. * Gets the scale applied to the radius
  94594. */
  94595. radiusScale: number;
  94596. /**
  94597. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  94598. */
  94599. /**
  94600. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  94601. */
  94602. positionScale: number;
  94603. /**
  94604. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  94605. * behaviour is triggered, in radians.
  94606. */
  94607. /**
  94608. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  94609. * behaviour is triggered, in radians.
  94610. */
  94611. defaultElevation: number;
  94612. /**
  94613. * Sets the time (in milliseconds) taken to return to the default beta position.
  94614. * Negative value indicates camera should not return to default.
  94615. */
  94616. /**
  94617. * Gets the time (in milliseconds) taken to return to the default beta position.
  94618. * Negative value indicates camera should not return to default.
  94619. */
  94620. elevationReturnTime: number;
  94621. /**
  94622. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  94623. */
  94624. /**
  94625. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  94626. */
  94627. elevationReturnWaitTime: number;
  94628. /**
  94629. * Sets the flag that indicates if user zooming should stop animation.
  94630. */
  94631. /**
  94632. * Gets the flag that indicates if user zooming should stop animation.
  94633. */
  94634. zoomStopsAnimation: boolean;
  94635. /**
  94636. * Sets the transition time when framing the mesh, in milliseconds
  94637. */
  94638. /**
  94639. * Gets the transition time when framing the mesh, in milliseconds
  94640. */
  94641. framingTime: number;
  94642. /**
  94643. * Define if the behavior should automatically change the configured
  94644. * camera limits and sensibilities.
  94645. */
  94646. autoCorrectCameraLimitsAndSensibility: boolean;
  94647. private _onPrePointerObservableObserver;
  94648. private _onAfterCheckInputsObserver;
  94649. private _onMeshTargetChangedObserver;
  94650. private _attachedCamera;
  94651. private _isPointerDown;
  94652. private _lastInteractionTime;
  94653. /**
  94654. * Initializes the behavior.
  94655. */
  94656. init(): void;
  94657. /**
  94658. * Attaches the behavior to its arc rotate camera.
  94659. * @param camera Defines the camera to attach the behavior to
  94660. */
  94661. attach(camera: ArcRotateCamera): void;
  94662. /**
  94663. * Detaches the behavior from its current arc rotate camera.
  94664. */
  94665. detach(): void;
  94666. private _animatables;
  94667. private _betaIsAnimating;
  94668. private _betaTransition;
  94669. private _radiusTransition;
  94670. private _vectorTransition;
  94671. /**
  94672. * Targets the given mesh and updates zoom level accordingly.
  94673. * @param mesh The mesh to target.
  94674. * @param radius Optional. If a cached radius position already exists, overrides default.
  94675. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  94676. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  94677. * @param onAnimationEnd Callback triggered at the end of the framing animation
  94678. */
  94679. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  94680. /**
  94681. * Targets the given mesh with its children and updates zoom level accordingly.
  94682. * @param mesh The mesh to target.
  94683. * @param radius Optional. If a cached radius position already exists, overrides default.
  94684. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  94685. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  94686. * @param onAnimationEnd Callback triggered at the end of the framing animation
  94687. */
  94688. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  94689. /**
  94690. * Targets the given meshes with their children and updates zoom level accordingly.
  94691. * @param meshes The mesh to target.
  94692. * @param radius Optional. If a cached radius position already exists, overrides default.
  94693. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  94694. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  94695. * @param onAnimationEnd Callback triggered at the end of the framing animation
  94696. */
  94697. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  94698. /**
  94699. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  94700. * @param minimumWorld Determines the smaller position of the bounding box extend
  94701. * @param maximumWorld Determines the bigger position of the bounding box extend
  94702. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  94703. * @param onAnimationEnd Callback triggered at the end of the framing animation
  94704. */
  94705. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  94706. /**
  94707. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  94708. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  94709. * frustum width.
  94710. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  94711. * to fully enclose the mesh in the viewing frustum.
  94712. */
  94713. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  94714. /**
  94715. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  94716. * is automatically returned to its default position (expected to be above ground plane).
  94717. */
  94718. private _maintainCameraAboveGround;
  94719. /**
  94720. * Returns the frustum slope based on the canvas ratio and camera FOV
  94721. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  94722. */
  94723. private _getFrustumSlope;
  94724. /**
  94725. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  94726. */
  94727. private _clearAnimationLocks;
  94728. /**
  94729. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  94730. */
  94731. private _applyUserInteraction;
  94732. /**
  94733. * Stops and removes all animations that have been applied to the camera
  94734. */
  94735. stopAllAnimations(): void;
  94736. /**
  94737. * Gets a value indicating if the user is moving the camera
  94738. */
  94739. readonly isUserIsMoving: boolean;
  94740. /**
  94741. * The camera can move all the way towards the mesh.
  94742. */
  94743. static IgnoreBoundsSizeMode: number;
  94744. /**
  94745. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  94746. */
  94747. static FitFrustumSidesMode: number;
  94748. }
  94749. }
  94750. declare module BABYLON {
  94751. /**
  94752. * Base class for Camera Pointer Inputs.
  94753. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  94754. * for example usage.
  94755. */
  94756. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  94757. /**
  94758. * Defines the camera the input is attached to.
  94759. */
  94760. abstract camera: Camera;
  94761. /**
  94762. * Whether keyboard modifier keys are pressed at time of last mouse event.
  94763. */
  94764. protected _altKey: boolean;
  94765. protected _ctrlKey: boolean;
  94766. protected _metaKey: boolean;
  94767. protected _shiftKey: boolean;
  94768. /**
  94769. * Which mouse buttons were pressed at time of last mouse event.
  94770. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  94771. */
  94772. protected _buttonsPressed: number;
  94773. /**
  94774. * Defines the buttons associated with the input to handle camera move.
  94775. */
  94776. buttons: number[];
  94777. /**
  94778. * Attach the input controls to a specific dom element to get the input from.
  94779. * @param element Defines the element the controls should be listened from
  94780. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94781. */
  94782. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94783. /**
  94784. * Detach the current controls from the specified dom element.
  94785. * @param element Defines the element to stop listening the inputs from
  94786. */
  94787. detachControl(element: Nullable<HTMLElement>): void;
  94788. /**
  94789. * Gets the class name of the current input.
  94790. * @returns the class name
  94791. */
  94792. getClassName(): string;
  94793. /**
  94794. * Get the friendly name associated with the input class.
  94795. * @returns the input friendly name
  94796. */
  94797. getSimpleName(): string;
  94798. /**
  94799. * Called on pointer POINTERDOUBLETAP event.
  94800. * Override this method to provide functionality on POINTERDOUBLETAP event.
  94801. */
  94802. protected onDoubleTap(type: string): void;
  94803. /**
  94804. * Called on pointer POINTERMOVE event if only a single touch is active.
  94805. * Override this method to provide functionality.
  94806. */
  94807. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  94808. /**
  94809. * Called on pointer POINTERMOVE event if multiple touches are active.
  94810. * Override this method to provide functionality.
  94811. */
  94812. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  94813. /**
  94814. * Called on JS contextmenu event.
  94815. * Override this method to provide functionality.
  94816. */
  94817. protected onContextMenu(evt: PointerEvent): void;
  94818. /**
  94819. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  94820. * press.
  94821. * Override this method to provide functionality.
  94822. */
  94823. protected onButtonDown(evt: PointerEvent): void;
  94824. /**
  94825. * Called each time a new POINTERUP event occurs. Ie, for each button
  94826. * release.
  94827. * Override this method to provide functionality.
  94828. */
  94829. protected onButtonUp(evt: PointerEvent): void;
  94830. /**
  94831. * Called when window becomes inactive.
  94832. * Override this method to provide functionality.
  94833. */
  94834. protected onLostFocus(): void;
  94835. private _pointerInput;
  94836. private _observer;
  94837. private _onLostFocus;
  94838. private pointA;
  94839. private pointB;
  94840. }
  94841. }
  94842. declare module BABYLON {
  94843. /**
  94844. * Manage the pointers inputs to control an arc rotate camera.
  94845. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94846. */
  94847. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  94848. /**
  94849. * Defines the camera the input is attached to.
  94850. */
  94851. camera: ArcRotateCamera;
  94852. /**
  94853. * Gets the class name of the current input.
  94854. * @returns the class name
  94855. */
  94856. getClassName(): string;
  94857. /**
  94858. * Defines the buttons associated with the input to handle camera move.
  94859. */
  94860. buttons: number[];
  94861. /**
  94862. * Defines the pointer angular sensibility along the X axis or how fast is
  94863. * the camera rotating.
  94864. */
  94865. angularSensibilityX: number;
  94866. /**
  94867. * Defines the pointer angular sensibility along the Y axis or how fast is
  94868. * the camera rotating.
  94869. */
  94870. angularSensibilityY: number;
  94871. /**
  94872. * Defines the pointer pinch precision or how fast is the camera zooming.
  94873. */
  94874. pinchPrecision: number;
  94875. /**
  94876. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  94877. * from 0.
  94878. * It defines the percentage of current camera.radius to use as delta when
  94879. * pinch zoom is used.
  94880. */
  94881. pinchDeltaPercentage: number;
  94882. /**
  94883. * Defines the pointer panning sensibility or how fast is the camera moving.
  94884. */
  94885. panningSensibility: number;
  94886. /**
  94887. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  94888. */
  94889. multiTouchPanning: boolean;
  94890. /**
  94891. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  94892. * zoom (pinch) through multitouch.
  94893. */
  94894. multiTouchPanAndZoom: boolean;
  94895. /**
  94896. * Revers pinch action direction.
  94897. */
  94898. pinchInwards: boolean;
  94899. private _isPanClick;
  94900. private _twoFingerActivityCount;
  94901. private _isPinching;
  94902. /**
  94903. * Called on pointer POINTERMOVE event if only a single touch is active.
  94904. */
  94905. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  94906. /**
  94907. * Called on pointer POINTERDOUBLETAP event.
  94908. */
  94909. protected onDoubleTap(type: string): void;
  94910. /**
  94911. * Called on pointer POINTERMOVE event if multiple touches are active.
  94912. */
  94913. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  94914. /**
  94915. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  94916. * press.
  94917. */
  94918. protected onButtonDown(evt: PointerEvent): void;
  94919. /**
  94920. * Called each time a new POINTERUP event occurs. Ie, for each button
  94921. * release.
  94922. */
  94923. protected onButtonUp(evt: PointerEvent): void;
  94924. /**
  94925. * Called when window becomes inactive.
  94926. */
  94927. protected onLostFocus(): void;
  94928. }
  94929. }
  94930. declare module BABYLON {
  94931. /**
  94932. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  94933. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94934. */
  94935. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  94936. /**
  94937. * Defines the camera the input is attached to.
  94938. */
  94939. camera: ArcRotateCamera;
  94940. /**
  94941. * Defines the list of key codes associated with the up action (increase alpha)
  94942. */
  94943. keysUp: number[];
  94944. /**
  94945. * Defines the list of key codes associated with the down action (decrease alpha)
  94946. */
  94947. keysDown: number[];
  94948. /**
  94949. * Defines the list of key codes associated with the left action (increase beta)
  94950. */
  94951. keysLeft: number[];
  94952. /**
  94953. * Defines the list of key codes associated with the right action (decrease beta)
  94954. */
  94955. keysRight: number[];
  94956. /**
  94957. * Defines the list of key codes associated with the reset action.
  94958. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  94959. */
  94960. keysReset: number[];
  94961. /**
  94962. * Defines the panning sensibility of the inputs.
  94963. * (How fast is the camera paning)
  94964. */
  94965. panningSensibility: number;
  94966. /**
  94967. * Defines the zooming sensibility of the inputs.
  94968. * (How fast is the camera zooming)
  94969. */
  94970. zoomingSensibility: number;
  94971. /**
  94972. * Defines wether maintaining the alt key down switch the movement mode from
  94973. * orientation to zoom.
  94974. */
  94975. useAltToZoom: boolean;
  94976. /**
  94977. * Rotation speed of the camera
  94978. */
  94979. angularSpeed: number;
  94980. private _keys;
  94981. private _ctrlPressed;
  94982. private _altPressed;
  94983. private _onCanvasBlurObserver;
  94984. private _onKeyboardObserver;
  94985. private _engine;
  94986. private _scene;
  94987. /**
  94988. * Attach the input controls to a specific dom element to get the input from.
  94989. * @param element Defines the element the controls should be listened from
  94990. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94991. */
  94992. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94993. /**
  94994. * Detach the current controls from the specified dom element.
  94995. * @param element Defines the element to stop listening the inputs from
  94996. */
  94997. detachControl(element: Nullable<HTMLElement>): void;
  94998. /**
  94999. * Update the current camera state depending on the inputs that have been used this frame.
  95000. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  95001. */
  95002. checkInputs(): void;
  95003. /**
  95004. * Gets the class name of the current intput.
  95005. * @returns the class name
  95006. */
  95007. getClassName(): string;
  95008. /**
  95009. * Get the friendly name associated with the input class.
  95010. * @returns the input friendly name
  95011. */
  95012. getSimpleName(): string;
  95013. }
  95014. }
  95015. declare module BABYLON {
  95016. /**
  95017. * Manage the mouse wheel inputs to control an arc rotate camera.
  95018. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95019. */
  95020. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  95021. /**
  95022. * Defines the camera the input is attached to.
  95023. */
  95024. camera: ArcRotateCamera;
  95025. /**
  95026. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  95027. */
  95028. wheelPrecision: number;
  95029. /**
  95030. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  95031. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  95032. */
  95033. wheelDeltaPercentage: number;
  95034. private _wheel;
  95035. private _observer;
  95036. private computeDeltaFromMouseWheelLegacyEvent;
  95037. /**
  95038. * Attach the input controls to a specific dom element to get the input from.
  95039. * @param element Defines the element the controls should be listened from
  95040. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95041. */
  95042. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95043. /**
  95044. * Detach the current controls from the specified dom element.
  95045. * @param element Defines the element to stop listening the inputs from
  95046. */
  95047. detachControl(element: Nullable<HTMLElement>): void;
  95048. /**
  95049. * Gets the class name of the current intput.
  95050. * @returns the class name
  95051. */
  95052. getClassName(): string;
  95053. /**
  95054. * Get the friendly name associated with the input class.
  95055. * @returns the input friendly name
  95056. */
  95057. getSimpleName(): string;
  95058. }
  95059. }
  95060. declare module BABYLON {
  95061. /**
  95062. * Default Inputs manager for the ArcRotateCamera.
  95063. * It groups all the default supported inputs for ease of use.
  95064. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95065. */
  95066. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  95067. /**
  95068. * Instantiates a new ArcRotateCameraInputsManager.
  95069. * @param camera Defines the camera the inputs belong to
  95070. */
  95071. constructor(camera: ArcRotateCamera);
  95072. /**
  95073. * Add mouse wheel input support to the input manager.
  95074. * @returns the current input manager
  95075. */
  95076. addMouseWheel(): ArcRotateCameraInputsManager;
  95077. /**
  95078. * Add pointers input support to the input manager.
  95079. * @returns the current input manager
  95080. */
  95081. addPointers(): ArcRotateCameraInputsManager;
  95082. /**
  95083. * Add keyboard input support to the input manager.
  95084. * @returns the current input manager
  95085. */
  95086. addKeyboard(): ArcRotateCameraInputsManager;
  95087. }
  95088. }
  95089. declare module BABYLON {
  95090. /**
  95091. * This represents an orbital type of camera.
  95092. *
  95093. * 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.
  95094. * 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.
  95095. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  95096. */
  95097. export class ArcRotateCamera extends TargetCamera {
  95098. /**
  95099. * Defines the rotation angle of the camera along the longitudinal axis.
  95100. */
  95101. alpha: number;
  95102. /**
  95103. * Defines the rotation angle of the camera along the latitudinal axis.
  95104. */
  95105. beta: number;
  95106. /**
  95107. * Defines the radius of the camera from it s target point.
  95108. */
  95109. radius: number;
  95110. protected _target: Vector3;
  95111. protected _targetHost: Nullable<AbstractMesh>;
  95112. /**
  95113. * Defines the target point of the camera.
  95114. * The camera looks towards it form the radius distance.
  95115. */
  95116. target: Vector3;
  95117. /**
  95118. * Define the current local position of the camera in the scene
  95119. */
  95120. position: Vector3;
  95121. protected _upVector: Vector3;
  95122. protected _upToYMatrix: Matrix;
  95123. protected _YToUpMatrix: Matrix;
  95124. /**
  95125. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  95126. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  95127. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  95128. */
  95129. upVector: Vector3;
  95130. /**
  95131. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  95132. */
  95133. setMatUp(): void;
  95134. /**
  95135. * Current inertia value on the longitudinal axis.
  95136. * The bigger this number the longer it will take for the camera to stop.
  95137. */
  95138. inertialAlphaOffset: number;
  95139. /**
  95140. * Current inertia value on the latitudinal axis.
  95141. * The bigger this number the longer it will take for the camera to stop.
  95142. */
  95143. inertialBetaOffset: number;
  95144. /**
  95145. * Current inertia value on the radius axis.
  95146. * The bigger this number the longer it will take for the camera to stop.
  95147. */
  95148. inertialRadiusOffset: number;
  95149. /**
  95150. * Minimum allowed angle on the longitudinal axis.
  95151. * This can help limiting how the Camera is able to move in the scene.
  95152. */
  95153. lowerAlphaLimit: Nullable<number>;
  95154. /**
  95155. * Maximum allowed angle on the longitudinal axis.
  95156. * This can help limiting how the Camera is able to move in the scene.
  95157. */
  95158. upperAlphaLimit: Nullable<number>;
  95159. /**
  95160. * Minimum allowed angle on the latitudinal axis.
  95161. * This can help limiting how the Camera is able to move in the scene.
  95162. */
  95163. lowerBetaLimit: number;
  95164. /**
  95165. * Maximum allowed angle on the latitudinal axis.
  95166. * This can help limiting how the Camera is able to move in the scene.
  95167. */
  95168. upperBetaLimit: number;
  95169. /**
  95170. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  95171. * This can help limiting how the Camera is able to move in the scene.
  95172. */
  95173. lowerRadiusLimit: Nullable<number>;
  95174. /**
  95175. * Maximum allowed distance of the camera to the target (The camera can not get further).
  95176. * This can help limiting how the Camera is able to move in the scene.
  95177. */
  95178. upperRadiusLimit: Nullable<number>;
  95179. /**
  95180. * Defines the current inertia value used during panning of the camera along the X axis.
  95181. */
  95182. inertialPanningX: number;
  95183. /**
  95184. * Defines the current inertia value used during panning of the camera along the Y axis.
  95185. */
  95186. inertialPanningY: number;
  95187. /**
  95188. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  95189. * Basically if your fingers moves away from more than this distance you will be considered
  95190. * in pinch mode.
  95191. */
  95192. pinchToPanMaxDistance: number;
  95193. /**
  95194. * Defines the maximum distance the camera can pan.
  95195. * This could help keeping the cammera always in your scene.
  95196. */
  95197. panningDistanceLimit: Nullable<number>;
  95198. /**
  95199. * Defines the target of the camera before paning.
  95200. */
  95201. panningOriginTarget: Vector3;
  95202. /**
  95203. * Defines the value of the inertia used during panning.
  95204. * 0 would mean stop inertia and one would mean no decelleration at all.
  95205. */
  95206. panningInertia: number;
  95207. /**
  95208. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  95209. */
  95210. angularSensibilityX: number;
  95211. /**
  95212. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  95213. */
  95214. angularSensibilityY: number;
  95215. /**
  95216. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  95217. */
  95218. pinchPrecision: number;
  95219. /**
  95220. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  95221. * It will be used instead of pinchDeltaPrecision if different from 0.
  95222. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  95223. */
  95224. pinchDeltaPercentage: number;
  95225. /**
  95226. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  95227. */
  95228. panningSensibility: number;
  95229. /**
  95230. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  95231. */
  95232. keysUp: number[];
  95233. /**
  95234. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  95235. */
  95236. keysDown: number[];
  95237. /**
  95238. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  95239. */
  95240. keysLeft: number[];
  95241. /**
  95242. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  95243. */
  95244. keysRight: number[];
  95245. /**
  95246. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  95247. */
  95248. wheelPrecision: number;
  95249. /**
  95250. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  95251. * It will be used instead of pinchDeltaPrecision if different from 0.
  95252. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  95253. */
  95254. wheelDeltaPercentage: number;
  95255. /**
  95256. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  95257. */
  95258. zoomOnFactor: number;
  95259. /**
  95260. * Defines a screen offset for the camera position.
  95261. */
  95262. targetScreenOffset: Vector2;
  95263. /**
  95264. * Allows the camera to be completely reversed.
  95265. * If false the camera can not arrive upside down.
  95266. */
  95267. allowUpsideDown: boolean;
  95268. /**
  95269. * Define if double tap/click is used to restore the previously saved state of the camera.
  95270. */
  95271. useInputToRestoreState: boolean;
  95272. /** @hidden */
  95273. _viewMatrix: Matrix;
  95274. /** @hidden */
  95275. _useCtrlForPanning: boolean;
  95276. /** @hidden */
  95277. _panningMouseButton: number;
  95278. /**
  95279. * Defines the input associated to the camera.
  95280. */
  95281. inputs: ArcRotateCameraInputsManager;
  95282. /** @hidden */
  95283. _reset: () => void;
  95284. /**
  95285. * Defines the allowed panning axis.
  95286. */
  95287. panningAxis: Vector3;
  95288. protected _localDirection: Vector3;
  95289. protected _transformedDirection: Vector3;
  95290. private _bouncingBehavior;
  95291. /**
  95292. * Gets the bouncing behavior of the camera if it has been enabled.
  95293. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  95294. */
  95295. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  95296. /**
  95297. * Defines if the bouncing behavior of the camera is enabled on the camera.
  95298. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  95299. */
  95300. useBouncingBehavior: boolean;
  95301. private _framingBehavior;
  95302. /**
  95303. * Gets the framing behavior of the camera if it has been enabled.
  95304. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  95305. */
  95306. readonly framingBehavior: Nullable<FramingBehavior>;
  95307. /**
  95308. * Defines if the framing behavior of the camera is enabled on the camera.
  95309. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  95310. */
  95311. useFramingBehavior: boolean;
  95312. private _autoRotationBehavior;
  95313. /**
  95314. * Gets the auto rotation behavior of the camera if it has been enabled.
  95315. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  95316. */
  95317. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  95318. /**
  95319. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  95320. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  95321. */
  95322. useAutoRotationBehavior: boolean;
  95323. /**
  95324. * Observable triggered when the mesh target has been changed on the camera.
  95325. */
  95326. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  95327. /**
  95328. * Event raised when the camera is colliding with a mesh.
  95329. */
  95330. onCollide: (collidedMesh: AbstractMesh) => void;
  95331. /**
  95332. * Defines whether the camera should check collision with the objects oh the scene.
  95333. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  95334. */
  95335. checkCollisions: boolean;
  95336. /**
  95337. * Defines the collision radius of the camera.
  95338. * This simulates a sphere around the camera.
  95339. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  95340. */
  95341. collisionRadius: Vector3;
  95342. protected _collider: Collider;
  95343. protected _previousPosition: Vector3;
  95344. protected _collisionVelocity: Vector3;
  95345. protected _newPosition: Vector3;
  95346. protected _previousAlpha: number;
  95347. protected _previousBeta: number;
  95348. protected _previousRadius: number;
  95349. protected _collisionTriggered: boolean;
  95350. protected _targetBoundingCenter: Nullable<Vector3>;
  95351. private _computationVector;
  95352. /**
  95353. * Instantiates a new ArcRotateCamera in a given scene
  95354. * @param name Defines the name of the camera
  95355. * @param alpha Defines the camera rotation along the logitudinal axis
  95356. * @param beta Defines the camera rotation along the latitudinal axis
  95357. * @param radius Defines the camera distance from its target
  95358. * @param target Defines the camera target
  95359. * @param scene Defines the scene the camera belongs to
  95360. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  95361. */
  95362. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  95363. /** @hidden */
  95364. _initCache(): void;
  95365. /** @hidden */
  95366. _updateCache(ignoreParentClass?: boolean): void;
  95367. protected _getTargetPosition(): Vector3;
  95368. private _storedAlpha;
  95369. private _storedBeta;
  95370. private _storedRadius;
  95371. private _storedTarget;
  95372. /**
  95373. * Stores the current state of the camera (alpha, beta, radius and target)
  95374. * @returns the camera itself
  95375. */
  95376. storeState(): Camera;
  95377. /**
  95378. * @hidden
  95379. * Restored camera state. You must call storeState() first
  95380. */
  95381. _restoreStateValues(): boolean;
  95382. /** @hidden */
  95383. _isSynchronizedViewMatrix(): boolean;
  95384. /**
  95385. * Attached controls to the current camera.
  95386. * @param element Defines the element the controls should be listened from
  95387. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95388. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  95389. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  95390. */
  95391. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  95392. /**
  95393. * Detach the current controls from the camera.
  95394. * The camera will stop reacting to inputs.
  95395. * @param element Defines the element to stop listening the inputs from
  95396. */
  95397. detachControl(element: HTMLElement): void;
  95398. /** @hidden */
  95399. _checkInputs(): void;
  95400. protected _checkLimits(): void;
  95401. /**
  95402. * Rebuilds angles (alpha, beta) and radius from the give position and target
  95403. */
  95404. rebuildAnglesAndRadius(): void;
  95405. /**
  95406. * Use a position to define the current camera related information like aplha, beta and radius
  95407. * @param position Defines the position to set the camera at
  95408. */
  95409. setPosition(position: Vector3): void;
  95410. /**
  95411. * Defines the target the camera should look at.
  95412. * This will automatically adapt alpha beta and radius to fit within the new target.
  95413. * @param target Defines the new target as a Vector or a mesh
  95414. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  95415. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  95416. */
  95417. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  95418. /** @hidden */
  95419. _getViewMatrix(): Matrix;
  95420. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  95421. /**
  95422. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  95423. * @param meshes Defines the mesh to zoom on
  95424. * @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)
  95425. */
  95426. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  95427. /**
  95428. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  95429. * The target will be changed but the radius
  95430. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  95431. * @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)
  95432. */
  95433. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  95434. min: Vector3;
  95435. max: Vector3;
  95436. distance: number;
  95437. }, doNotUpdateMaxZ?: boolean): void;
  95438. /**
  95439. * @override
  95440. * Override Camera.createRigCamera
  95441. */
  95442. createRigCamera(name: string, cameraIndex: number): Camera;
  95443. /**
  95444. * @hidden
  95445. * @override
  95446. * Override Camera._updateRigCameras
  95447. */
  95448. _updateRigCameras(): void;
  95449. /**
  95450. * Destroy the camera and release the current resources hold by it.
  95451. */
  95452. dispose(): void;
  95453. /**
  95454. * Gets the current object class name.
  95455. * @return the class name
  95456. */
  95457. getClassName(): string;
  95458. }
  95459. }
  95460. declare module BABYLON {
  95461. /**
  95462. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  95463. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  95464. */
  95465. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  95466. /**
  95467. * Gets the name of the behavior.
  95468. */
  95469. readonly name: string;
  95470. private _zoomStopsAnimation;
  95471. private _idleRotationSpeed;
  95472. private _idleRotationWaitTime;
  95473. private _idleRotationSpinupTime;
  95474. /**
  95475. * Sets the flag that indicates if user zooming should stop animation.
  95476. */
  95477. /**
  95478. * Gets the flag that indicates if user zooming should stop animation.
  95479. */
  95480. zoomStopsAnimation: boolean;
  95481. /**
  95482. * Sets the default speed at which the camera rotates around the model.
  95483. */
  95484. /**
  95485. * Gets the default speed at which the camera rotates around the model.
  95486. */
  95487. idleRotationSpeed: number;
  95488. /**
  95489. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  95490. */
  95491. /**
  95492. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  95493. */
  95494. idleRotationWaitTime: number;
  95495. /**
  95496. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  95497. */
  95498. /**
  95499. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  95500. */
  95501. idleRotationSpinupTime: number;
  95502. /**
  95503. * Gets a value indicating if the camera is currently rotating because of this behavior
  95504. */
  95505. readonly rotationInProgress: boolean;
  95506. private _onPrePointerObservableObserver;
  95507. private _onAfterCheckInputsObserver;
  95508. private _attachedCamera;
  95509. private _isPointerDown;
  95510. private _lastFrameTime;
  95511. private _lastInteractionTime;
  95512. private _cameraRotationSpeed;
  95513. /**
  95514. * Initializes the behavior.
  95515. */
  95516. init(): void;
  95517. /**
  95518. * Attaches the behavior to its arc rotate camera.
  95519. * @param camera Defines the camera to attach the behavior to
  95520. */
  95521. attach(camera: ArcRotateCamera): void;
  95522. /**
  95523. * Detaches the behavior from its current arc rotate camera.
  95524. */
  95525. detach(): void;
  95526. /**
  95527. * Returns true if user is scrolling.
  95528. * @return true if user is scrolling.
  95529. */
  95530. private _userIsZooming;
  95531. private _lastFrameRadius;
  95532. private _shouldAnimationStopForInteraction;
  95533. /**
  95534. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  95535. */
  95536. private _applyUserInteraction;
  95537. private _userIsMoving;
  95538. }
  95539. }
  95540. declare module BABYLON {
  95541. /**
  95542. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  95543. */
  95544. export class AttachToBoxBehavior implements Behavior<Mesh> {
  95545. private ui;
  95546. /**
  95547. * The name of the behavior
  95548. */
  95549. name: string;
  95550. /**
  95551. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  95552. */
  95553. distanceAwayFromFace: number;
  95554. /**
  95555. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  95556. */
  95557. distanceAwayFromBottomOfFace: number;
  95558. private _faceVectors;
  95559. private _target;
  95560. private _scene;
  95561. private _onRenderObserver;
  95562. private _tmpMatrix;
  95563. private _tmpVector;
  95564. /**
  95565. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  95566. * @param ui The transform node that should be attched to the mesh
  95567. */
  95568. constructor(ui: TransformNode);
  95569. /**
  95570. * Initializes the behavior
  95571. */
  95572. init(): void;
  95573. private _closestFace;
  95574. private _zeroVector;
  95575. private _lookAtTmpMatrix;
  95576. private _lookAtToRef;
  95577. /**
  95578. * Attaches the AttachToBoxBehavior to the passed in mesh
  95579. * @param target The mesh that the specified node will be attached to
  95580. */
  95581. attach(target: Mesh): void;
  95582. /**
  95583. * Detaches the behavior from the mesh
  95584. */
  95585. detach(): void;
  95586. }
  95587. }
  95588. declare module BABYLON {
  95589. /**
  95590. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  95591. */
  95592. export class FadeInOutBehavior implements Behavior<Mesh> {
  95593. /**
  95594. * Time in milliseconds to delay before fading in (Default: 0)
  95595. */
  95596. delay: number;
  95597. /**
  95598. * Time in milliseconds for the mesh to fade in (Default: 300)
  95599. */
  95600. fadeInTime: number;
  95601. private _millisecondsPerFrame;
  95602. private _hovered;
  95603. private _hoverValue;
  95604. private _ownerNode;
  95605. /**
  95606. * Instatiates the FadeInOutBehavior
  95607. */
  95608. constructor();
  95609. /**
  95610. * The name of the behavior
  95611. */
  95612. readonly name: string;
  95613. /**
  95614. * Initializes the behavior
  95615. */
  95616. init(): void;
  95617. /**
  95618. * Attaches the fade behavior on the passed in mesh
  95619. * @param ownerNode The mesh that will be faded in/out once attached
  95620. */
  95621. attach(ownerNode: Mesh): void;
  95622. /**
  95623. * Detaches the behavior from the mesh
  95624. */
  95625. detach(): void;
  95626. /**
  95627. * Triggers the mesh to begin fading in or out
  95628. * @param value if the object should fade in or out (true to fade in)
  95629. */
  95630. fadeIn(value: boolean): void;
  95631. private _update;
  95632. private _setAllVisibility;
  95633. }
  95634. }
  95635. declare module BABYLON {
  95636. /**
  95637. * Class containing a set of static utilities functions for managing Pivots
  95638. * @hidden
  95639. */
  95640. export class PivotTools {
  95641. private static _PivotCached;
  95642. private static _OldPivotPoint;
  95643. private static _PivotTranslation;
  95644. private static _PivotTmpVector;
  95645. /** @hidden */
  95646. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  95647. /** @hidden */
  95648. static _RestorePivotPoint(mesh: AbstractMesh): void;
  95649. }
  95650. }
  95651. declare module BABYLON {
  95652. /**
  95653. * Class containing static functions to help procedurally build meshes
  95654. */
  95655. export class PlaneBuilder {
  95656. /**
  95657. * Creates a plane mesh
  95658. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  95659. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  95660. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  95661. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  95662. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  95663. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  95664. * @param name defines the name of the mesh
  95665. * @param options defines the options used to create the mesh
  95666. * @param scene defines the hosting scene
  95667. * @returns the plane mesh
  95668. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  95669. */
  95670. static CreatePlane(name: string, options: {
  95671. size?: number;
  95672. width?: number;
  95673. height?: number;
  95674. sideOrientation?: number;
  95675. frontUVs?: Vector4;
  95676. backUVs?: Vector4;
  95677. updatable?: boolean;
  95678. sourcePlane?: Plane;
  95679. }, scene?: Nullable<Scene>): Mesh;
  95680. }
  95681. }
  95682. declare module BABYLON {
  95683. /**
  95684. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  95685. */
  95686. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  95687. private static _AnyMouseID;
  95688. private _attachedNode;
  95689. private _dragPlane;
  95690. private _scene;
  95691. private _pointerObserver;
  95692. private _beforeRenderObserver;
  95693. private static _planeScene;
  95694. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  95695. /**
  95696. * 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)
  95697. */
  95698. maxDragAngle: number;
  95699. /**
  95700. * @hidden
  95701. */
  95702. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  95703. /**
  95704. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  95705. */
  95706. currentDraggingPointerID: number;
  95707. /**
  95708. * The last position where the pointer hit the drag plane in world space
  95709. */
  95710. lastDragPosition: Vector3;
  95711. /**
  95712. * If the behavior is currently in a dragging state
  95713. */
  95714. dragging: boolean;
  95715. /**
  95716. * 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)
  95717. */
  95718. dragDeltaRatio: number;
  95719. /**
  95720. * If the drag plane orientation should be updated during the dragging (Default: true)
  95721. */
  95722. updateDragPlane: boolean;
  95723. private _debugMode;
  95724. private _moving;
  95725. /**
  95726. * Fires each time the attached mesh is dragged with the pointer
  95727. * * delta between last drag position and current drag position in world space
  95728. * * dragDistance along the drag axis
  95729. * * dragPlaneNormal normal of the current drag plane used during the drag
  95730. * * dragPlanePoint in world space where the drag intersects the drag plane
  95731. */
  95732. onDragObservable: Observable<{
  95733. delta: Vector3;
  95734. dragPlanePoint: Vector3;
  95735. dragPlaneNormal: Vector3;
  95736. dragDistance: number;
  95737. pointerId: number;
  95738. }>;
  95739. /**
  95740. * Fires each time a drag begins (eg. mouse down on mesh)
  95741. */
  95742. onDragStartObservable: Observable<{
  95743. dragPlanePoint: Vector3;
  95744. pointerId: number;
  95745. }>;
  95746. /**
  95747. * Fires each time a drag ends (eg. mouse release after drag)
  95748. */
  95749. onDragEndObservable: Observable<{
  95750. dragPlanePoint: Vector3;
  95751. pointerId: number;
  95752. }>;
  95753. /**
  95754. * If the attached mesh should be moved when dragged
  95755. */
  95756. moveAttached: boolean;
  95757. /**
  95758. * If the drag behavior will react to drag events (Default: true)
  95759. */
  95760. enabled: boolean;
  95761. /**
  95762. * If camera controls should be detached during the drag
  95763. */
  95764. detachCameraControls: boolean;
  95765. /**
  95766. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  95767. */
  95768. useObjectOrienationForDragging: boolean;
  95769. private _options;
  95770. /**
  95771. * Creates a pointer drag behavior that can be attached to a mesh
  95772. * @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)
  95773. */
  95774. constructor(options?: {
  95775. dragAxis?: Vector3;
  95776. dragPlaneNormal?: Vector3;
  95777. });
  95778. /**
  95779. * Predicate to determine if it is valid to move the object to a new position when it is moved
  95780. */
  95781. validateDrag: (targetPosition: Vector3) => boolean;
  95782. /**
  95783. * The name of the behavior
  95784. */
  95785. readonly name: string;
  95786. /**
  95787. * Initializes the behavior
  95788. */
  95789. init(): void;
  95790. private _tmpVector;
  95791. private _alternatePickedPoint;
  95792. private _worldDragAxis;
  95793. private _targetPosition;
  95794. private _attachedElement;
  95795. /**
  95796. * Attaches the drag behavior the passed in mesh
  95797. * @param ownerNode The mesh that will be dragged around once attached
  95798. */
  95799. attach(ownerNode: AbstractMesh): void;
  95800. /**
  95801. * Force relase the drag action by code.
  95802. */
  95803. releaseDrag(): void;
  95804. private _startDragRay;
  95805. private _lastPointerRay;
  95806. /**
  95807. * Simulates the start of a pointer drag event on the behavior
  95808. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  95809. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  95810. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  95811. */
  95812. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  95813. private _startDrag;
  95814. private _dragDelta;
  95815. private _moveDrag;
  95816. private _pickWithRayOnDragPlane;
  95817. private _pointA;
  95818. private _pointB;
  95819. private _pointC;
  95820. private _lineA;
  95821. private _lineB;
  95822. private _localAxis;
  95823. private _lookAt;
  95824. private _updateDragPlanePosition;
  95825. /**
  95826. * Detaches the behavior from the mesh
  95827. */
  95828. detach(): void;
  95829. }
  95830. }
  95831. declare module BABYLON {
  95832. /**
  95833. * A behavior that when attached to a mesh will allow the mesh to be scaled
  95834. */
  95835. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  95836. private _dragBehaviorA;
  95837. private _dragBehaviorB;
  95838. private _startDistance;
  95839. private _initialScale;
  95840. private _targetScale;
  95841. private _ownerNode;
  95842. private _sceneRenderObserver;
  95843. /**
  95844. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  95845. */
  95846. constructor();
  95847. /**
  95848. * The name of the behavior
  95849. */
  95850. readonly name: string;
  95851. /**
  95852. * Initializes the behavior
  95853. */
  95854. init(): void;
  95855. private _getCurrentDistance;
  95856. /**
  95857. * Attaches the scale behavior the passed in mesh
  95858. * @param ownerNode The mesh that will be scaled around once attached
  95859. */
  95860. attach(ownerNode: Mesh): void;
  95861. /**
  95862. * Detaches the behavior from the mesh
  95863. */
  95864. detach(): void;
  95865. }
  95866. }
  95867. declare module BABYLON {
  95868. /**
  95869. * 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
  95870. */
  95871. export class SixDofDragBehavior implements Behavior<Mesh> {
  95872. private static _virtualScene;
  95873. private _ownerNode;
  95874. private _sceneRenderObserver;
  95875. private _scene;
  95876. private _targetPosition;
  95877. private _virtualOriginMesh;
  95878. private _virtualDragMesh;
  95879. private _pointerObserver;
  95880. private _moving;
  95881. private _startingOrientation;
  95882. /**
  95883. * 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)
  95884. */
  95885. private zDragFactor;
  95886. /**
  95887. * If the object should rotate to face the drag origin
  95888. */
  95889. rotateDraggedObject: boolean;
  95890. /**
  95891. * If the behavior is currently in a dragging state
  95892. */
  95893. dragging: boolean;
  95894. /**
  95895. * 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)
  95896. */
  95897. dragDeltaRatio: number;
  95898. /**
  95899. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  95900. */
  95901. currentDraggingPointerID: number;
  95902. /**
  95903. * If camera controls should be detached during the drag
  95904. */
  95905. detachCameraControls: boolean;
  95906. /**
  95907. * Fires each time a drag starts
  95908. */
  95909. onDragStartObservable: Observable<{}>;
  95910. /**
  95911. * Fires each time a drag ends (eg. mouse release after drag)
  95912. */
  95913. onDragEndObservable: Observable<{}>;
  95914. /**
  95915. * 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
  95916. */
  95917. constructor();
  95918. /**
  95919. * The name of the behavior
  95920. */
  95921. readonly name: string;
  95922. /**
  95923. * Initializes the behavior
  95924. */
  95925. init(): void;
  95926. /**
  95927. * Attaches the scale behavior the passed in mesh
  95928. * @param ownerNode The mesh that will be scaled around once attached
  95929. */
  95930. attach(ownerNode: Mesh): void;
  95931. /**
  95932. * Detaches the behavior from the mesh
  95933. */
  95934. detach(): void;
  95935. }
  95936. }
  95937. declare module BABYLON {
  95938. /**
  95939. * Class used to apply inverse kinematics to bones
  95940. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  95941. */
  95942. export class BoneIKController {
  95943. private static _tmpVecs;
  95944. private static _tmpQuat;
  95945. private static _tmpMats;
  95946. /**
  95947. * Gets or sets the target mesh
  95948. */
  95949. targetMesh: AbstractMesh;
  95950. /** Gets or sets the mesh used as pole */
  95951. poleTargetMesh: AbstractMesh;
  95952. /**
  95953. * Gets or sets the bone used as pole
  95954. */
  95955. poleTargetBone: Nullable<Bone>;
  95956. /**
  95957. * Gets or sets the target position
  95958. */
  95959. targetPosition: Vector3;
  95960. /**
  95961. * Gets or sets the pole target position
  95962. */
  95963. poleTargetPosition: Vector3;
  95964. /**
  95965. * Gets or sets the pole target local offset
  95966. */
  95967. poleTargetLocalOffset: Vector3;
  95968. /**
  95969. * Gets or sets the pole angle
  95970. */
  95971. poleAngle: number;
  95972. /**
  95973. * Gets or sets the mesh associated with the controller
  95974. */
  95975. mesh: AbstractMesh;
  95976. /**
  95977. * 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)
  95978. */
  95979. slerpAmount: number;
  95980. private _bone1Quat;
  95981. private _bone1Mat;
  95982. private _bone2Ang;
  95983. private _bone1;
  95984. private _bone2;
  95985. private _bone1Length;
  95986. private _bone2Length;
  95987. private _maxAngle;
  95988. private _maxReach;
  95989. private _rightHandedSystem;
  95990. private _bendAxis;
  95991. private _slerping;
  95992. private _adjustRoll;
  95993. /**
  95994. * Gets or sets maximum allowed angle
  95995. */
  95996. maxAngle: number;
  95997. /**
  95998. * Creates a new BoneIKController
  95999. * @param mesh defines the mesh to control
  96000. * @param bone defines the bone to control
  96001. * @param options defines options to set up the controller
  96002. */
  96003. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  96004. targetMesh?: AbstractMesh;
  96005. poleTargetMesh?: AbstractMesh;
  96006. poleTargetBone?: Bone;
  96007. poleTargetLocalOffset?: Vector3;
  96008. poleAngle?: number;
  96009. bendAxis?: Vector3;
  96010. maxAngle?: number;
  96011. slerpAmount?: number;
  96012. });
  96013. private _setMaxAngle;
  96014. /**
  96015. * Force the controller to update the bones
  96016. */
  96017. update(): void;
  96018. }
  96019. }
  96020. declare module BABYLON {
  96021. /**
  96022. * Class used to make a bone look toward a point in space
  96023. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  96024. */
  96025. export class BoneLookController {
  96026. private static _tmpVecs;
  96027. private static _tmpQuat;
  96028. private static _tmpMats;
  96029. /**
  96030. * The target Vector3 that the bone will look at
  96031. */
  96032. target: Vector3;
  96033. /**
  96034. * The mesh that the bone is attached to
  96035. */
  96036. mesh: AbstractMesh;
  96037. /**
  96038. * The bone that will be looking to the target
  96039. */
  96040. bone: Bone;
  96041. /**
  96042. * The up axis of the coordinate system that is used when the bone is rotated
  96043. */
  96044. upAxis: Vector3;
  96045. /**
  96046. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  96047. */
  96048. upAxisSpace: Space;
  96049. /**
  96050. * Used to make an adjustment to the yaw of the bone
  96051. */
  96052. adjustYaw: number;
  96053. /**
  96054. * Used to make an adjustment to the pitch of the bone
  96055. */
  96056. adjustPitch: number;
  96057. /**
  96058. * Used to make an adjustment to the roll of the bone
  96059. */
  96060. adjustRoll: number;
  96061. /**
  96062. * 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)
  96063. */
  96064. slerpAmount: number;
  96065. private _minYaw;
  96066. private _maxYaw;
  96067. private _minPitch;
  96068. private _maxPitch;
  96069. private _minYawSin;
  96070. private _minYawCos;
  96071. private _maxYawSin;
  96072. private _maxYawCos;
  96073. private _midYawConstraint;
  96074. private _minPitchTan;
  96075. private _maxPitchTan;
  96076. private _boneQuat;
  96077. private _slerping;
  96078. private _transformYawPitch;
  96079. private _transformYawPitchInv;
  96080. private _firstFrameSkipped;
  96081. private _yawRange;
  96082. private _fowardAxis;
  96083. /**
  96084. * Gets or sets the minimum yaw angle that the bone can look to
  96085. */
  96086. minYaw: number;
  96087. /**
  96088. * Gets or sets the maximum yaw angle that the bone can look to
  96089. */
  96090. maxYaw: number;
  96091. /**
  96092. * Gets or sets the minimum pitch angle that the bone can look to
  96093. */
  96094. minPitch: number;
  96095. /**
  96096. * Gets or sets the maximum pitch angle that the bone can look to
  96097. */
  96098. maxPitch: number;
  96099. /**
  96100. * Create a BoneLookController
  96101. * @param mesh the mesh that the bone belongs to
  96102. * @param bone the bone that will be looking to the target
  96103. * @param target the target Vector3 to look at
  96104. * @param options optional settings:
  96105. * * maxYaw: the maximum angle the bone will yaw to
  96106. * * minYaw: the minimum angle the bone will yaw to
  96107. * * maxPitch: the maximum angle the bone will pitch to
  96108. * * minPitch: the minimum angle the bone will yaw to
  96109. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  96110. * * upAxis: the up axis of the coordinate system
  96111. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  96112. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  96113. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  96114. * * adjustYaw: used to make an adjustment to the yaw of the bone
  96115. * * adjustPitch: used to make an adjustment to the pitch of the bone
  96116. * * adjustRoll: used to make an adjustment to the roll of the bone
  96117. **/
  96118. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  96119. maxYaw?: number;
  96120. minYaw?: number;
  96121. maxPitch?: number;
  96122. minPitch?: number;
  96123. slerpAmount?: number;
  96124. upAxis?: Vector3;
  96125. upAxisSpace?: Space;
  96126. yawAxis?: Vector3;
  96127. pitchAxis?: Vector3;
  96128. adjustYaw?: number;
  96129. adjustPitch?: number;
  96130. adjustRoll?: number;
  96131. });
  96132. /**
  96133. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  96134. */
  96135. update(): void;
  96136. private _getAngleDiff;
  96137. private _getAngleBetween;
  96138. private _isAngleBetween;
  96139. }
  96140. }
  96141. declare module BABYLON {
  96142. /**
  96143. * Manage the gamepad inputs to control an arc rotate camera.
  96144. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96145. */
  96146. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  96147. /**
  96148. * Defines the camera the input is attached to.
  96149. */
  96150. camera: ArcRotateCamera;
  96151. /**
  96152. * Defines the gamepad the input is gathering event from.
  96153. */
  96154. gamepad: Nullable<Gamepad>;
  96155. /**
  96156. * Defines the gamepad rotation sensiblity.
  96157. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  96158. */
  96159. gamepadRotationSensibility: number;
  96160. /**
  96161. * Defines the gamepad move sensiblity.
  96162. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  96163. */
  96164. gamepadMoveSensibility: number;
  96165. private _onGamepadConnectedObserver;
  96166. private _onGamepadDisconnectedObserver;
  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 intput.
  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. }
  96195. declare module BABYLON {
  96196. interface ArcRotateCameraInputsManager {
  96197. /**
  96198. * Add orientation input support to the input manager.
  96199. * @returns the current input manager
  96200. */
  96201. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  96202. }
  96203. /**
  96204. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  96205. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96206. */
  96207. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  96208. /**
  96209. * Defines the camera the input is attached to.
  96210. */
  96211. camera: ArcRotateCamera;
  96212. /**
  96213. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  96214. */
  96215. alphaCorrection: number;
  96216. /**
  96217. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  96218. */
  96219. gammaCorrection: number;
  96220. private _alpha;
  96221. private _gamma;
  96222. private _dirty;
  96223. private _deviceOrientationHandler;
  96224. /**
  96225. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  96226. */
  96227. constructor();
  96228. /**
  96229. * Attach the input controls to a specific dom element to get the input from.
  96230. * @param element Defines the element the controls should be listened from
  96231. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96232. */
  96233. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96234. /** @hidden */
  96235. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  96236. /**
  96237. * Update the current camera state depending on the inputs that have been used this frame.
  96238. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  96239. */
  96240. checkInputs(): void;
  96241. /**
  96242. * Detach the current controls from the specified dom element.
  96243. * @param element Defines the element to stop listening the inputs from
  96244. */
  96245. detachControl(element: Nullable<HTMLElement>): void;
  96246. /**
  96247. * Gets the class name of the current intput.
  96248. * @returns the class name
  96249. */
  96250. getClassName(): string;
  96251. /**
  96252. * Get the friendly name associated with the input class.
  96253. * @returns the input friendly name
  96254. */
  96255. getSimpleName(): string;
  96256. }
  96257. }
  96258. declare module BABYLON {
  96259. /**
  96260. * Listen to mouse events to control the camera.
  96261. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96262. */
  96263. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  96264. /**
  96265. * Defines the camera the input is attached to.
  96266. */
  96267. camera: FlyCamera;
  96268. /**
  96269. * Defines if touch is enabled. (Default is true.)
  96270. */
  96271. touchEnabled: boolean;
  96272. /**
  96273. * Defines the buttons associated with the input to handle camera rotation.
  96274. */
  96275. buttons: number[];
  96276. /**
  96277. * Assign buttons for Yaw control.
  96278. */
  96279. buttonsYaw: number[];
  96280. /**
  96281. * Assign buttons for Pitch control.
  96282. */
  96283. buttonsPitch: number[];
  96284. /**
  96285. * Assign buttons for Roll control.
  96286. */
  96287. buttonsRoll: number[];
  96288. /**
  96289. * Detect if any button is being pressed while mouse is moved.
  96290. * -1 = Mouse locked.
  96291. * 0 = Left button.
  96292. * 1 = Middle Button.
  96293. * 2 = Right Button.
  96294. */
  96295. activeButton: number;
  96296. /**
  96297. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  96298. * Higher values reduce its sensitivity.
  96299. */
  96300. angularSensibility: number;
  96301. private _mousemoveCallback;
  96302. private _observer;
  96303. private _rollObserver;
  96304. private previousPosition;
  96305. private noPreventDefault;
  96306. private element;
  96307. /**
  96308. * Listen to mouse events to control the camera.
  96309. * @param touchEnabled Define if touch is enabled. (Default is true.)
  96310. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96311. */
  96312. constructor(touchEnabled?: boolean);
  96313. /**
  96314. * Attach the mouse control to the HTML DOM element.
  96315. * @param element Defines the element that listens to the input events.
  96316. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  96317. */
  96318. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96319. /**
  96320. * Detach the current controls from the specified dom element.
  96321. * @param element Defines the element to stop listening the inputs from
  96322. */
  96323. detachControl(element: Nullable<HTMLElement>): void;
  96324. /**
  96325. * Gets the class name of the current input.
  96326. * @returns the class name.
  96327. */
  96328. getClassName(): string;
  96329. /**
  96330. * Get the friendly name associated with the input class.
  96331. * @returns the input's friendly name.
  96332. */
  96333. getSimpleName(): string;
  96334. private _pointerInput;
  96335. private _onMouseMove;
  96336. /**
  96337. * Rotate camera by mouse offset.
  96338. */
  96339. private rotateCamera;
  96340. }
  96341. }
  96342. declare module BABYLON {
  96343. /**
  96344. * Default Inputs manager for the FlyCamera.
  96345. * It groups all the default supported inputs for ease of use.
  96346. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96347. */
  96348. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  96349. /**
  96350. * Instantiates a new FlyCameraInputsManager.
  96351. * @param camera Defines the camera the inputs belong to.
  96352. */
  96353. constructor(camera: FlyCamera);
  96354. /**
  96355. * Add keyboard input support to the input manager.
  96356. * @returns the new FlyCameraKeyboardMoveInput().
  96357. */
  96358. addKeyboard(): FlyCameraInputsManager;
  96359. /**
  96360. * Add mouse input support to the input manager.
  96361. * @param touchEnabled Enable touch screen support.
  96362. * @returns the new FlyCameraMouseInput().
  96363. */
  96364. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  96365. }
  96366. }
  96367. declare module BABYLON {
  96368. /**
  96369. * This is a flying camera, designed for 3D movement and rotation in all directions,
  96370. * such as in a 3D Space Shooter or a Flight Simulator.
  96371. */
  96372. export class FlyCamera extends TargetCamera {
  96373. /**
  96374. * Define the collision ellipsoid of the camera.
  96375. * This is helpful for simulating a camera body, like a player's body.
  96376. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  96377. */
  96378. ellipsoid: Vector3;
  96379. /**
  96380. * Define an offset for the position of the ellipsoid around the camera.
  96381. * This can be helpful if the camera is attached away from the player's body center,
  96382. * such as at its head.
  96383. */
  96384. ellipsoidOffset: Vector3;
  96385. /**
  96386. * Enable or disable collisions of the camera with the rest of the scene objects.
  96387. */
  96388. checkCollisions: boolean;
  96389. /**
  96390. * Enable or disable gravity on the camera.
  96391. */
  96392. applyGravity: boolean;
  96393. /**
  96394. * Define the current direction the camera is moving to.
  96395. */
  96396. cameraDirection: Vector3;
  96397. /**
  96398. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  96399. * This overrides and empties cameraRotation.
  96400. */
  96401. rotationQuaternion: Quaternion;
  96402. /**
  96403. * Track Roll to maintain the wanted Rolling when looking around.
  96404. */
  96405. _trackRoll: number;
  96406. /**
  96407. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  96408. */
  96409. rollCorrect: number;
  96410. /**
  96411. * Mimic a banked turn, Rolling the camera when Yawing.
  96412. * It's recommended to use rollCorrect = 10 for faster banking correction.
  96413. */
  96414. bankedTurn: boolean;
  96415. /**
  96416. * Limit in radians for how much Roll banking will add. (Default: 90°)
  96417. */
  96418. bankedTurnLimit: number;
  96419. /**
  96420. * Value of 0 disables the banked Roll.
  96421. * Value of 1 is equal to the Yaw angle in radians.
  96422. */
  96423. bankedTurnMultiplier: number;
  96424. /**
  96425. * The inputs manager loads all the input sources, such as keyboard and mouse.
  96426. */
  96427. inputs: FlyCameraInputsManager;
  96428. /**
  96429. * Gets the input sensibility for mouse input.
  96430. * Higher values reduce sensitivity.
  96431. */
  96432. /**
  96433. * Sets the input sensibility for a mouse input.
  96434. * Higher values reduce sensitivity.
  96435. */
  96436. angularSensibility: number;
  96437. /**
  96438. * Get the keys for camera movement forward.
  96439. */
  96440. /**
  96441. * Set the keys for camera movement forward.
  96442. */
  96443. keysForward: number[];
  96444. /**
  96445. * Get the keys for camera movement backward.
  96446. */
  96447. keysBackward: number[];
  96448. /**
  96449. * Get the keys for camera movement up.
  96450. */
  96451. /**
  96452. * Set the keys for camera movement up.
  96453. */
  96454. keysUp: number[];
  96455. /**
  96456. * Get the keys for camera movement down.
  96457. */
  96458. /**
  96459. * Set the keys for camera movement down.
  96460. */
  96461. keysDown: number[];
  96462. /**
  96463. * Get the keys for camera movement left.
  96464. */
  96465. /**
  96466. * Set the keys for camera movement left.
  96467. */
  96468. keysLeft: number[];
  96469. /**
  96470. * Set the keys for camera movement right.
  96471. */
  96472. /**
  96473. * Set the keys for camera movement right.
  96474. */
  96475. keysRight: number[];
  96476. /**
  96477. * Event raised when the camera collides with a mesh in the scene.
  96478. */
  96479. onCollide: (collidedMesh: AbstractMesh) => void;
  96480. private _collider;
  96481. private _needMoveForGravity;
  96482. private _oldPosition;
  96483. private _diffPosition;
  96484. private _newPosition;
  96485. /** @hidden */
  96486. _localDirection: Vector3;
  96487. /** @hidden */
  96488. _transformedDirection: Vector3;
  96489. /**
  96490. * Instantiates a FlyCamera.
  96491. * This is a flying camera, designed for 3D movement and rotation in all directions,
  96492. * such as in a 3D Space Shooter or a Flight Simulator.
  96493. * @param name Define the name of the camera in the scene.
  96494. * @param position Define the starting position of the camera in the scene.
  96495. * @param scene Define the scene the camera belongs to.
  96496. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  96497. */
  96498. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  96499. /**
  96500. * Attach a control to the HTML DOM element.
  96501. * @param element Defines the element that listens to the input events.
  96502. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  96503. */
  96504. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96505. /**
  96506. * Detach a control from the HTML DOM element.
  96507. * The camera will stop reacting to that input.
  96508. * @param element Defines the element that listens to the input events.
  96509. */
  96510. detachControl(element: HTMLElement): void;
  96511. private _collisionMask;
  96512. /**
  96513. * Get the mask that the camera ignores in collision events.
  96514. */
  96515. /**
  96516. * Set the mask that the camera ignores in collision events.
  96517. */
  96518. collisionMask: number;
  96519. /** @hidden */
  96520. _collideWithWorld(displacement: Vector3): void;
  96521. /** @hidden */
  96522. private _onCollisionPositionChange;
  96523. /** @hidden */
  96524. _checkInputs(): void;
  96525. /** @hidden */
  96526. _decideIfNeedsToMove(): boolean;
  96527. /** @hidden */
  96528. _updatePosition(): void;
  96529. /**
  96530. * Restore the Roll to its target value at the rate specified.
  96531. * @param rate - Higher means slower restoring.
  96532. * @hidden
  96533. */
  96534. restoreRoll(rate: number): void;
  96535. /**
  96536. * Destroy the camera and release the current resources held by it.
  96537. */
  96538. dispose(): void;
  96539. /**
  96540. * Get the current object class name.
  96541. * @returns the class name.
  96542. */
  96543. getClassName(): string;
  96544. }
  96545. }
  96546. declare module BABYLON {
  96547. /**
  96548. * Listen to keyboard events to control the camera.
  96549. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96550. */
  96551. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  96552. /**
  96553. * Defines the camera the input is attached to.
  96554. */
  96555. camera: FlyCamera;
  96556. /**
  96557. * The list of keyboard keys used to control the forward move of the camera.
  96558. */
  96559. keysForward: number[];
  96560. /**
  96561. * The list of keyboard keys used to control the backward move of the camera.
  96562. */
  96563. keysBackward: number[];
  96564. /**
  96565. * The list of keyboard keys used to control the forward move of the camera.
  96566. */
  96567. keysUp: number[];
  96568. /**
  96569. * The list of keyboard keys used to control the backward move of the camera.
  96570. */
  96571. keysDown: number[];
  96572. /**
  96573. * The list of keyboard keys used to control the right strafe move of the camera.
  96574. */
  96575. keysRight: number[];
  96576. /**
  96577. * The list of keyboard keys used to control the left strafe move of the camera.
  96578. */
  96579. keysLeft: number[];
  96580. private _keys;
  96581. private _onCanvasBlurObserver;
  96582. private _onKeyboardObserver;
  96583. private _engine;
  96584. private _scene;
  96585. /**
  96586. * Attach the input controls to a specific dom element to get the input from.
  96587. * @param element Defines the element the controls should be listened from
  96588. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96589. */
  96590. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96591. /**
  96592. * Detach the current controls from the specified dom element.
  96593. * @param element Defines the element to stop listening the inputs from
  96594. */
  96595. detachControl(element: Nullable<HTMLElement>): void;
  96596. /**
  96597. * Gets the class name of the current intput.
  96598. * @returns the class name
  96599. */
  96600. getClassName(): string;
  96601. /** @hidden */
  96602. _onLostFocus(e: FocusEvent): void;
  96603. /**
  96604. * Get the friendly name associated with the input class.
  96605. * @returns the input friendly name
  96606. */
  96607. getSimpleName(): string;
  96608. /**
  96609. * Update the current camera state depending on the inputs that have been used this frame.
  96610. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  96611. */
  96612. checkInputs(): void;
  96613. }
  96614. }
  96615. declare module BABYLON {
  96616. /**
  96617. * Manage the mouse wheel inputs to control a follow camera.
  96618. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96619. */
  96620. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  96621. /**
  96622. * Defines the camera the input is attached to.
  96623. */
  96624. camera: FollowCamera;
  96625. /**
  96626. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  96627. */
  96628. axisControlRadius: boolean;
  96629. /**
  96630. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  96631. */
  96632. axisControlHeight: boolean;
  96633. /**
  96634. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  96635. */
  96636. axisControlRotation: boolean;
  96637. /**
  96638. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  96639. * relation to mouseWheel events.
  96640. */
  96641. wheelPrecision: number;
  96642. /**
  96643. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  96644. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  96645. */
  96646. wheelDeltaPercentage: number;
  96647. private _wheel;
  96648. private _observer;
  96649. /**
  96650. * Attach the input controls to a specific dom element to get the input from.
  96651. * @param element Defines the element the controls should be listened from
  96652. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96653. */
  96654. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96655. /**
  96656. * Detach the current controls from the specified dom element.
  96657. * @param element Defines the element to stop listening the inputs from
  96658. */
  96659. detachControl(element: Nullable<HTMLElement>): void;
  96660. /**
  96661. * Gets the class name of the current intput.
  96662. * @returns the class name
  96663. */
  96664. getClassName(): string;
  96665. /**
  96666. * Get the friendly name associated with the input class.
  96667. * @returns the input friendly name
  96668. */
  96669. getSimpleName(): string;
  96670. }
  96671. }
  96672. declare module BABYLON {
  96673. /**
  96674. * Manage the pointers inputs to control an follow camera.
  96675. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96676. */
  96677. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  96678. /**
  96679. * Defines the camera the input is attached to.
  96680. */
  96681. camera: FollowCamera;
  96682. /**
  96683. * Gets the class name of the current input.
  96684. * @returns the class name
  96685. */
  96686. getClassName(): string;
  96687. /**
  96688. * Defines the pointer angular sensibility along the X axis or how fast is
  96689. * the camera rotating.
  96690. * A negative number will reverse the axis direction.
  96691. */
  96692. angularSensibilityX: number;
  96693. /**
  96694. * Defines the pointer angular sensibility along the Y axis or how fast is
  96695. * the camera rotating.
  96696. * A negative number will reverse the axis direction.
  96697. */
  96698. angularSensibilityY: number;
  96699. /**
  96700. * Defines the pointer pinch precision or how fast is the camera zooming.
  96701. * A negative number will reverse the axis direction.
  96702. */
  96703. pinchPrecision: number;
  96704. /**
  96705. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  96706. * from 0.
  96707. * It defines the percentage of current camera.radius to use as delta when
  96708. * pinch zoom is used.
  96709. */
  96710. pinchDeltaPercentage: number;
  96711. /**
  96712. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  96713. */
  96714. axisXControlRadius: boolean;
  96715. /**
  96716. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  96717. */
  96718. axisXControlHeight: boolean;
  96719. /**
  96720. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  96721. */
  96722. axisXControlRotation: boolean;
  96723. /**
  96724. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  96725. */
  96726. axisYControlRadius: boolean;
  96727. /**
  96728. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  96729. */
  96730. axisYControlHeight: boolean;
  96731. /**
  96732. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  96733. */
  96734. axisYControlRotation: boolean;
  96735. /**
  96736. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  96737. */
  96738. axisPinchControlRadius: boolean;
  96739. /**
  96740. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  96741. */
  96742. axisPinchControlHeight: boolean;
  96743. /**
  96744. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  96745. */
  96746. axisPinchControlRotation: boolean;
  96747. /**
  96748. * Log error messages if basic misconfiguration has occurred.
  96749. */
  96750. warningEnable: boolean;
  96751. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  96752. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  96753. private _warningCounter;
  96754. private _warning;
  96755. }
  96756. }
  96757. declare module BABYLON {
  96758. /**
  96759. * Default Inputs manager for the FollowCamera.
  96760. * It groups all the default supported inputs for ease of use.
  96761. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96762. */
  96763. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  96764. /**
  96765. * Instantiates a new FollowCameraInputsManager.
  96766. * @param camera Defines the camera the inputs belong to
  96767. */
  96768. constructor(camera: FollowCamera);
  96769. /**
  96770. * Add keyboard input support to the input manager.
  96771. * @returns the current input manager
  96772. */
  96773. addKeyboard(): FollowCameraInputsManager;
  96774. /**
  96775. * Add mouse wheel input support to the input manager.
  96776. * @returns the current input manager
  96777. */
  96778. addMouseWheel(): FollowCameraInputsManager;
  96779. /**
  96780. * Add pointers input support to the input manager.
  96781. * @returns the current input manager
  96782. */
  96783. addPointers(): FollowCameraInputsManager;
  96784. /**
  96785. * Add orientation input support to the input manager.
  96786. * @returns the current input manager
  96787. */
  96788. addVRDeviceOrientation(): FollowCameraInputsManager;
  96789. }
  96790. }
  96791. declare module BABYLON {
  96792. /**
  96793. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  96794. * an arc rotate version arcFollowCamera are available.
  96795. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  96796. */
  96797. export class FollowCamera extends TargetCamera {
  96798. /**
  96799. * Distance the follow camera should follow an object at
  96800. */
  96801. radius: number;
  96802. /**
  96803. * Minimum allowed distance of the camera to the axis of rotation
  96804. * (The camera can not get closer).
  96805. * This can help limiting how the Camera is able to move in the scene.
  96806. */
  96807. lowerRadiusLimit: Nullable<number>;
  96808. /**
  96809. * Maximum allowed distance of the camera to the axis of rotation
  96810. * (The camera can not get further).
  96811. * This can help limiting how the Camera is able to move in the scene.
  96812. */
  96813. upperRadiusLimit: Nullable<number>;
  96814. /**
  96815. * Define a rotation offset between the camera and the object it follows
  96816. */
  96817. rotationOffset: number;
  96818. /**
  96819. * Minimum allowed angle to camera position relative to target object.
  96820. * This can help limiting how the Camera is able to move in the scene.
  96821. */
  96822. lowerRotationOffsetLimit: Nullable<number>;
  96823. /**
  96824. * Maximum allowed angle to camera position relative to target object.
  96825. * This can help limiting how the Camera is able to move in the scene.
  96826. */
  96827. upperRotationOffsetLimit: Nullable<number>;
  96828. /**
  96829. * Define a height offset between the camera and the object it follows.
  96830. * It can help following an object from the top (like a car chaing a plane)
  96831. */
  96832. heightOffset: number;
  96833. /**
  96834. * Minimum allowed height of camera position relative to target object.
  96835. * This can help limiting how the Camera is able to move in the scene.
  96836. */
  96837. lowerHeightOffsetLimit: Nullable<number>;
  96838. /**
  96839. * Maximum allowed height of camera position relative to target object.
  96840. * This can help limiting how the Camera is able to move in the scene.
  96841. */
  96842. upperHeightOffsetLimit: Nullable<number>;
  96843. /**
  96844. * Define how fast the camera can accelerate to follow it s target.
  96845. */
  96846. cameraAcceleration: number;
  96847. /**
  96848. * Define the speed limit of the camera following an object.
  96849. */
  96850. maxCameraSpeed: number;
  96851. /**
  96852. * Define the target of the camera.
  96853. */
  96854. lockedTarget: Nullable<AbstractMesh>;
  96855. /**
  96856. * Defines the input associated with the camera.
  96857. */
  96858. inputs: FollowCameraInputsManager;
  96859. /**
  96860. * Instantiates the follow camera.
  96861. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  96862. * @param name Define the name of the camera in the scene
  96863. * @param position Define the position of the camera
  96864. * @param scene Define the scene the camera belong to
  96865. * @param lockedTarget Define the target of the camera
  96866. */
  96867. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  96868. private _follow;
  96869. /**
  96870. * Attached controls to the current camera.
  96871. * @param element Defines the element the controls should be listened from
  96872. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96873. */
  96874. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96875. /**
  96876. * Detach the current controls from the camera.
  96877. * The camera will stop reacting to inputs.
  96878. * @param element Defines the element to stop listening the inputs from
  96879. */
  96880. detachControl(element: HTMLElement): void;
  96881. /** @hidden */
  96882. _checkInputs(): void;
  96883. private _checkLimits;
  96884. /**
  96885. * Gets the camera class name.
  96886. * @returns the class name
  96887. */
  96888. getClassName(): string;
  96889. }
  96890. /**
  96891. * Arc Rotate version of the follow camera.
  96892. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  96893. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  96894. */
  96895. export class ArcFollowCamera extends TargetCamera {
  96896. /** The longitudinal angle of the camera */
  96897. alpha: number;
  96898. /** The latitudinal angle of the camera */
  96899. beta: number;
  96900. /** The radius of the camera from its target */
  96901. radius: number;
  96902. /** Define the camera target (the messh it should follow) */
  96903. target: Nullable<AbstractMesh>;
  96904. private _cartesianCoordinates;
  96905. /**
  96906. * Instantiates a new ArcFollowCamera
  96907. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  96908. * @param name Define the name of the camera
  96909. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  96910. * @param beta Define the rotation angle of the camera around the elevation axis
  96911. * @param radius Define the radius of the camera from its target point
  96912. * @param target Define the target of the camera
  96913. * @param scene Define the scene the camera belongs to
  96914. */
  96915. constructor(name: string,
  96916. /** The longitudinal angle of the camera */
  96917. alpha: number,
  96918. /** The latitudinal angle of the camera */
  96919. beta: number,
  96920. /** The radius of the camera from its target */
  96921. radius: number,
  96922. /** Define the camera target (the messh it should follow) */
  96923. target: Nullable<AbstractMesh>, scene: Scene);
  96924. private _follow;
  96925. /** @hidden */
  96926. _checkInputs(): void;
  96927. /**
  96928. * Returns the class name of the object.
  96929. * It is mostly used internally for serialization purposes.
  96930. */
  96931. getClassName(): string;
  96932. }
  96933. }
  96934. declare module BABYLON {
  96935. /**
  96936. * Manage the keyboard inputs to control the movement of a follow camera.
  96937. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96938. */
  96939. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  96940. /**
  96941. * Defines the camera the input is attached to.
  96942. */
  96943. camera: FollowCamera;
  96944. /**
  96945. * Defines the list of key codes associated with the up action (increase heightOffset)
  96946. */
  96947. keysHeightOffsetIncr: number[];
  96948. /**
  96949. * Defines the list of key codes associated with the down action (decrease heightOffset)
  96950. */
  96951. keysHeightOffsetDecr: number[];
  96952. /**
  96953. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  96954. */
  96955. keysHeightOffsetModifierAlt: boolean;
  96956. /**
  96957. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  96958. */
  96959. keysHeightOffsetModifierCtrl: boolean;
  96960. /**
  96961. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  96962. */
  96963. keysHeightOffsetModifierShift: boolean;
  96964. /**
  96965. * Defines the list of key codes associated with the left action (increase rotationOffset)
  96966. */
  96967. keysRotationOffsetIncr: number[];
  96968. /**
  96969. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  96970. */
  96971. keysRotationOffsetDecr: number[];
  96972. /**
  96973. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  96974. */
  96975. keysRotationOffsetModifierAlt: boolean;
  96976. /**
  96977. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  96978. */
  96979. keysRotationOffsetModifierCtrl: boolean;
  96980. /**
  96981. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  96982. */
  96983. keysRotationOffsetModifierShift: boolean;
  96984. /**
  96985. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  96986. */
  96987. keysRadiusIncr: number[];
  96988. /**
  96989. * Defines the list of key codes associated with the zoom-out action (increase radius)
  96990. */
  96991. keysRadiusDecr: number[];
  96992. /**
  96993. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  96994. */
  96995. keysRadiusModifierAlt: boolean;
  96996. /**
  96997. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  96998. */
  96999. keysRadiusModifierCtrl: boolean;
  97000. /**
  97001. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  97002. */
  97003. keysRadiusModifierShift: boolean;
  97004. /**
  97005. * Defines the rate of change of heightOffset.
  97006. */
  97007. heightSensibility: number;
  97008. /**
  97009. * Defines the rate of change of rotationOffset.
  97010. */
  97011. rotationSensibility: number;
  97012. /**
  97013. * Defines the rate of change of radius.
  97014. */
  97015. radiusSensibility: number;
  97016. private _keys;
  97017. private _ctrlPressed;
  97018. private _altPressed;
  97019. private _shiftPressed;
  97020. private _onCanvasBlurObserver;
  97021. private _onKeyboardObserver;
  97022. private _engine;
  97023. private _scene;
  97024. /**
  97025. * Attach the input controls to a specific dom element to get the input from.
  97026. * @param element Defines the element the controls should be listened from
  97027. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  97028. */
  97029. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97030. /**
  97031. * Detach the current controls from the specified dom element.
  97032. * @param element Defines the element to stop listening the inputs from
  97033. */
  97034. detachControl(element: Nullable<HTMLElement>): void;
  97035. /**
  97036. * Update the current camera state depending on the inputs that have been used this frame.
  97037. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  97038. */
  97039. checkInputs(): void;
  97040. /**
  97041. * Gets the class name of the current input.
  97042. * @returns the class name
  97043. */
  97044. getClassName(): string;
  97045. /**
  97046. * Get the friendly name associated with the input class.
  97047. * @returns the input friendly name
  97048. */
  97049. getSimpleName(): string;
  97050. /**
  97051. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  97052. * allow modification of the heightOffset value.
  97053. */
  97054. private _modifierHeightOffset;
  97055. /**
  97056. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  97057. * allow modification of the rotationOffset value.
  97058. */
  97059. private _modifierRotationOffset;
  97060. /**
  97061. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  97062. * allow modification of the radius value.
  97063. */
  97064. private _modifierRadius;
  97065. }
  97066. }
  97067. declare module BABYLON {
  97068. interface FreeCameraInputsManager {
  97069. /**
  97070. * @hidden
  97071. */
  97072. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  97073. /**
  97074. * Add orientation input support to the input manager.
  97075. * @returns the current input manager
  97076. */
  97077. addDeviceOrientation(): FreeCameraInputsManager;
  97078. }
  97079. /**
  97080. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  97081. * Screen rotation is taken into account.
  97082. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  97083. */
  97084. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  97085. private _camera;
  97086. private _screenOrientationAngle;
  97087. private _constantTranform;
  97088. private _screenQuaternion;
  97089. private _alpha;
  97090. private _beta;
  97091. private _gamma;
  97092. /**
  97093. * @hidden
  97094. */
  97095. _onDeviceOrientationChangedObservable: Observable<void>;
  97096. /**
  97097. * Instantiates a new input
  97098. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  97099. */
  97100. constructor();
  97101. /**
  97102. * Define the camera controlled by the input.
  97103. */
  97104. camera: FreeCamera;
  97105. /**
  97106. * Attach the input controls to a specific dom element to get the input from.
  97107. * @param element Defines the element the controls should be listened from
  97108. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  97109. */
  97110. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97111. private _orientationChanged;
  97112. private _deviceOrientation;
  97113. /**
  97114. * Detach the current controls from the specified dom element.
  97115. * @param element Defines the element to stop listening the inputs from
  97116. */
  97117. detachControl(element: Nullable<HTMLElement>): void;
  97118. /**
  97119. * Update the current camera state depending on the inputs that have been used this frame.
  97120. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  97121. */
  97122. checkInputs(): void;
  97123. /**
  97124. * Gets the class name of the current intput.
  97125. * @returns the class name
  97126. */
  97127. getClassName(): string;
  97128. /**
  97129. * Get the friendly name associated with the input class.
  97130. * @returns the input friendly name
  97131. */
  97132. getSimpleName(): string;
  97133. }
  97134. }
  97135. declare module BABYLON {
  97136. /**
  97137. * Manage the gamepad inputs to control a free camera.
  97138. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  97139. */
  97140. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  97141. /**
  97142. * Define the camera the input is attached to.
  97143. */
  97144. camera: FreeCamera;
  97145. /**
  97146. * Define the Gamepad controlling the input
  97147. */
  97148. gamepad: Nullable<Gamepad>;
  97149. /**
  97150. * Defines the gamepad rotation sensiblity.
  97151. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  97152. */
  97153. gamepadAngularSensibility: number;
  97154. /**
  97155. * Defines the gamepad move sensiblity.
  97156. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  97157. */
  97158. gamepadMoveSensibility: number;
  97159. private _onGamepadConnectedObserver;
  97160. private _onGamepadDisconnectedObserver;
  97161. private _cameraTransform;
  97162. private _deltaTransform;
  97163. private _vector3;
  97164. private _vector2;
  97165. /**
  97166. * Attach the input controls to a specific dom element to get the input from.
  97167. * @param element Defines the element the controls should be listened from
  97168. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  97169. */
  97170. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97171. /**
  97172. * Detach the current controls from the specified dom element.
  97173. * @param element Defines the element to stop listening the inputs from
  97174. */
  97175. detachControl(element: Nullable<HTMLElement>): void;
  97176. /**
  97177. * Update the current camera state depending on the inputs that have been used this frame.
  97178. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  97179. */
  97180. checkInputs(): void;
  97181. /**
  97182. * Gets the class name of the current intput.
  97183. * @returns the class name
  97184. */
  97185. getClassName(): string;
  97186. /**
  97187. * Get the friendly name associated with the input class.
  97188. * @returns the input friendly name
  97189. */
  97190. getSimpleName(): string;
  97191. }
  97192. }
  97193. declare module BABYLON {
  97194. /**
  97195. * Defines the potential axis of a Joystick
  97196. */
  97197. export enum JoystickAxis {
  97198. /** X axis */
  97199. X = 0,
  97200. /** Y axis */
  97201. Y = 1,
  97202. /** Z axis */
  97203. Z = 2
  97204. }
  97205. /**
  97206. * Class used to define virtual joystick (used in touch mode)
  97207. */
  97208. export class VirtualJoystick {
  97209. /**
  97210. * Gets or sets a boolean indicating that left and right values must be inverted
  97211. */
  97212. reverseLeftRight: boolean;
  97213. /**
  97214. * Gets or sets a boolean indicating that up and down values must be inverted
  97215. */
  97216. reverseUpDown: boolean;
  97217. /**
  97218. * Gets the offset value for the position (ie. the change of the position value)
  97219. */
  97220. deltaPosition: Vector3;
  97221. /**
  97222. * Gets a boolean indicating if the virtual joystick was pressed
  97223. */
  97224. pressed: boolean;
  97225. /**
  97226. * Canvas the virtual joystick will render onto, default z-index of this is 5
  97227. */
  97228. static Canvas: Nullable<HTMLCanvasElement>;
  97229. private static _globalJoystickIndex;
  97230. private static vjCanvasContext;
  97231. private static vjCanvasWidth;
  97232. private static vjCanvasHeight;
  97233. private static halfWidth;
  97234. private _action;
  97235. private _axisTargetedByLeftAndRight;
  97236. private _axisTargetedByUpAndDown;
  97237. private _joystickSensibility;
  97238. private _inversedSensibility;
  97239. private _joystickPointerID;
  97240. private _joystickColor;
  97241. private _joystickPointerPos;
  97242. private _joystickPreviousPointerPos;
  97243. private _joystickPointerStartPos;
  97244. private _deltaJoystickVector;
  97245. private _leftJoystick;
  97246. private _touches;
  97247. private _onPointerDownHandlerRef;
  97248. private _onPointerMoveHandlerRef;
  97249. private _onPointerUpHandlerRef;
  97250. private _onResize;
  97251. /**
  97252. * Creates a new virtual joystick
  97253. * @param leftJoystick defines that the joystick is for left hand (false by default)
  97254. */
  97255. constructor(leftJoystick?: boolean);
  97256. /**
  97257. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  97258. * @param newJoystickSensibility defines the new sensibility
  97259. */
  97260. setJoystickSensibility(newJoystickSensibility: number): void;
  97261. private _onPointerDown;
  97262. private _onPointerMove;
  97263. private _onPointerUp;
  97264. /**
  97265. * Change the color of the virtual joystick
  97266. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  97267. */
  97268. setJoystickColor(newColor: string): void;
  97269. /**
  97270. * Defines a callback to call when the joystick is touched
  97271. * @param action defines the callback
  97272. */
  97273. setActionOnTouch(action: () => any): void;
  97274. /**
  97275. * Defines which axis you'd like to control for left & right
  97276. * @param axis defines the axis to use
  97277. */
  97278. setAxisForLeftRight(axis: JoystickAxis): void;
  97279. /**
  97280. * Defines which axis you'd like to control for up & down
  97281. * @param axis defines the axis to use
  97282. */
  97283. setAxisForUpDown(axis: JoystickAxis): void;
  97284. private _drawVirtualJoystick;
  97285. /**
  97286. * Release internal HTML canvas
  97287. */
  97288. releaseCanvas(): void;
  97289. }
  97290. }
  97291. declare module BABYLON {
  97292. interface FreeCameraInputsManager {
  97293. /**
  97294. * Add virtual joystick input support to the input manager.
  97295. * @returns the current input manager
  97296. */
  97297. addVirtualJoystick(): FreeCameraInputsManager;
  97298. }
  97299. /**
  97300. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  97301. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  97302. */
  97303. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  97304. /**
  97305. * Defines the camera the input is attached to.
  97306. */
  97307. camera: FreeCamera;
  97308. private _leftjoystick;
  97309. private _rightjoystick;
  97310. /**
  97311. * Gets the left stick of the virtual joystick.
  97312. * @returns The virtual Joystick
  97313. */
  97314. getLeftJoystick(): VirtualJoystick;
  97315. /**
  97316. * Gets the right stick of the virtual joystick.
  97317. * @returns The virtual Joystick
  97318. */
  97319. getRightJoystick(): VirtualJoystick;
  97320. /**
  97321. * Update the current camera state depending on the inputs that have been used this frame.
  97322. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  97323. */
  97324. checkInputs(): void;
  97325. /**
  97326. * Attach the input controls to a specific dom element to get the input from.
  97327. * @param element Defines the element the controls should be listened from
  97328. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  97329. */
  97330. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97331. /**
  97332. * Detach the current controls from the specified dom element.
  97333. * @param element Defines the element to stop listening the inputs from
  97334. */
  97335. detachControl(element: Nullable<HTMLElement>): void;
  97336. /**
  97337. * Gets the class name of the current intput.
  97338. * @returns the class name
  97339. */
  97340. getClassName(): string;
  97341. /**
  97342. * Get the friendly name associated with the input class.
  97343. * @returns the input friendly name
  97344. */
  97345. getSimpleName(): string;
  97346. }
  97347. }
  97348. declare module BABYLON {
  97349. /**
  97350. * This represents a FPS type of camera controlled by touch.
  97351. * This is like a universal camera minus the Gamepad controls.
  97352. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  97353. */
  97354. export class TouchCamera extends FreeCamera {
  97355. /**
  97356. * Defines the touch sensibility for rotation.
  97357. * The higher the faster.
  97358. */
  97359. touchAngularSensibility: number;
  97360. /**
  97361. * Defines the touch sensibility for move.
  97362. * The higher the faster.
  97363. */
  97364. touchMoveSensibility: number;
  97365. /**
  97366. * Instantiates a new touch camera.
  97367. * This represents a FPS type of camera controlled by touch.
  97368. * This is like a universal camera minus the Gamepad controls.
  97369. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  97370. * @param name Define the name of the camera in the scene
  97371. * @param position Define the start position of the camera in the scene
  97372. * @param scene Define the scene the camera belongs to
  97373. */
  97374. constructor(name: string, position: Vector3, scene: Scene);
  97375. /**
  97376. * Gets the current object class name.
  97377. * @return the class name
  97378. */
  97379. getClassName(): string;
  97380. /** @hidden */
  97381. _setupInputs(): void;
  97382. }
  97383. }
  97384. declare module BABYLON {
  97385. /**
  97386. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  97387. * being tilted forward or back and left or right.
  97388. */
  97389. export class DeviceOrientationCamera extends FreeCamera {
  97390. private _initialQuaternion;
  97391. private _quaternionCache;
  97392. private _tmpDragQuaternion;
  97393. /**
  97394. * Creates a new device orientation camera
  97395. * @param name The name of the camera
  97396. * @param position The start position camera
  97397. * @param scene The scene the camera belongs to
  97398. */
  97399. constructor(name: string, position: Vector3, scene: Scene);
  97400. /**
  97401. * @hidden
  97402. * Disabled pointer input on first orientation sensor update (Default: true)
  97403. */
  97404. _disablePointerInputWhenUsingDeviceOrientation: boolean;
  97405. private _dragFactor;
  97406. /**
  97407. * Enabled turning on the y axis when the orientation sensor is active
  97408. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  97409. */
  97410. enableHorizontalDragging(dragFactor?: number): void;
  97411. /**
  97412. * Gets the current instance class name ("DeviceOrientationCamera").
  97413. * This helps avoiding instanceof at run time.
  97414. * @returns the class name
  97415. */
  97416. getClassName(): string;
  97417. /**
  97418. * @hidden
  97419. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  97420. */
  97421. _checkInputs(): void;
  97422. /**
  97423. * Reset the camera to its default orientation on the specified axis only.
  97424. * @param axis The axis to reset
  97425. */
  97426. resetToCurrentRotation(axis?: Axis): void;
  97427. }
  97428. }
  97429. declare module BABYLON {
  97430. /**
  97431. * Defines supported buttons for XBox360 compatible gamepads
  97432. */
  97433. export enum Xbox360Button {
  97434. /** A */
  97435. A = 0,
  97436. /** B */
  97437. B = 1,
  97438. /** X */
  97439. X = 2,
  97440. /** Y */
  97441. Y = 3,
  97442. /** Start */
  97443. Start = 4,
  97444. /** Back */
  97445. Back = 5,
  97446. /** Left button */
  97447. LB = 6,
  97448. /** Right button */
  97449. RB = 7,
  97450. /** Left stick */
  97451. LeftStick = 8,
  97452. /** Right stick */
  97453. RightStick = 9
  97454. }
  97455. /** Defines values for XBox360 DPad */
  97456. export enum Xbox360Dpad {
  97457. /** Up */
  97458. Up = 0,
  97459. /** Down */
  97460. Down = 1,
  97461. /** Left */
  97462. Left = 2,
  97463. /** Right */
  97464. Right = 3
  97465. }
  97466. /**
  97467. * Defines a XBox360 gamepad
  97468. */
  97469. export class Xbox360Pad extends Gamepad {
  97470. private _leftTrigger;
  97471. private _rightTrigger;
  97472. private _onlefttriggerchanged;
  97473. private _onrighttriggerchanged;
  97474. private _onbuttondown;
  97475. private _onbuttonup;
  97476. private _ondpaddown;
  97477. private _ondpadup;
  97478. /** Observable raised when a button is pressed */
  97479. onButtonDownObservable: Observable<Xbox360Button>;
  97480. /** Observable raised when a button is released */
  97481. onButtonUpObservable: Observable<Xbox360Button>;
  97482. /** Observable raised when a pad is pressed */
  97483. onPadDownObservable: Observable<Xbox360Dpad>;
  97484. /** Observable raised when a pad is released */
  97485. onPadUpObservable: Observable<Xbox360Dpad>;
  97486. private _buttonA;
  97487. private _buttonB;
  97488. private _buttonX;
  97489. private _buttonY;
  97490. private _buttonBack;
  97491. private _buttonStart;
  97492. private _buttonLB;
  97493. private _buttonRB;
  97494. private _buttonLeftStick;
  97495. private _buttonRightStick;
  97496. private _dPadUp;
  97497. private _dPadDown;
  97498. private _dPadLeft;
  97499. private _dPadRight;
  97500. private _isXboxOnePad;
  97501. /**
  97502. * Creates a new XBox360 gamepad object
  97503. * @param id defines the id of this gamepad
  97504. * @param index defines its index
  97505. * @param gamepad defines the internal HTML gamepad object
  97506. * @param xboxOne defines if it is a XBox One gamepad
  97507. */
  97508. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  97509. /**
  97510. * Defines the callback to call when left trigger is pressed
  97511. * @param callback defines the callback to use
  97512. */
  97513. onlefttriggerchanged(callback: (value: number) => void): void;
  97514. /**
  97515. * Defines the callback to call when right trigger is pressed
  97516. * @param callback defines the callback to use
  97517. */
  97518. onrighttriggerchanged(callback: (value: number) => void): void;
  97519. /**
  97520. * Gets the left trigger value
  97521. */
  97522. /**
  97523. * Sets the left trigger value
  97524. */
  97525. leftTrigger: number;
  97526. /**
  97527. * Gets the right trigger value
  97528. */
  97529. /**
  97530. * Sets the right trigger value
  97531. */
  97532. rightTrigger: number;
  97533. /**
  97534. * Defines the callback to call when a button is pressed
  97535. * @param callback defines the callback to use
  97536. */
  97537. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  97538. /**
  97539. * Defines the callback to call when a button is released
  97540. * @param callback defines the callback to use
  97541. */
  97542. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  97543. /**
  97544. * Defines the callback to call when a pad is pressed
  97545. * @param callback defines the callback to use
  97546. */
  97547. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  97548. /**
  97549. * Defines the callback to call when a pad is released
  97550. * @param callback defines the callback to use
  97551. */
  97552. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  97553. private _setButtonValue;
  97554. private _setDPadValue;
  97555. /**
  97556. * Gets the value of the `A` button
  97557. */
  97558. /**
  97559. * Sets the value of the `A` button
  97560. */
  97561. buttonA: number;
  97562. /**
  97563. * Gets the value of the `B` button
  97564. */
  97565. /**
  97566. * Sets the value of the `B` button
  97567. */
  97568. buttonB: number;
  97569. /**
  97570. * Gets the value of the `X` button
  97571. */
  97572. /**
  97573. * Sets the value of the `X` button
  97574. */
  97575. buttonX: number;
  97576. /**
  97577. * Gets the value of the `Y` button
  97578. */
  97579. /**
  97580. * Sets the value of the `Y` button
  97581. */
  97582. buttonY: number;
  97583. /**
  97584. * Gets the value of the `Start` button
  97585. */
  97586. /**
  97587. * Sets the value of the `Start` button
  97588. */
  97589. buttonStart: number;
  97590. /**
  97591. * Gets the value of the `Back` button
  97592. */
  97593. /**
  97594. * Sets the value of the `Back` button
  97595. */
  97596. buttonBack: number;
  97597. /**
  97598. * Gets the value of the `Left` button
  97599. */
  97600. /**
  97601. * Sets the value of the `Left` button
  97602. */
  97603. buttonLB: number;
  97604. /**
  97605. * Gets the value of the `Right` button
  97606. */
  97607. /**
  97608. * Sets the value of the `Right` button
  97609. */
  97610. buttonRB: number;
  97611. /**
  97612. * Gets the value of the Left joystick
  97613. */
  97614. /**
  97615. * Sets the value of the Left joystick
  97616. */
  97617. buttonLeftStick: number;
  97618. /**
  97619. * Gets the value of the Right joystick
  97620. */
  97621. /**
  97622. * Sets the value of the Right joystick
  97623. */
  97624. buttonRightStick: number;
  97625. /**
  97626. * Gets the value of D-pad up
  97627. */
  97628. /**
  97629. * Sets the value of D-pad up
  97630. */
  97631. dPadUp: number;
  97632. /**
  97633. * Gets the value of D-pad down
  97634. */
  97635. /**
  97636. * Sets the value of D-pad down
  97637. */
  97638. dPadDown: number;
  97639. /**
  97640. * Gets the value of D-pad left
  97641. */
  97642. /**
  97643. * Sets the value of D-pad left
  97644. */
  97645. dPadLeft: number;
  97646. /**
  97647. * Gets the value of D-pad right
  97648. */
  97649. /**
  97650. * Sets the value of D-pad right
  97651. */
  97652. dPadRight: number;
  97653. /**
  97654. * Force the gamepad to synchronize with device values
  97655. */
  97656. update(): void;
  97657. /**
  97658. * Disposes the gamepad
  97659. */
  97660. dispose(): void;
  97661. }
  97662. }
  97663. declare module BABYLON {
  97664. /**
  97665. * Manager for handling gamepads
  97666. */
  97667. export class GamepadManager {
  97668. private _scene?;
  97669. private _babylonGamepads;
  97670. private _oneGamepadConnected;
  97671. /** @hidden */
  97672. _isMonitoring: boolean;
  97673. private _gamepadEventSupported;
  97674. private _gamepadSupport;
  97675. /**
  97676. * observable to be triggered when the gamepad controller has been connected
  97677. */
  97678. onGamepadConnectedObservable: Observable<Gamepad>;
  97679. /**
  97680. * observable to be triggered when the gamepad controller has been disconnected
  97681. */
  97682. onGamepadDisconnectedObservable: Observable<Gamepad>;
  97683. private _onGamepadConnectedEvent;
  97684. private _onGamepadDisconnectedEvent;
  97685. /**
  97686. * Initializes the gamepad manager
  97687. * @param _scene BabylonJS scene
  97688. */
  97689. constructor(_scene?: Scene | undefined);
  97690. /**
  97691. * The gamepads in the game pad manager
  97692. */
  97693. readonly gamepads: Gamepad[];
  97694. /**
  97695. * Get the gamepad controllers based on type
  97696. * @param type The type of gamepad controller
  97697. * @returns Nullable gamepad
  97698. */
  97699. getGamepadByType(type?: number): Nullable<Gamepad>;
  97700. /**
  97701. * Disposes the gamepad manager
  97702. */
  97703. dispose(): void;
  97704. private _addNewGamepad;
  97705. private _startMonitoringGamepads;
  97706. private _stopMonitoringGamepads;
  97707. /** @hidden */
  97708. _checkGamepadsStatus(): void;
  97709. private _updateGamepadObjects;
  97710. }
  97711. }
  97712. declare module BABYLON {
  97713. interface Scene {
  97714. /** @hidden */
  97715. _gamepadManager: Nullable<GamepadManager>;
  97716. /**
  97717. * Gets the gamepad manager associated with the scene
  97718. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  97719. */
  97720. gamepadManager: GamepadManager;
  97721. }
  97722. /**
  97723. * Interface representing a free camera inputs manager
  97724. */
  97725. interface FreeCameraInputsManager {
  97726. /**
  97727. * Adds gamepad input support to the FreeCameraInputsManager.
  97728. * @returns the FreeCameraInputsManager
  97729. */
  97730. addGamepad(): FreeCameraInputsManager;
  97731. }
  97732. /**
  97733. * Interface representing an arc rotate camera inputs manager
  97734. */
  97735. interface ArcRotateCameraInputsManager {
  97736. /**
  97737. * Adds gamepad input support to the ArcRotateCamera InputManager.
  97738. * @returns the camera inputs manager
  97739. */
  97740. addGamepad(): ArcRotateCameraInputsManager;
  97741. }
  97742. /**
  97743. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  97744. */
  97745. export class GamepadSystemSceneComponent implements ISceneComponent {
  97746. /**
  97747. * The component name helpfull to identify the component in the list of scene components.
  97748. */
  97749. readonly name: string;
  97750. /**
  97751. * The scene the component belongs to.
  97752. */
  97753. scene: Scene;
  97754. /**
  97755. * Creates a new instance of the component for the given scene
  97756. * @param scene Defines the scene to register the component in
  97757. */
  97758. constructor(scene: Scene);
  97759. /**
  97760. * Registers the component in a given scene
  97761. */
  97762. register(): void;
  97763. /**
  97764. * Rebuilds the elements related to this component in case of
  97765. * context lost for instance.
  97766. */
  97767. rebuild(): void;
  97768. /**
  97769. * Disposes the component and the associated ressources
  97770. */
  97771. dispose(): void;
  97772. private _beforeCameraUpdate;
  97773. }
  97774. }
  97775. declare module BABYLON {
  97776. /**
  97777. * 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,
  97778. * which still works and will still be found in many Playgrounds.
  97779. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  97780. */
  97781. export class UniversalCamera extends TouchCamera {
  97782. /**
  97783. * Defines the gamepad rotation sensiblity.
  97784. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  97785. */
  97786. gamepadAngularSensibility: number;
  97787. /**
  97788. * Defines the gamepad move sensiblity.
  97789. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  97790. */
  97791. gamepadMoveSensibility: number;
  97792. /**
  97793. * 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,
  97794. * which still works and will still be found in many Playgrounds.
  97795. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  97796. * @param name Define the name of the camera in the scene
  97797. * @param position Define the start position of the camera in the scene
  97798. * @param scene Define the scene the camera belongs to
  97799. */
  97800. constructor(name: string, position: Vector3, scene: Scene);
  97801. /**
  97802. * Gets the current object class name.
  97803. * @return the class name
  97804. */
  97805. getClassName(): string;
  97806. }
  97807. }
  97808. declare module BABYLON {
  97809. /**
  97810. * This represents a FPS type of camera. This is only here for back compat purpose.
  97811. * Please use the UniversalCamera instead as both are identical.
  97812. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  97813. */
  97814. export class GamepadCamera extends UniversalCamera {
  97815. /**
  97816. * Instantiates a new Gamepad Camera
  97817. * This represents a FPS type of camera. This is only here for back compat purpose.
  97818. * Please use the UniversalCamera instead as both are identical.
  97819. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  97820. * @param name Define the name of the camera in the scene
  97821. * @param position Define the start position of the camera in the scene
  97822. * @param scene Define the scene the camera belongs to
  97823. */
  97824. constructor(name: string, position: Vector3, scene: Scene);
  97825. /**
  97826. * Gets the current object class name.
  97827. * @return the class name
  97828. */
  97829. getClassName(): string;
  97830. }
  97831. }
  97832. declare module BABYLON {
  97833. /** @hidden */
  97834. export var passPixelShader: {
  97835. name: string;
  97836. shader: string;
  97837. };
  97838. }
  97839. declare module BABYLON {
  97840. /** @hidden */
  97841. export var passCubePixelShader: {
  97842. name: string;
  97843. shader: string;
  97844. };
  97845. }
  97846. declare module BABYLON {
  97847. /**
  97848. * PassPostProcess which produces an output the same as it's input
  97849. */
  97850. export class PassPostProcess extends PostProcess {
  97851. /**
  97852. * Creates the PassPostProcess
  97853. * @param name The name of the effect.
  97854. * @param options The required width/height ratio to downsize to before computing the render pass.
  97855. * @param camera The camera to apply the render pass to.
  97856. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  97857. * @param engine The engine which the post process will be applied. (default: current engine)
  97858. * @param reusable If the post process can be reused on the same frame. (default: false)
  97859. * @param textureType The type of texture to be used when performing the post processing.
  97860. * @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)
  97861. */
  97862. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  97863. }
  97864. /**
  97865. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  97866. */
  97867. export class PassCubePostProcess extends PostProcess {
  97868. private _face;
  97869. /**
  97870. * Gets or sets the cube face to display.
  97871. * * 0 is +X
  97872. * * 1 is -X
  97873. * * 2 is +Y
  97874. * * 3 is -Y
  97875. * * 4 is +Z
  97876. * * 5 is -Z
  97877. */
  97878. face: number;
  97879. /**
  97880. * Creates the PassCubePostProcess
  97881. * @param name The name of the effect.
  97882. * @param options The required width/height ratio to downsize to before computing the render pass.
  97883. * @param camera The camera to apply the render pass to.
  97884. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  97885. * @param engine The engine which the post process will be applied. (default: current engine)
  97886. * @param reusable If the post process can be reused on the same frame. (default: false)
  97887. * @param textureType The type of texture to be used when performing the post processing.
  97888. * @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)
  97889. */
  97890. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  97891. }
  97892. }
  97893. declare module BABYLON {
  97894. /** @hidden */
  97895. export var anaglyphPixelShader: {
  97896. name: string;
  97897. shader: string;
  97898. };
  97899. }
  97900. declare module BABYLON {
  97901. /**
  97902. * Postprocess used to generate anaglyphic rendering
  97903. */
  97904. export class AnaglyphPostProcess extends PostProcess {
  97905. private _passedProcess;
  97906. /**
  97907. * Creates a new AnaglyphPostProcess
  97908. * @param name defines postprocess name
  97909. * @param options defines creation options or target ratio scale
  97910. * @param rigCameras defines cameras using this postprocess
  97911. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  97912. * @param engine defines hosting engine
  97913. * @param reusable defines if the postprocess will be reused multiple times per frame
  97914. */
  97915. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  97916. }
  97917. }
  97918. declare module BABYLON {
  97919. /**
  97920. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  97921. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  97922. */
  97923. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  97924. /**
  97925. * Creates a new AnaglyphArcRotateCamera
  97926. * @param name defines camera name
  97927. * @param alpha defines alpha angle (in radians)
  97928. * @param beta defines beta angle (in radians)
  97929. * @param radius defines radius
  97930. * @param target defines camera target
  97931. * @param interaxialDistance defines distance between each color axis
  97932. * @param scene defines the hosting scene
  97933. */
  97934. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  97935. /**
  97936. * Gets camera class name
  97937. * @returns AnaglyphArcRotateCamera
  97938. */
  97939. getClassName(): string;
  97940. }
  97941. }
  97942. declare module BABYLON {
  97943. /**
  97944. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  97945. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  97946. */
  97947. export class AnaglyphFreeCamera extends FreeCamera {
  97948. /**
  97949. * Creates a new AnaglyphFreeCamera
  97950. * @param name defines camera name
  97951. * @param position defines initial position
  97952. * @param interaxialDistance defines distance between each color axis
  97953. * @param scene defines the hosting scene
  97954. */
  97955. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  97956. /**
  97957. * Gets camera class name
  97958. * @returns AnaglyphFreeCamera
  97959. */
  97960. getClassName(): string;
  97961. }
  97962. }
  97963. declare module BABYLON {
  97964. /**
  97965. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  97966. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  97967. */
  97968. export class AnaglyphGamepadCamera extends GamepadCamera {
  97969. /**
  97970. * Creates a new AnaglyphGamepadCamera
  97971. * @param name defines camera name
  97972. * @param position defines initial position
  97973. * @param interaxialDistance defines distance between each color axis
  97974. * @param scene defines the hosting scene
  97975. */
  97976. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  97977. /**
  97978. * Gets camera class name
  97979. * @returns AnaglyphGamepadCamera
  97980. */
  97981. getClassName(): string;
  97982. }
  97983. }
  97984. declare module BABYLON {
  97985. /**
  97986. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  97987. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  97988. */
  97989. export class AnaglyphUniversalCamera extends UniversalCamera {
  97990. /**
  97991. * Creates a new AnaglyphUniversalCamera
  97992. * @param name defines camera name
  97993. * @param position defines initial position
  97994. * @param interaxialDistance defines distance between each color axis
  97995. * @param scene defines the hosting scene
  97996. */
  97997. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  97998. /**
  97999. * Gets camera class name
  98000. * @returns AnaglyphUniversalCamera
  98001. */
  98002. getClassName(): string;
  98003. }
  98004. }
  98005. declare module BABYLON {
  98006. /** @hidden */
  98007. export var stereoscopicInterlacePixelShader: {
  98008. name: string;
  98009. shader: string;
  98010. };
  98011. }
  98012. declare module BABYLON {
  98013. /**
  98014. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  98015. */
  98016. export class StereoscopicInterlacePostProcess extends PostProcess {
  98017. private _stepSize;
  98018. private _passedProcess;
  98019. /**
  98020. * Initializes a StereoscopicInterlacePostProcess
  98021. * @param name The name of the effect.
  98022. * @param rigCameras The rig cameras to be appled to the post process
  98023. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  98024. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  98025. * @param engine The engine which the post process will be applied. (default: current engine)
  98026. * @param reusable If the post process can be reused on the same frame. (default: false)
  98027. */
  98028. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  98029. }
  98030. }
  98031. declare module BABYLON {
  98032. /**
  98033. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  98034. * @see http://doc.babylonjs.com/features/cameras
  98035. */
  98036. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  98037. /**
  98038. * Creates a new StereoscopicArcRotateCamera
  98039. * @param name defines camera name
  98040. * @param alpha defines alpha angle (in radians)
  98041. * @param beta defines beta angle (in radians)
  98042. * @param radius defines radius
  98043. * @param target defines camera target
  98044. * @param interaxialDistance defines distance between each color axis
  98045. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  98046. * @param scene defines the hosting scene
  98047. */
  98048. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  98049. /**
  98050. * Gets camera class name
  98051. * @returns StereoscopicArcRotateCamera
  98052. */
  98053. getClassName(): string;
  98054. }
  98055. }
  98056. declare module BABYLON {
  98057. /**
  98058. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  98059. * @see http://doc.babylonjs.com/features/cameras
  98060. */
  98061. export class StereoscopicFreeCamera extends FreeCamera {
  98062. /**
  98063. * Creates a new StereoscopicFreeCamera
  98064. * @param name defines camera name
  98065. * @param position defines initial position
  98066. * @param interaxialDistance defines distance between each color axis
  98067. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  98068. * @param scene defines the hosting scene
  98069. */
  98070. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  98071. /**
  98072. * Gets camera class name
  98073. * @returns StereoscopicFreeCamera
  98074. */
  98075. getClassName(): string;
  98076. }
  98077. }
  98078. declare module BABYLON {
  98079. /**
  98080. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  98081. * @see http://doc.babylonjs.com/features/cameras
  98082. */
  98083. export class StereoscopicGamepadCamera extends GamepadCamera {
  98084. /**
  98085. * Creates a new StereoscopicGamepadCamera
  98086. * @param name defines camera name
  98087. * @param position defines initial position
  98088. * @param interaxialDistance defines distance between each color axis
  98089. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  98090. * @param scene defines the hosting scene
  98091. */
  98092. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  98093. /**
  98094. * Gets camera class name
  98095. * @returns StereoscopicGamepadCamera
  98096. */
  98097. getClassName(): string;
  98098. }
  98099. }
  98100. declare module BABYLON {
  98101. /**
  98102. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  98103. * @see http://doc.babylonjs.com/features/cameras
  98104. */
  98105. export class StereoscopicUniversalCamera extends UniversalCamera {
  98106. /**
  98107. * Creates a new StereoscopicUniversalCamera
  98108. * @param name defines camera name
  98109. * @param position defines initial position
  98110. * @param interaxialDistance defines distance between each color axis
  98111. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  98112. * @param scene defines the hosting scene
  98113. */
  98114. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  98115. /**
  98116. * Gets camera class name
  98117. * @returns StereoscopicUniversalCamera
  98118. */
  98119. getClassName(): string;
  98120. }
  98121. }
  98122. declare module BABYLON {
  98123. /**
  98124. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  98125. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  98126. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  98127. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  98128. */
  98129. export class VirtualJoysticksCamera extends FreeCamera {
  98130. /**
  98131. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  98132. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  98133. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  98134. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  98135. * @param name Define the name of the camera in the scene
  98136. * @param position Define the start position of the camera in the scene
  98137. * @param scene Define the scene the camera belongs to
  98138. */
  98139. constructor(name: string, position: Vector3, scene: Scene);
  98140. /**
  98141. * Gets the current object class name.
  98142. * @return the class name
  98143. */
  98144. getClassName(): string;
  98145. }
  98146. }
  98147. declare module BABYLON {
  98148. /**
  98149. * This represents all the required metrics to create a VR camera.
  98150. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  98151. */
  98152. export class VRCameraMetrics {
  98153. /**
  98154. * Define the horizontal resolution off the screen.
  98155. */
  98156. hResolution: number;
  98157. /**
  98158. * Define the vertical resolution off the screen.
  98159. */
  98160. vResolution: number;
  98161. /**
  98162. * Define the horizontal screen size.
  98163. */
  98164. hScreenSize: number;
  98165. /**
  98166. * Define the vertical screen size.
  98167. */
  98168. vScreenSize: number;
  98169. /**
  98170. * Define the vertical screen center position.
  98171. */
  98172. vScreenCenter: number;
  98173. /**
  98174. * Define the distance of the eyes to the screen.
  98175. */
  98176. eyeToScreenDistance: number;
  98177. /**
  98178. * Define the distance between both lenses
  98179. */
  98180. lensSeparationDistance: number;
  98181. /**
  98182. * Define the distance between both viewer's eyes.
  98183. */
  98184. interpupillaryDistance: number;
  98185. /**
  98186. * Define the distortion factor of the VR postprocess.
  98187. * Please, touch with care.
  98188. */
  98189. distortionK: number[];
  98190. /**
  98191. * Define the chromatic aberration correction factors for the VR post process.
  98192. */
  98193. chromaAbCorrection: number[];
  98194. /**
  98195. * Define the scale factor of the post process.
  98196. * The smaller the better but the slower.
  98197. */
  98198. postProcessScaleFactor: number;
  98199. /**
  98200. * Define an offset for the lens center.
  98201. */
  98202. lensCenterOffset: number;
  98203. /**
  98204. * Define if the current vr camera should compensate the distortion of the lense or not.
  98205. */
  98206. compensateDistortion: boolean;
  98207. /**
  98208. * Defines if multiview should be enabled when rendering (Default: false)
  98209. */
  98210. multiviewEnabled: boolean;
  98211. /**
  98212. * Gets the rendering aspect ratio based on the provided resolutions.
  98213. */
  98214. readonly aspectRatio: number;
  98215. /**
  98216. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  98217. */
  98218. readonly aspectRatioFov: number;
  98219. /**
  98220. * @hidden
  98221. */
  98222. readonly leftHMatrix: Matrix;
  98223. /**
  98224. * @hidden
  98225. */
  98226. readonly rightHMatrix: Matrix;
  98227. /**
  98228. * @hidden
  98229. */
  98230. readonly leftPreViewMatrix: Matrix;
  98231. /**
  98232. * @hidden
  98233. */
  98234. readonly rightPreViewMatrix: Matrix;
  98235. /**
  98236. * Get the default VRMetrics based on the most generic setup.
  98237. * @returns the default vr metrics
  98238. */
  98239. static GetDefault(): VRCameraMetrics;
  98240. }
  98241. }
  98242. declare module BABYLON {
  98243. /** @hidden */
  98244. export var vrDistortionCorrectionPixelShader: {
  98245. name: string;
  98246. shader: string;
  98247. };
  98248. }
  98249. declare module BABYLON {
  98250. /**
  98251. * VRDistortionCorrectionPostProcess used for mobile VR
  98252. */
  98253. export class VRDistortionCorrectionPostProcess extends PostProcess {
  98254. private _isRightEye;
  98255. private _distortionFactors;
  98256. private _postProcessScaleFactor;
  98257. private _lensCenterOffset;
  98258. private _scaleIn;
  98259. private _scaleFactor;
  98260. private _lensCenter;
  98261. /**
  98262. * Initializes the VRDistortionCorrectionPostProcess
  98263. * @param name The name of the effect.
  98264. * @param camera The camera to apply the render pass to.
  98265. * @param isRightEye If this is for the right eye distortion
  98266. * @param vrMetrics All the required metrics for the VR camera
  98267. */
  98268. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  98269. }
  98270. }
  98271. declare module BABYLON {
  98272. /**
  98273. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  98274. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  98275. */
  98276. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  98277. /**
  98278. * Creates a new VRDeviceOrientationArcRotateCamera
  98279. * @param name defines camera name
  98280. * @param alpha defines the camera rotation along the logitudinal axis
  98281. * @param beta defines the camera rotation along the latitudinal axis
  98282. * @param radius defines the camera distance from its target
  98283. * @param target defines the camera target
  98284. * @param scene defines the scene the camera belongs to
  98285. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  98286. * @param vrCameraMetrics defines the vr metrics associated to the camera
  98287. */
  98288. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  98289. /**
  98290. * Gets camera class name
  98291. * @returns VRDeviceOrientationArcRotateCamera
  98292. */
  98293. getClassName(): string;
  98294. }
  98295. }
  98296. declare module BABYLON {
  98297. /**
  98298. * Camera used to simulate VR rendering (based on FreeCamera)
  98299. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  98300. */
  98301. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  98302. /**
  98303. * Creates a new VRDeviceOrientationFreeCamera
  98304. * @param name defines camera name
  98305. * @param position defines the start position of the camera
  98306. * @param scene defines the scene the camera belongs to
  98307. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  98308. * @param vrCameraMetrics defines the vr metrics associated to the camera
  98309. */
  98310. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  98311. /**
  98312. * Gets camera class name
  98313. * @returns VRDeviceOrientationFreeCamera
  98314. */
  98315. getClassName(): string;
  98316. }
  98317. }
  98318. declare module BABYLON {
  98319. /**
  98320. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  98321. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  98322. */
  98323. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  98324. /**
  98325. * Creates a new VRDeviceOrientationGamepadCamera
  98326. * @param name defines camera name
  98327. * @param position defines the start position of the camera
  98328. * @param scene defines the scene the camera belongs to
  98329. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  98330. * @param vrCameraMetrics defines the vr metrics associated to the camera
  98331. */
  98332. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  98333. /**
  98334. * Gets camera class name
  98335. * @returns VRDeviceOrientationGamepadCamera
  98336. */
  98337. getClassName(): string;
  98338. }
  98339. }
  98340. declare module BABYLON {
  98341. /**
  98342. * Base class of materials working in push mode in babylon JS
  98343. * @hidden
  98344. */
  98345. export class PushMaterial extends Material {
  98346. protected _activeEffect: Effect;
  98347. protected _normalMatrix: Matrix;
  98348. /**
  98349. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  98350. * This means that the material can keep using a previous shader while a new one is being compiled.
  98351. * This is mostly used when shader parallel compilation is supported (true by default)
  98352. */
  98353. allowShaderHotSwapping: boolean;
  98354. constructor(name: string, scene: Scene);
  98355. getEffect(): Effect;
  98356. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  98357. /**
  98358. * Binds the given world matrix to the active effect
  98359. *
  98360. * @param world the matrix to bind
  98361. */
  98362. bindOnlyWorldMatrix(world: Matrix): void;
  98363. /**
  98364. * Binds the given normal matrix to the active effect
  98365. *
  98366. * @param normalMatrix the matrix to bind
  98367. */
  98368. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  98369. bind(world: Matrix, mesh?: Mesh): void;
  98370. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  98371. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  98372. }
  98373. }
  98374. declare module BABYLON {
  98375. /**
  98376. * This groups all the flags used to control the materials channel.
  98377. */
  98378. export class MaterialFlags {
  98379. private static _DiffuseTextureEnabled;
  98380. /**
  98381. * Are diffuse textures enabled in the application.
  98382. */
  98383. static DiffuseTextureEnabled: boolean;
  98384. private static _AmbientTextureEnabled;
  98385. /**
  98386. * Are ambient textures enabled in the application.
  98387. */
  98388. static AmbientTextureEnabled: boolean;
  98389. private static _OpacityTextureEnabled;
  98390. /**
  98391. * Are opacity textures enabled in the application.
  98392. */
  98393. static OpacityTextureEnabled: boolean;
  98394. private static _ReflectionTextureEnabled;
  98395. /**
  98396. * Are reflection textures enabled in the application.
  98397. */
  98398. static ReflectionTextureEnabled: boolean;
  98399. private static _EmissiveTextureEnabled;
  98400. /**
  98401. * Are emissive textures enabled in the application.
  98402. */
  98403. static EmissiveTextureEnabled: boolean;
  98404. private static _SpecularTextureEnabled;
  98405. /**
  98406. * Are specular textures enabled in the application.
  98407. */
  98408. static SpecularTextureEnabled: boolean;
  98409. private static _BumpTextureEnabled;
  98410. /**
  98411. * Are bump textures enabled in the application.
  98412. */
  98413. static BumpTextureEnabled: boolean;
  98414. private static _LightmapTextureEnabled;
  98415. /**
  98416. * Are lightmap textures enabled in the application.
  98417. */
  98418. static LightmapTextureEnabled: boolean;
  98419. private static _RefractionTextureEnabled;
  98420. /**
  98421. * Are refraction textures enabled in the application.
  98422. */
  98423. static RefractionTextureEnabled: boolean;
  98424. private static _ColorGradingTextureEnabled;
  98425. /**
  98426. * Are color grading textures enabled in the application.
  98427. */
  98428. static ColorGradingTextureEnabled: boolean;
  98429. private static _FresnelEnabled;
  98430. /**
  98431. * Are fresnels enabled in the application.
  98432. */
  98433. static FresnelEnabled: boolean;
  98434. private static _ClearCoatTextureEnabled;
  98435. /**
  98436. * Are clear coat textures enabled in the application.
  98437. */
  98438. static ClearCoatTextureEnabled: boolean;
  98439. private static _ClearCoatBumpTextureEnabled;
  98440. /**
  98441. * Are clear coat bump textures enabled in the application.
  98442. */
  98443. static ClearCoatBumpTextureEnabled: boolean;
  98444. private static _ClearCoatTintTextureEnabled;
  98445. /**
  98446. * Are clear coat tint textures enabled in the application.
  98447. */
  98448. static ClearCoatTintTextureEnabled: boolean;
  98449. private static _SheenTextureEnabled;
  98450. /**
  98451. * Are sheen textures enabled in the application.
  98452. */
  98453. static SheenTextureEnabled: boolean;
  98454. private static _AnisotropicTextureEnabled;
  98455. /**
  98456. * Are anisotropic textures enabled in the application.
  98457. */
  98458. static AnisotropicTextureEnabled: boolean;
  98459. private static _ThicknessTextureEnabled;
  98460. /**
  98461. * Are thickness textures enabled in the application.
  98462. */
  98463. static ThicknessTextureEnabled: boolean;
  98464. }
  98465. }
  98466. declare module BABYLON {
  98467. /** @hidden */
  98468. export var defaultFragmentDeclaration: {
  98469. name: string;
  98470. shader: string;
  98471. };
  98472. }
  98473. declare module BABYLON {
  98474. /** @hidden */
  98475. export var defaultUboDeclaration: {
  98476. name: string;
  98477. shader: string;
  98478. };
  98479. }
  98480. declare module BABYLON {
  98481. /** @hidden */
  98482. export var lightFragmentDeclaration: {
  98483. name: string;
  98484. shader: string;
  98485. };
  98486. }
  98487. declare module BABYLON {
  98488. /** @hidden */
  98489. export var lightUboDeclaration: {
  98490. name: string;
  98491. shader: string;
  98492. };
  98493. }
  98494. declare module BABYLON {
  98495. /** @hidden */
  98496. export var lightsFragmentFunctions: {
  98497. name: string;
  98498. shader: string;
  98499. };
  98500. }
  98501. declare module BABYLON {
  98502. /** @hidden */
  98503. export var shadowsFragmentFunctions: {
  98504. name: string;
  98505. shader: string;
  98506. };
  98507. }
  98508. declare module BABYLON {
  98509. /** @hidden */
  98510. export var fresnelFunction: {
  98511. name: string;
  98512. shader: string;
  98513. };
  98514. }
  98515. declare module BABYLON {
  98516. /** @hidden */
  98517. export var reflectionFunction: {
  98518. name: string;
  98519. shader: string;
  98520. };
  98521. }
  98522. declare module BABYLON {
  98523. /** @hidden */
  98524. export var bumpFragmentFunctions: {
  98525. name: string;
  98526. shader: string;
  98527. };
  98528. }
  98529. declare module BABYLON {
  98530. /** @hidden */
  98531. export var logDepthDeclaration: {
  98532. name: string;
  98533. shader: string;
  98534. };
  98535. }
  98536. declare module BABYLON {
  98537. /** @hidden */
  98538. export var bumpFragment: {
  98539. name: string;
  98540. shader: string;
  98541. };
  98542. }
  98543. declare module BABYLON {
  98544. /** @hidden */
  98545. export var depthPrePass: {
  98546. name: string;
  98547. shader: string;
  98548. };
  98549. }
  98550. declare module BABYLON {
  98551. /** @hidden */
  98552. export var lightFragment: {
  98553. name: string;
  98554. shader: string;
  98555. };
  98556. }
  98557. declare module BABYLON {
  98558. /** @hidden */
  98559. export var logDepthFragment: {
  98560. name: string;
  98561. shader: string;
  98562. };
  98563. }
  98564. declare module BABYLON {
  98565. /** @hidden */
  98566. export var defaultPixelShader: {
  98567. name: string;
  98568. shader: string;
  98569. };
  98570. }
  98571. declare module BABYLON {
  98572. /** @hidden */
  98573. export var defaultVertexDeclaration: {
  98574. name: string;
  98575. shader: string;
  98576. };
  98577. }
  98578. declare module BABYLON {
  98579. /** @hidden */
  98580. export var bumpVertexDeclaration: {
  98581. name: string;
  98582. shader: string;
  98583. };
  98584. }
  98585. declare module BABYLON {
  98586. /** @hidden */
  98587. export var bumpVertex: {
  98588. name: string;
  98589. shader: string;
  98590. };
  98591. }
  98592. declare module BABYLON {
  98593. /** @hidden */
  98594. export var fogVertex: {
  98595. name: string;
  98596. shader: string;
  98597. };
  98598. }
  98599. declare module BABYLON {
  98600. /** @hidden */
  98601. export var shadowsVertex: {
  98602. name: string;
  98603. shader: string;
  98604. };
  98605. }
  98606. declare module BABYLON {
  98607. /** @hidden */
  98608. export var pointCloudVertex: {
  98609. name: string;
  98610. shader: string;
  98611. };
  98612. }
  98613. declare module BABYLON {
  98614. /** @hidden */
  98615. export var logDepthVertex: {
  98616. name: string;
  98617. shader: string;
  98618. };
  98619. }
  98620. declare module BABYLON {
  98621. /** @hidden */
  98622. export var defaultVertexShader: {
  98623. name: string;
  98624. shader: string;
  98625. };
  98626. }
  98627. declare module BABYLON {
  98628. /** @hidden */
  98629. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  98630. MAINUV1: boolean;
  98631. MAINUV2: boolean;
  98632. DIFFUSE: boolean;
  98633. DIFFUSEDIRECTUV: number;
  98634. AMBIENT: boolean;
  98635. AMBIENTDIRECTUV: number;
  98636. OPACITY: boolean;
  98637. OPACITYDIRECTUV: number;
  98638. OPACITYRGB: boolean;
  98639. REFLECTION: boolean;
  98640. EMISSIVE: boolean;
  98641. EMISSIVEDIRECTUV: number;
  98642. SPECULAR: boolean;
  98643. SPECULARDIRECTUV: number;
  98644. BUMP: boolean;
  98645. BUMPDIRECTUV: number;
  98646. PARALLAX: boolean;
  98647. PARALLAXOCCLUSION: boolean;
  98648. SPECULAROVERALPHA: boolean;
  98649. CLIPPLANE: boolean;
  98650. CLIPPLANE2: boolean;
  98651. CLIPPLANE3: boolean;
  98652. CLIPPLANE4: boolean;
  98653. ALPHATEST: boolean;
  98654. DEPTHPREPASS: boolean;
  98655. ALPHAFROMDIFFUSE: boolean;
  98656. POINTSIZE: boolean;
  98657. FOG: boolean;
  98658. SPECULARTERM: boolean;
  98659. DIFFUSEFRESNEL: boolean;
  98660. OPACITYFRESNEL: boolean;
  98661. REFLECTIONFRESNEL: boolean;
  98662. REFRACTIONFRESNEL: boolean;
  98663. EMISSIVEFRESNEL: boolean;
  98664. FRESNEL: boolean;
  98665. NORMAL: boolean;
  98666. UV1: boolean;
  98667. UV2: boolean;
  98668. VERTEXCOLOR: boolean;
  98669. VERTEXALPHA: boolean;
  98670. NUM_BONE_INFLUENCERS: number;
  98671. BonesPerMesh: number;
  98672. BONETEXTURE: boolean;
  98673. INSTANCES: boolean;
  98674. GLOSSINESS: boolean;
  98675. ROUGHNESS: boolean;
  98676. EMISSIVEASILLUMINATION: boolean;
  98677. LINKEMISSIVEWITHDIFFUSE: boolean;
  98678. REFLECTIONFRESNELFROMSPECULAR: boolean;
  98679. LIGHTMAP: boolean;
  98680. LIGHTMAPDIRECTUV: number;
  98681. OBJECTSPACE_NORMALMAP: boolean;
  98682. USELIGHTMAPASSHADOWMAP: boolean;
  98683. REFLECTIONMAP_3D: boolean;
  98684. REFLECTIONMAP_SPHERICAL: boolean;
  98685. REFLECTIONMAP_PLANAR: boolean;
  98686. REFLECTIONMAP_CUBIC: boolean;
  98687. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  98688. REFLECTIONMAP_PROJECTION: boolean;
  98689. REFLECTIONMAP_SKYBOX: boolean;
  98690. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  98691. REFLECTIONMAP_EXPLICIT: boolean;
  98692. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  98693. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  98694. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  98695. INVERTCUBICMAP: boolean;
  98696. LOGARITHMICDEPTH: boolean;
  98697. REFRACTION: boolean;
  98698. REFRACTIONMAP_3D: boolean;
  98699. REFLECTIONOVERALPHA: boolean;
  98700. TWOSIDEDLIGHTING: boolean;
  98701. SHADOWFLOAT: boolean;
  98702. MORPHTARGETS: boolean;
  98703. MORPHTARGETS_NORMAL: boolean;
  98704. MORPHTARGETS_TANGENT: boolean;
  98705. NUM_MORPH_INFLUENCERS: number;
  98706. NONUNIFORMSCALING: boolean;
  98707. PREMULTIPLYALPHA: boolean;
  98708. IMAGEPROCESSING: boolean;
  98709. VIGNETTE: boolean;
  98710. VIGNETTEBLENDMODEMULTIPLY: boolean;
  98711. VIGNETTEBLENDMODEOPAQUE: boolean;
  98712. TONEMAPPING: boolean;
  98713. TONEMAPPING_ACES: boolean;
  98714. CONTRAST: boolean;
  98715. COLORCURVES: boolean;
  98716. COLORGRADING: boolean;
  98717. COLORGRADING3D: boolean;
  98718. SAMPLER3DGREENDEPTH: boolean;
  98719. SAMPLER3DBGRMAP: boolean;
  98720. IMAGEPROCESSINGPOSTPROCESS: boolean;
  98721. MULTIVIEW: boolean;
  98722. /**
  98723. * If the reflection texture on this material is in linear color space
  98724. * @hidden
  98725. */
  98726. IS_REFLECTION_LINEAR: boolean;
  98727. /**
  98728. * If the refraction texture on this material is in linear color space
  98729. * @hidden
  98730. */
  98731. IS_REFRACTION_LINEAR: boolean;
  98732. EXPOSURE: boolean;
  98733. constructor();
  98734. setReflectionMode(modeToEnable: string): void;
  98735. }
  98736. /**
  98737. * This is the default material used in Babylon. It is the best trade off between quality
  98738. * and performances.
  98739. * @see http://doc.babylonjs.com/babylon101/materials
  98740. */
  98741. export class StandardMaterial extends PushMaterial {
  98742. private _diffuseTexture;
  98743. /**
  98744. * The basic texture of the material as viewed under a light.
  98745. */
  98746. diffuseTexture: Nullable<BaseTexture>;
  98747. private _ambientTexture;
  98748. /**
  98749. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  98750. */
  98751. ambientTexture: Nullable<BaseTexture>;
  98752. private _opacityTexture;
  98753. /**
  98754. * Define the transparency of the material from a texture.
  98755. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  98756. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  98757. */
  98758. opacityTexture: Nullable<BaseTexture>;
  98759. private _reflectionTexture;
  98760. /**
  98761. * Define the texture used to display the reflection.
  98762. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  98763. */
  98764. reflectionTexture: Nullable<BaseTexture>;
  98765. private _emissiveTexture;
  98766. /**
  98767. * Define texture of the material as if self lit.
  98768. * This will be mixed in the final result even in the absence of light.
  98769. */
  98770. emissiveTexture: Nullable<BaseTexture>;
  98771. private _specularTexture;
  98772. /**
  98773. * Define how the color and intensity of the highlight given by the light in the material.
  98774. */
  98775. specularTexture: Nullable<BaseTexture>;
  98776. private _bumpTexture;
  98777. /**
  98778. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  98779. * 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.
  98780. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  98781. */
  98782. bumpTexture: Nullable<BaseTexture>;
  98783. private _lightmapTexture;
  98784. /**
  98785. * Complex lighting can be computationally expensive to compute at runtime.
  98786. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  98787. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  98788. */
  98789. lightmapTexture: Nullable<BaseTexture>;
  98790. private _refractionTexture;
  98791. /**
  98792. * Define the texture used to display the refraction.
  98793. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  98794. */
  98795. refractionTexture: Nullable<BaseTexture>;
  98796. /**
  98797. * The color of the material lit by the environmental background lighting.
  98798. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  98799. */
  98800. ambientColor: Color3;
  98801. /**
  98802. * The basic color of the material as viewed under a light.
  98803. */
  98804. diffuseColor: Color3;
  98805. /**
  98806. * Define how the color and intensity of the highlight given by the light in the material.
  98807. */
  98808. specularColor: Color3;
  98809. /**
  98810. * Define the color of the material as if self lit.
  98811. * This will be mixed in the final result even in the absence of light.
  98812. */
  98813. emissiveColor: Color3;
  98814. /**
  98815. * Defines how sharp are the highlights in the material.
  98816. * The bigger the value the sharper giving a more glossy feeling to the result.
  98817. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  98818. */
  98819. specularPower: number;
  98820. private _useAlphaFromDiffuseTexture;
  98821. /**
  98822. * Does the transparency come from the diffuse texture alpha channel.
  98823. */
  98824. useAlphaFromDiffuseTexture: boolean;
  98825. private _useEmissiveAsIllumination;
  98826. /**
  98827. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  98828. */
  98829. useEmissiveAsIllumination: boolean;
  98830. private _linkEmissiveWithDiffuse;
  98831. /**
  98832. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  98833. * the emissive level when the final color is close to one.
  98834. */
  98835. linkEmissiveWithDiffuse: boolean;
  98836. private _useSpecularOverAlpha;
  98837. /**
  98838. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  98839. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  98840. */
  98841. useSpecularOverAlpha: boolean;
  98842. private _useReflectionOverAlpha;
  98843. /**
  98844. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  98845. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  98846. */
  98847. useReflectionOverAlpha: boolean;
  98848. private _disableLighting;
  98849. /**
  98850. * Does lights from the scene impacts this material.
  98851. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  98852. */
  98853. disableLighting: boolean;
  98854. private _useObjectSpaceNormalMap;
  98855. /**
  98856. * Allows using an object space normal map (instead of tangent space).
  98857. */
  98858. useObjectSpaceNormalMap: boolean;
  98859. private _useParallax;
  98860. /**
  98861. * Is parallax enabled or not.
  98862. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  98863. */
  98864. useParallax: boolean;
  98865. private _useParallaxOcclusion;
  98866. /**
  98867. * Is parallax occlusion enabled or not.
  98868. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  98869. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  98870. */
  98871. useParallaxOcclusion: boolean;
  98872. /**
  98873. * 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.
  98874. */
  98875. parallaxScaleBias: number;
  98876. private _roughness;
  98877. /**
  98878. * Helps to define how blurry the reflections should appears in the material.
  98879. */
  98880. roughness: number;
  98881. /**
  98882. * In case of refraction, define the value of the indice of refraction.
  98883. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  98884. */
  98885. indexOfRefraction: number;
  98886. /**
  98887. * Invert the refraction texture alongside the y axis.
  98888. * It can be useful with procedural textures or probe for instance.
  98889. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  98890. */
  98891. invertRefractionY: boolean;
  98892. /**
  98893. * Defines the alpha limits in alpha test mode.
  98894. */
  98895. alphaCutOff: number;
  98896. private _useLightmapAsShadowmap;
  98897. /**
  98898. * In case of light mapping, define whether the map contains light or shadow informations.
  98899. */
  98900. useLightmapAsShadowmap: boolean;
  98901. private _diffuseFresnelParameters;
  98902. /**
  98903. * Define the diffuse fresnel parameters of the material.
  98904. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98905. */
  98906. diffuseFresnelParameters: FresnelParameters;
  98907. private _opacityFresnelParameters;
  98908. /**
  98909. * Define the opacity fresnel parameters of the material.
  98910. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98911. */
  98912. opacityFresnelParameters: FresnelParameters;
  98913. private _reflectionFresnelParameters;
  98914. /**
  98915. * Define the reflection fresnel parameters of the material.
  98916. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98917. */
  98918. reflectionFresnelParameters: FresnelParameters;
  98919. private _refractionFresnelParameters;
  98920. /**
  98921. * Define the refraction fresnel parameters of the material.
  98922. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98923. */
  98924. refractionFresnelParameters: FresnelParameters;
  98925. private _emissiveFresnelParameters;
  98926. /**
  98927. * Define the emissive fresnel parameters of the material.
  98928. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98929. */
  98930. emissiveFresnelParameters: FresnelParameters;
  98931. private _useReflectionFresnelFromSpecular;
  98932. /**
  98933. * If true automatically deducts the fresnels values from the material specularity.
  98934. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98935. */
  98936. useReflectionFresnelFromSpecular: boolean;
  98937. private _useGlossinessFromSpecularMapAlpha;
  98938. /**
  98939. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  98940. */
  98941. useGlossinessFromSpecularMapAlpha: boolean;
  98942. private _maxSimultaneousLights;
  98943. /**
  98944. * Defines the maximum number of lights that can be used in the material
  98945. */
  98946. maxSimultaneousLights: number;
  98947. private _invertNormalMapX;
  98948. /**
  98949. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  98950. */
  98951. invertNormalMapX: boolean;
  98952. private _invertNormalMapY;
  98953. /**
  98954. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  98955. */
  98956. invertNormalMapY: boolean;
  98957. private _twoSidedLighting;
  98958. /**
  98959. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  98960. */
  98961. twoSidedLighting: boolean;
  98962. /**
  98963. * Default configuration related to image processing available in the standard Material.
  98964. */
  98965. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  98966. /**
  98967. * Gets the image processing configuration used either in this material.
  98968. */
  98969. /**
  98970. * Sets the Default image processing configuration used either in the this material.
  98971. *
  98972. * If sets to null, the scene one is in use.
  98973. */
  98974. imageProcessingConfiguration: ImageProcessingConfiguration;
  98975. /**
  98976. * Keep track of the image processing observer to allow dispose and replace.
  98977. */
  98978. private _imageProcessingObserver;
  98979. /**
  98980. * Attaches a new image processing configuration to the Standard Material.
  98981. * @param configuration
  98982. */
  98983. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  98984. /**
  98985. * Gets wether the color curves effect is enabled.
  98986. */
  98987. /**
  98988. * Sets wether the color curves effect is enabled.
  98989. */
  98990. cameraColorCurvesEnabled: boolean;
  98991. /**
  98992. * Gets wether the color grading effect is enabled.
  98993. */
  98994. /**
  98995. * Gets wether the color grading effect is enabled.
  98996. */
  98997. cameraColorGradingEnabled: boolean;
  98998. /**
  98999. * Gets wether tonemapping is enabled or not.
  99000. */
  99001. /**
  99002. * Sets wether tonemapping is enabled or not
  99003. */
  99004. cameraToneMappingEnabled: boolean;
  99005. /**
  99006. * The camera exposure used on this material.
  99007. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  99008. * This corresponds to a photographic exposure.
  99009. */
  99010. /**
  99011. * The camera exposure used on this material.
  99012. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  99013. * This corresponds to a photographic exposure.
  99014. */
  99015. cameraExposure: number;
  99016. /**
  99017. * Gets The camera contrast used on this material.
  99018. */
  99019. /**
  99020. * Sets The camera contrast used on this material.
  99021. */
  99022. cameraContrast: number;
  99023. /**
  99024. * Gets the Color Grading 2D Lookup Texture.
  99025. */
  99026. /**
  99027. * Sets the Color Grading 2D Lookup Texture.
  99028. */
  99029. cameraColorGradingTexture: Nullable<BaseTexture>;
  99030. /**
  99031. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  99032. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  99033. * 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;
  99034. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  99035. */
  99036. /**
  99037. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  99038. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  99039. * 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;
  99040. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  99041. */
  99042. cameraColorCurves: Nullable<ColorCurves>;
  99043. /**
  99044. * Custom callback helping to override the default shader used in the material.
  99045. */
  99046. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  99047. protected _renderTargets: SmartArray<RenderTargetTexture>;
  99048. protected _worldViewProjectionMatrix: Matrix;
  99049. protected _globalAmbientColor: Color3;
  99050. protected _useLogarithmicDepth: boolean;
  99051. /**
  99052. * Instantiates a new standard material.
  99053. * This is the default material used in Babylon. It is the best trade off between quality
  99054. * and performances.
  99055. * @see http://doc.babylonjs.com/babylon101/materials
  99056. * @param name Define the name of the material in the scene
  99057. * @param scene Define the scene the material belong to
  99058. */
  99059. constructor(name: string, scene: Scene);
  99060. /**
  99061. * Gets a boolean indicating that current material needs to register RTT
  99062. */
  99063. readonly hasRenderTargetTextures: boolean;
  99064. /**
  99065. * Gets the current class name of the material e.g. "StandardMaterial"
  99066. * Mainly use in serialization.
  99067. * @returns the class name
  99068. */
  99069. getClassName(): string;
  99070. /**
  99071. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  99072. * You can try switching to logarithmic depth.
  99073. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  99074. */
  99075. useLogarithmicDepth: boolean;
  99076. /**
  99077. * Specifies if the material will require alpha blending
  99078. * @returns a boolean specifying if alpha blending is needed
  99079. */
  99080. needAlphaBlending(): boolean;
  99081. /**
  99082. * Specifies if this material should be rendered in alpha test mode
  99083. * @returns a boolean specifying if an alpha test is needed.
  99084. */
  99085. needAlphaTesting(): boolean;
  99086. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  99087. /**
  99088. * Get the texture used for alpha test purpose.
  99089. * @returns the diffuse texture in case of the standard material.
  99090. */
  99091. getAlphaTestTexture(): Nullable<BaseTexture>;
  99092. /**
  99093. * Get if the submesh is ready to be used and all its information available.
  99094. * Child classes can use it to update shaders
  99095. * @param mesh defines the mesh to check
  99096. * @param subMesh defines which submesh to check
  99097. * @param useInstances specifies that instances should be used
  99098. * @returns a boolean indicating that the submesh is ready or not
  99099. */
  99100. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  99101. /**
  99102. * Builds the material UBO layouts.
  99103. * Used internally during the effect preparation.
  99104. */
  99105. buildUniformLayout(): void;
  99106. /**
  99107. * Unbinds the material from the mesh
  99108. */
  99109. unbind(): void;
  99110. /**
  99111. * Binds the submesh to this material by preparing the effect and shader to draw
  99112. * @param world defines the world transformation matrix
  99113. * @param mesh defines the mesh containing the submesh
  99114. * @param subMesh defines the submesh to bind the material to
  99115. */
  99116. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  99117. /**
  99118. * Get the list of animatables in the material.
  99119. * @returns the list of animatables object used in the material
  99120. */
  99121. getAnimatables(): IAnimatable[];
  99122. /**
  99123. * Gets the active textures from the material
  99124. * @returns an array of textures
  99125. */
  99126. getActiveTextures(): BaseTexture[];
  99127. /**
  99128. * Specifies if the material uses a texture
  99129. * @param texture defines the texture to check against the material
  99130. * @returns a boolean specifying if the material uses the texture
  99131. */
  99132. hasTexture(texture: BaseTexture): boolean;
  99133. /**
  99134. * Disposes the material
  99135. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  99136. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  99137. */
  99138. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  99139. /**
  99140. * Makes a duplicate of the material, and gives it a new name
  99141. * @param name defines the new name for the duplicated material
  99142. * @returns the cloned material
  99143. */
  99144. clone(name: string): StandardMaterial;
  99145. /**
  99146. * Serializes this material in a JSON representation
  99147. * @returns the serialized material object
  99148. */
  99149. serialize(): any;
  99150. /**
  99151. * Creates a standard material from parsed material data
  99152. * @param source defines the JSON representation of the material
  99153. * @param scene defines the hosting scene
  99154. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  99155. * @returns a new standard material
  99156. */
  99157. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  99158. /**
  99159. * Are diffuse textures enabled in the application.
  99160. */
  99161. static DiffuseTextureEnabled: boolean;
  99162. /**
  99163. * Are ambient textures enabled in the application.
  99164. */
  99165. static AmbientTextureEnabled: boolean;
  99166. /**
  99167. * Are opacity textures enabled in the application.
  99168. */
  99169. static OpacityTextureEnabled: boolean;
  99170. /**
  99171. * Are reflection textures enabled in the application.
  99172. */
  99173. static ReflectionTextureEnabled: boolean;
  99174. /**
  99175. * Are emissive textures enabled in the application.
  99176. */
  99177. static EmissiveTextureEnabled: boolean;
  99178. /**
  99179. * Are specular textures enabled in the application.
  99180. */
  99181. static SpecularTextureEnabled: boolean;
  99182. /**
  99183. * Are bump textures enabled in the application.
  99184. */
  99185. static BumpTextureEnabled: boolean;
  99186. /**
  99187. * Are lightmap textures enabled in the application.
  99188. */
  99189. static LightmapTextureEnabled: boolean;
  99190. /**
  99191. * Are refraction textures enabled in the application.
  99192. */
  99193. static RefractionTextureEnabled: boolean;
  99194. /**
  99195. * Are color grading textures enabled in the application.
  99196. */
  99197. static ColorGradingTextureEnabled: boolean;
  99198. /**
  99199. * Are fresnels enabled in the application.
  99200. */
  99201. static FresnelEnabled: boolean;
  99202. }
  99203. }
  99204. declare module BABYLON {
  99205. /**
  99206. * A class extending Texture allowing drawing on a texture
  99207. * @see http://doc.babylonjs.com/how_to/dynamictexture
  99208. */
  99209. export class DynamicTexture extends Texture {
  99210. private _generateMipMaps;
  99211. private _canvas;
  99212. private _context;
  99213. private _engine;
  99214. /**
  99215. * Creates a DynamicTexture
  99216. * @param name defines the name of the texture
  99217. * @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
  99218. * @param scene defines the scene where you want the texture
  99219. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  99220. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  99221. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  99222. */
  99223. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  99224. /**
  99225. * Get the current class name of the texture useful for serialization or dynamic coding.
  99226. * @returns "DynamicTexture"
  99227. */
  99228. getClassName(): string;
  99229. /**
  99230. * Gets the current state of canRescale
  99231. */
  99232. readonly canRescale: boolean;
  99233. private _recreate;
  99234. /**
  99235. * Scales the texture
  99236. * @param ratio the scale factor to apply to both width and height
  99237. */
  99238. scale(ratio: number): void;
  99239. /**
  99240. * Resizes the texture
  99241. * @param width the new width
  99242. * @param height the new height
  99243. */
  99244. scaleTo(width: number, height: number): void;
  99245. /**
  99246. * Gets the context of the canvas used by the texture
  99247. * @returns the canvas context of the dynamic texture
  99248. */
  99249. getContext(): CanvasRenderingContext2D;
  99250. /**
  99251. * Clears the texture
  99252. */
  99253. clear(): void;
  99254. /**
  99255. * Updates the texture
  99256. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  99257. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  99258. */
  99259. update(invertY?: boolean, premulAlpha?: boolean): void;
  99260. /**
  99261. * Draws text onto the texture
  99262. * @param text defines the text to be drawn
  99263. * @param x defines the placement of the text from the left
  99264. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  99265. * @param font defines the font to be used with font-style, font-size, font-name
  99266. * @param color defines the color used for the text
  99267. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  99268. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  99269. * @param update defines whether texture is immediately update (default is true)
  99270. */
  99271. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  99272. /**
  99273. * Clones the texture
  99274. * @returns the clone of the texture.
  99275. */
  99276. clone(): DynamicTexture;
  99277. /**
  99278. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  99279. * @returns a serialized dynamic texture object
  99280. */
  99281. serialize(): any;
  99282. /** @hidden */
  99283. _rebuild(): void;
  99284. }
  99285. }
  99286. declare module BABYLON {
  99287. /** @hidden */
  99288. export var imageProcessingPixelShader: {
  99289. name: string;
  99290. shader: string;
  99291. };
  99292. }
  99293. declare module BABYLON {
  99294. /**
  99295. * ImageProcessingPostProcess
  99296. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  99297. */
  99298. export class ImageProcessingPostProcess extends PostProcess {
  99299. /**
  99300. * Default configuration related to image processing available in the PBR Material.
  99301. */
  99302. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  99303. /**
  99304. * Gets the image processing configuration used either in this material.
  99305. */
  99306. /**
  99307. * Sets the Default image processing configuration used either in the this material.
  99308. *
  99309. * If sets to null, the scene one is in use.
  99310. */
  99311. imageProcessingConfiguration: ImageProcessingConfiguration;
  99312. /**
  99313. * Keep track of the image processing observer to allow dispose and replace.
  99314. */
  99315. private _imageProcessingObserver;
  99316. /**
  99317. * Attaches a new image processing configuration to the PBR Material.
  99318. * @param configuration
  99319. */
  99320. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  99321. /**
  99322. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  99323. */
  99324. /**
  99325. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  99326. */
  99327. colorCurves: Nullable<ColorCurves>;
  99328. /**
  99329. * Gets wether the color curves effect is enabled.
  99330. */
  99331. /**
  99332. * Sets wether the color curves effect is enabled.
  99333. */
  99334. colorCurvesEnabled: boolean;
  99335. /**
  99336. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  99337. */
  99338. /**
  99339. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  99340. */
  99341. colorGradingTexture: Nullable<BaseTexture>;
  99342. /**
  99343. * Gets wether the color grading effect is enabled.
  99344. */
  99345. /**
  99346. * Gets wether the color grading effect is enabled.
  99347. */
  99348. colorGradingEnabled: boolean;
  99349. /**
  99350. * Gets exposure used in the effect.
  99351. */
  99352. /**
  99353. * Sets exposure used in the effect.
  99354. */
  99355. exposure: number;
  99356. /**
  99357. * Gets wether tonemapping is enabled or not.
  99358. */
  99359. /**
  99360. * Sets wether tonemapping is enabled or not
  99361. */
  99362. toneMappingEnabled: boolean;
  99363. /**
  99364. * Gets the type of tone mapping effect.
  99365. */
  99366. /**
  99367. * Sets the type of tone mapping effect.
  99368. */
  99369. toneMappingType: number;
  99370. /**
  99371. * Gets contrast used in the effect.
  99372. */
  99373. /**
  99374. * Sets contrast used in the effect.
  99375. */
  99376. contrast: number;
  99377. /**
  99378. * Gets Vignette stretch size.
  99379. */
  99380. /**
  99381. * Sets Vignette stretch size.
  99382. */
  99383. vignetteStretch: number;
  99384. /**
  99385. * Gets Vignette centre X Offset.
  99386. */
  99387. /**
  99388. * Sets Vignette centre X Offset.
  99389. */
  99390. vignetteCentreX: number;
  99391. /**
  99392. * Gets Vignette centre Y Offset.
  99393. */
  99394. /**
  99395. * Sets Vignette centre Y Offset.
  99396. */
  99397. vignetteCentreY: number;
  99398. /**
  99399. * Gets Vignette weight or intensity of the vignette effect.
  99400. */
  99401. /**
  99402. * Sets Vignette weight or intensity of the vignette effect.
  99403. */
  99404. vignetteWeight: number;
  99405. /**
  99406. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  99407. * if vignetteEnabled is set to true.
  99408. */
  99409. /**
  99410. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  99411. * if vignetteEnabled is set to true.
  99412. */
  99413. vignetteColor: Color4;
  99414. /**
  99415. * Gets Camera field of view used by the Vignette effect.
  99416. */
  99417. /**
  99418. * Sets Camera field of view used by the Vignette effect.
  99419. */
  99420. vignetteCameraFov: number;
  99421. /**
  99422. * Gets the vignette blend mode allowing different kind of effect.
  99423. */
  99424. /**
  99425. * Sets the vignette blend mode allowing different kind of effect.
  99426. */
  99427. vignetteBlendMode: number;
  99428. /**
  99429. * Gets wether the vignette effect is enabled.
  99430. */
  99431. /**
  99432. * Sets wether the vignette effect is enabled.
  99433. */
  99434. vignetteEnabled: boolean;
  99435. private _fromLinearSpace;
  99436. /**
  99437. * Gets wether the input of the processing is in Gamma or Linear Space.
  99438. */
  99439. /**
  99440. * Sets wether the input of the processing is in Gamma or Linear Space.
  99441. */
  99442. fromLinearSpace: boolean;
  99443. /**
  99444. * Defines cache preventing GC.
  99445. */
  99446. private _defines;
  99447. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  99448. /**
  99449. * "ImageProcessingPostProcess"
  99450. * @returns "ImageProcessingPostProcess"
  99451. */
  99452. getClassName(): string;
  99453. protected _updateParameters(): void;
  99454. dispose(camera?: Camera): void;
  99455. }
  99456. }
  99457. declare module BABYLON {
  99458. /**
  99459. * Class containing static functions to help procedurally build meshes
  99460. */
  99461. export class GroundBuilder {
  99462. /**
  99463. * Creates a ground mesh
  99464. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  99465. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  99466. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  99467. * @param name defines the name of the mesh
  99468. * @param options defines the options used to create the mesh
  99469. * @param scene defines the hosting scene
  99470. * @returns the ground mesh
  99471. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  99472. */
  99473. static CreateGround(name: string, options: {
  99474. width?: number;
  99475. height?: number;
  99476. subdivisions?: number;
  99477. subdivisionsX?: number;
  99478. subdivisionsY?: number;
  99479. updatable?: boolean;
  99480. }, scene: any): Mesh;
  99481. /**
  99482. * Creates a tiled ground mesh
  99483. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  99484. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  99485. * * 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
  99486. * * 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
  99487. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  99488. * @param name defines the name of the mesh
  99489. * @param options defines the options used to create the mesh
  99490. * @param scene defines the hosting scene
  99491. * @returns the tiled ground mesh
  99492. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  99493. */
  99494. static CreateTiledGround(name: string, options: {
  99495. xmin: number;
  99496. zmin: number;
  99497. xmax: number;
  99498. zmax: number;
  99499. subdivisions?: {
  99500. w: number;
  99501. h: number;
  99502. };
  99503. precision?: {
  99504. w: number;
  99505. h: number;
  99506. };
  99507. updatable?: boolean;
  99508. }, scene?: Nullable<Scene>): Mesh;
  99509. /**
  99510. * Creates a ground mesh from a height map
  99511. * * The parameter `url` sets the URL of the height map image resource.
  99512. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  99513. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  99514. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  99515. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  99516. * * 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.
  99517. * * 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).
  99518. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  99519. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  99520. * @param name defines the name of the mesh
  99521. * @param url defines the url to the height map
  99522. * @param options defines the options used to create the mesh
  99523. * @param scene defines the hosting scene
  99524. * @returns the ground mesh
  99525. * @see https://doc.babylonjs.com/babylon101/height_map
  99526. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  99527. */
  99528. static CreateGroundFromHeightMap(name: string, url: string, options: {
  99529. width?: number;
  99530. height?: number;
  99531. subdivisions?: number;
  99532. minHeight?: number;
  99533. maxHeight?: number;
  99534. colorFilter?: Color3;
  99535. alphaFilter?: number;
  99536. updatable?: boolean;
  99537. onReady?: (mesh: GroundMesh) => void;
  99538. }, scene?: Nullable<Scene>): GroundMesh;
  99539. }
  99540. }
  99541. declare module BABYLON {
  99542. /**
  99543. * Class containing static functions to help procedurally build meshes
  99544. */
  99545. export class TorusBuilder {
  99546. /**
  99547. * Creates a torus mesh
  99548. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  99549. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  99550. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  99551. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  99552. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  99553. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  99554. * @param name defines the name of the mesh
  99555. * @param options defines the options used to create the mesh
  99556. * @param scene defines the hosting scene
  99557. * @returns the torus mesh
  99558. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  99559. */
  99560. static CreateTorus(name: string, options: {
  99561. diameter?: number;
  99562. thickness?: number;
  99563. tessellation?: number;
  99564. updatable?: boolean;
  99565. sideOrientation?: number;
  99566. frontUVs?: Vector4;
  99567. backUVs?: Vector4;
  99568. }, scene: any): Mesh;
  99569. }
  99570. }
  99571. declare module BABYLON {
  99572. /**
  99573. * Class containing static functions to help procedurally build meshes
  99574. */
  99575. export class CylinderBuilder {
  99576. /**
  99577. * Creates a cylinder or a cone mesh
  99578. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  99579. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  99580. * * 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.
  99581. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  99582. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  99583. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  99584. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  99585. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  99586. * * 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).
  99587. * * 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
  99588. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  99589. * * 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
  99590. * * 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.
  99591. * * If `enclose` is false, a ring surface is one element.
  99592. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  99593. * * 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
  99594. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  99595. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  99596. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  99597. * @param name defines the name of the mesh
  99598. * @param options defines the options used to create the mesh
  99599. * @param scene defines the hosting scene
  99600. * @returns the cylinder mesh
  99601. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  99602. */
  99603. static CreateCylinder(name: string, options: {
  99604. height?: number;
  99605. diameterTop?: number;
  99606. diameterBottom?: number;
  99607. diameter?: number;
  99608. tessellation?: number;
  99609. subdivisions?: number;
  99610. arc?: number;
  99611. faceColors?: Color4[];
  99612. faceUV?: Vector4[];
  99613. updatable?: boolean;
  99614. hasRings?: boolean;
  99615. enclose?: boolean;
  99616. sideOrientation?: number;
  99617. frontUVs?: Vector4;
  99618. backUVs?: Vector4;
  99619. }, scene: any): Mesh;
  99620. }
  99621. }
  99622. declare module BABYLON {
  99623. /**
  99624. * Options to modify the vr teleportation behavior.
  99625. */
  99626. export interface VRTeleportationOptions {
  99627. /**
  99628. * The name of the mesh which should be used as the teleportation floor. (default: null)
  99629. */
  99630. floorMeshName?: string;
  99631. /**
  99632. * A list of meshes to be used as the teleportation floor. (default: empty)
  99633. */
  99634. floorMeshes?: Mesh[];
  99635. }
  99636. /**
  99637. * Options to modify the vr experience helper's behavior.
  99638. */
  99639. export interface VRExperienceHelperOptions extends WebVROptions {
  99640. /**
  99641. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  99642. */
  99643. createDeviceOrientationCamera?: boolean;
  99644. /**
  99645. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  99646. */
  99647. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  99648. /**
  99649. * Uses the main button on the controller to toggle the laser casted. (default: true)
  99650. */
  99651. laserToggle?: boolean;
  99652. /**
  99653. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  99654. */
  99655. floorMeshes?: Mesh[];
  99656. /**
  99657. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  99658. */
  99659. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  99660. }
  99661. /**
  99662. * Event containing information after VR has been entered
  99663. */
  99664. export class OnAfterEnteringVRObservableEvent {
  99665. /**
  99666. * If entering vr was successful
  99667. */
  99668. success: boolean;
  99669. }
  99670. /**
  99671. * Helps to quickly add VR support to an existing scene.
  99672. * See http://doc.babylonjs.com/how_to/webvr_helper
  99673. */
  99674. export class VRExperienceHelper {
  99675. /** Options to modify the vr experience helper's behavior. */
  99676. webVROptions: VRExperienceHelperOptions;
  99677. private _scene;
  99678. private _position;
  99679. private _btnVR;
  99680. private _btnVRDisplayed;
  99681. private _webVRsupported;
  99682. private _webVRready;
  99683. private _webVRrequesting;
  99684. private _webVRpresenting;
  99685. private _hasEnteredVR;
  99686. private _fullscreenVRpresenting;
  99687. private _canvas;
  99688. private _webVRCamera;
  99689. private _vrDeviceOrientationCamera;
  99690. private _deviceOrientationCamera;
  99691. private _existingCamera;
  99692. private _onKeyDown;
  99693. private _onVrDisplayPresentChange;
  99694. private _onVRDisplayChanged;
  99695. private _onVRRequestPresentStart;
  99696. private _onVRRequestPresentComplete;
  99697. /**
  99698. * Observable raised right before entering VR.
  99699. */
  99700. onEnteringVRObservable: Observable<VRExperienceHelper>;
  99701. /**
  99702. * Observable raised when entering VR has completed.
  99703. */
  99704. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  99705. /**
  99706. * Observable raised when exiting VR.
  99707. */
  99708. onExitingVRObservable: Observable<VRExperienceHelper>;
  99709. /**
  99710. * Observable raised when controller mesh is loaded.
  99711. */
  99712. onControllerMeshLoadedObservable: Observable<WebVRController>;
  99713. /** Return this.onEnteringVRObservable
  99714. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  99715. */
  99716. readonly onEnteringVR: Observable<VRExperienceHelper>;
  99717. /** Return this.onExitingVRObservable
  99718. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  99719. */
  99720. readonly onExitingVR: Observable<VRExperienceHelper>;
  99721. /** Return this.onControllerMeshLoadedObservable
  99722. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  99723. */
  99724. readonly onControllerMeshLoaded: Observable<WebVRController>;
  99725. private _rayLength;
  99726. private _useCustomVRButton;
  99727. private _teleportationRequested;
  99728. private _teleportActive;
  99729. private _floorMeshName;
  99730. private _floorMeshesCollection;
  99731. private _rotationAllowed;
  99732. private _teleportBackwardsVector;
  99733. private _teleportationTarget;
  99734. private _isDefaultTeleportationTarget;
  99735. private _postProcessMove;
  99736. private _teleportationFillColor;
  99737. private _teleportationBorderColor;
  99738. private _rotationAngle;
  99739. private _haloCenter;
  99740. private _cameraGazer;
  99741. private _padSensibilityUp;
  99742. private _padSensibilityDown;
  99743. private _leftController;
  99744. private _rightController;
  99745. /**
  99746. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  99747. */
  99748. onNewMeshSelected: Observable<AbstractMesh>;
  99749. /**
  99750. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  99751. */
  99752. onNewMeshPicked: Observable<PickingInfo>;
  99753. private _circleEase;
  99754. /**
  99755. * Observable raised before camera teleportation
  99756. */
  99757. onBeforeCameraTeleport: Observable<Vector3>;
  99758. /**
  99759. * Observable raised after camera teleportation
  99760. */
  99761. onAfterCameraTeleport: Observable<Vector3>;
  99762. /**
  99763. * Observable raised when current selected mesh gets unselected
  99764. */
  99765. onSelectedMeshUnselected: Observable<AbstractMesh>;
  99766. private _raySelectionPredicate;
  99767. /**
  99768. * To be optionaly changed by user to define custom ray selection
  99769. */
  99770. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  99771. /**
  99772. * To be optionaly changed by user to define custom selection logic (after ray selection)
  99773. */
  99774. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  99775. /**
  99776. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  99777. */
  99778. teleportationEnabled: boolean;
  99779. private _defaultHeight;
  99780. private _teleportationInitialized;
  99781. private _interactionsEnabled;
  99782. private _interactionsRequested;
  99783. private _displayGaze;
  99784. private _displayLaserPointer;
  99785. /**
  99786. * The mesh used to display where the user is going to teleport.
  99787. */
  99788. /**
  99789. * Sets the mesh to be used to display where the user is going to teleport.
  99790. */
  99791. teleportationTarget: Mesh;
  99792. /**
  99793. * 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
  99794. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  99795. * See http://doc.babylonjs.com/resources/baking_transformations
  99796. */
  99797. gazeTrackerMesh: Mesh;
  99798. /**
  99799. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  99800. */
  99801. updateGazeTrackerScale: boolean;
  99802. /**
  99803. * If the gaze trackers color should be updated when selecting meshes
  99804. */
  99805. updateGazeTrackerColor: boolean;
  99806. /**
  99807. * The gaze tracking mesh corresponding to the left controller
  99808. */
  99809. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  99810. /**
  99811. * The gaze tracking mesh corresponding to the right controller
  99812. */
  99813. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  99814. /**
  99815. * If the ray of the gaze should be displayed.
  99816. */
  99817. /**
  99818. * Sets if the ray of the gaze should be displayed.
  99819. */
  99820. displayGaze: boolean;
  99821. /**
  99822. * If the ray of the LaserPointer should be displayed.
  99823. */
  99824. /**
  99825. * Sets if the ray of the LaserPointer should be displayed.
  99826. */
  99827. displayLaserPointer: boolean;
  99828. /**
  99829. * The deviceOrientationCamera used as the camera when not in VR.
  99830. */
  99831. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  99832. /**
  99833. * Based on the current WebVR support, returns the current VR camera used.
  99834. */
  99835. readonly currentVRCamera: Nullable<Camera>;
  99836. /**
  99837. * The webVRCamera which is used when in VR.
  99838. */
  99839. readonly webVRCamera: WebVRFreeCamera;
  99840. /**
  99841. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  99842. */
  99843. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  99844. private readonly _teleportationRequestInitiated;
  99845. /**
  99846. * Defines wether or not Pointer lock should be requested when switching to
  99847. * full screen.
  99848. */
  99849. requestPointerLockOnFullScreen: boolean;
  99850. /**
  99851. * Instantiates a VRExperienceHelper.
  99852. * Helps to quickly add VR support to an existing scene.
  99853. * @param scene The scene the VRExperienceHelper belongs to.
  99854. * @param webVROptions Options to modify the vr experience helper's behavior.
  99855. */
  99856. constructor(scene: Scene,
  99857. /** Options to modify the vr experience helper's behavior. */
  99858. webVROptions?: VRExperienceHelperOptions);
  99859. private _onDefaultMeshLoaded;
  99860. private _onResize;
  99861. private _onFullscreenChange;
  99862. /**
  99863. * Gets a value indicating if we are currently in VR mode.
  99864. */
  99865. readonly isInVRMode: boolean;
  99866. private onVrDisplayPresentChange;
  99867. private onVRDisplayChanged;
  99868. private moveButtonToBottomRight;
  99869. private displayVRButton;
  99870. private updateButtonVisibility;
  99871. private _cachedAngularSensibility;
  99872. /**
  99873. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  99874. * Otherwise, will use the fullscreen API.
  99875. */
  99876. enterVR(): void;
  99877. /**
  99878. * Attempt to exit VR, or fullscreen.
  99879. */
  99880. exitVR(): void;
  99881. /**
  99882. * The position of the vr experience helper.
  99883. */
  99884. /**
  99885. * Sets the position of the vr experience helper.
  99886. */
  99887. position: Vector3;
  99888. /**
  99889. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  99890. */
  99891. enableInteractions(): void;
  99892. private readonly _noControllerIsActive;
  99893. private beforeRender;
  99894. private _isTeleportationFloor;
  99895. /**
  99896. * Adds a floor mesh to be used for teleportation.
  99897. * @param floorMesh the mesh to be used for teleportation.
  99898. */
  99899. addFloorMesh(floorMesh: Mesh): void;
  99900. /**
  99901. * Removes a floor mesh from being used for teleportation.
  99902. * @param floorMesh the mesh to be removed.
  99903. */
  99904. removeFloorMesh(floorMesh: Mesh): void;
  99905. /**
  99906. * Enables interactions and teleportation using the VR controllers and gaze.
  99907. * @param vrTeleportationOptions options to modify teleportation behavior.
  99908. */
  99909. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  99910. private _onNewGamepadConnected;
  99911. private _tryEnableInteractionOnController;
  99912. private _onNewGamepadDisconnected;
  99913. private _enableInteractionOnController;
  99914. private _checkTeleportWithRay;
  99915. private _checkRotate;
  99916. private _checkTeleportBackwards;
  99917. private _enableTeleportationOnController;
  99918. private _createTeleportationCircles;
  99919. private _displayTeleportationTarget;
  99920. private _hideTeleportationTarget;
  99921. private _rotateCamera;
  99922. private _moveTeleportationSelectorTo;
  99923. private _workingVector;
  99924. private _workingQuaternion;
  99925. private _workingMatrix;
  99926. /**
  99927. * Teleports the users feet to the desired location
  99928. * @param location The location where the user's feet should be placed
  99929. */
  99930. teleportCamera(location: Vector3): void;
  99931. private _convertNormalToDirectionOfRay;
  99932. private _castRayAndSelectObject;
  99933. private _notifySelectedMeshUnselected;
  99934. /**
  99935. * Sets the color of the laser ray from the vr controllers.
  99936. * @param color new color for the ray.
  99937. */
  99938. changeLaserColor(color: Color3): void;
  99939. /**
  99940. * Sets the color of the ray from the vr headsets gaze.
  99941. * @param color new color for the ray.
  99942. */
  99943. changeGazeColor(color: Color3): void;
  99944. /**
  99945. * Exits VR and disposes of the vr experience helper
  99946. */
  99947. dispose(): void;
  99948. /**
  99949. * Gets the name of the VRExperienceHelper class
  99950. * @returns "VRExperienceHelper"
  99951. */
  99952. getClassName(): string;
  99953. }
  99954. }
  99955. declare module BABYLON {
  99956. /**
  99957. * Manages an XRSession
  99958. * @see https://doc.babylonjs.com/how_to/webxr
  99959. */
  99960. export class WebXRSessionManager implements IDisposable {
  99961. private scene;
  99962. /**
  99963. * Fires every time a new xrFrame arrives which can be used to update the camera
  99964. */
  99965. onXRFrameObservable: Observable<any>;
  99966. /**
  99967. * Fires when the xr session is ended either by the device or manually done
  99968. */
  99969. onXRSessionEnded: Observable<any>;
  99970. /** @hidden */
  99971. _xrSession: XRSession;
  99972. /** @hidden */
  99973. _frameOfReference: XRFrameOfReference;
  99974. /** @hidden */
  99975. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  99976. /** @hidden */
  99977. _currentXRFrame: Nullable<XRFrame>;
  99978. private _xrNavigator;
  99979. private _xrDevice;
  99980. private _tmpMatrix;
  99981. /**
  99982. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  99983. * @param scene The scene which the session should be created for
  99984. */
  99985. constructor(scene: Scene);
  99986. /**
  99987. * Initializes the manager
  99988. * After initialization enterXR can be called to start an XR session
  99989. * @returns Promise which resolves after it is initialized
  99990. */
  99991. initializeAsync(): Promise<void>;
  99992. /**
  99993. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  99994. * @param sessionCreationOptions xr options to create the session with
  99995. * @param frameOfReferenceType option to configure how the xr pose is expressed
  99996. * @returns Promise which resolves after it enters XR
  99997. */
  99998. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  99999. /**
  100000. * Stops the xrSession and restores the renderloop
  100001. * @returns Promise which resolves after it exits XR
  100002. */
  100003. exitXRAsync(): Promise<void>;
  100004. /**
  100005. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  100006. * @param ray ray to cast into the environment
  100007. * @returns Promise which resolves with a collision point in the environment if it exists
  100008. */
  100009. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  100010. /**
  100011. * Checks if a session would be supported for the creation options specified
  100012. * @param options creation options to check if they are supported
  100013. * @returns true if supported
  100014. */
  100015. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  100016. /**
  100017. * @hidden
  100018. * Converts the render layer of xrSession to a render target
  100019. * @param session session to create render target for
  100020. * @param scene scene the new render target should be created for
  100021. */
  100022. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  100023. /**
  100024. * Disposes of the session manager
  100025. */
  100026. dispose(): void;
  100027. }
  100028. }
  100029. declare module BABYLON {
  100030. /**
  100031. * WebXR Camera which holds the views for the xrSession
  100032. * @see https://doc.babylonjs.com/how_to/webxr
  100033. */
  100034. export class WebXRCamera extends FreeCamera {
  100035. private static _TmpMatrix;
  100036. /**
  100037. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  100038. * @param name the name of the camera
  100039. * @param scene the scene to add the camera to
  100040. */
  100041. constructor(name: string, scene: Scene);
  100042. private _updateNumberOfRigCameras;
  100043. /** @hidden */
  100044. _updateForDualEyeDebugging(pupilDistance?: number): void;
  100045. /**
  100046. * Updates the cameras position from the current pose information of the XR session
  100047. * @param xrSessionManager the session containing pose information
  100048. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  100049. */
  100050. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  100051. }
  100052. }
  100053. declare module BABYLON {
  100054. /**
  100055. * States of the webXR experience
  100056. */
  100057. export enum WebXRState {
  100058. /**
  100059. * Transitioning to being in XR mode
  100060. */
  100061. ENTERING_XR = 0,
  100062. /**
  100063. * Transitioning to non XR mode
  100064. */
  100065. EXITING_XR = 1,
  100066. /**
  100067. * In XR mode and presenting
  100068. */
  100069. IN_XR = 2,
  100070. /**
  100071. * Not entered XR mode
  100072. */
  100073. NOT_IN_XR = 3
  100074. }
  100075. /**
  100076. * Helper class used to enable XR
  100077. * @see https://doc.babylonjs.com/how_to/webxr
  100078. */
  100079. export class WebXRExperienceHelper implements IDisposable {
  100080. private scene;
  100081. /**
  100082. * 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
  100083. */
  100084. container: AbstractMesh;
  100085. /**
  100086. * Camera used to render xr content
  100087. */
  100088. camera: WebXRCamera;
  100089. /**
  100090. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  100091. */
  100092. state: WebXRState;
  100093. private _setState;
  100094. private static _TmpVector;
  100095. /**
  100096. * Fires when the state of the experience helper has changed
  100097. */
  100098. onStateChangedObservable: Observable<WebXRState>;
  100099. /** @hidden */
  100100. _sessionManager: WebXRSessionManager;
  100101. private _nonVRCamera;
  100102. private _originalSceneAutoClear;
  100103. private _supported;
  100104. /**
  100105. * Creates the experience helper
  100106. * @param scene the scene to attach the experience helper to
  100107. * @returns a promise for the experience helper
  100108. */
  100109. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  100110. /**
  100111. * Creates a WebXRExperienceHelper
  100112. * @param scene The scene the helper should be created in
  100113. */
  100114. private constructor();
  100115. /**
  100116. * Exits XR mode and returns the scene to its original state
  100117. * @returns promise that resolves after xr mode has exited
  100118. */
  100119. exitXRAsync(): Promise<void>;
  100120. /**
  100121. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  100122. * @param sessionCreationOptions options for the XR session
  100123. * @param frameOfReference frame of reference of the XR session
  100124. * @returns promise that resolves after xr mode has entered
  100125. */
  100126. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  100127. /**
  100128. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  100129. * @param ray ray to cast into the environment
  100130. * @returns Promise which resolves with a collision point in the environment if it exists
  100131. */
  100132. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  100133. /**
  100134. * Updates the global position of the camera by moving the camera's container
  100135. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  100136. * @param position The desired global position of the camera
  100137. */
  100138. setPositionOfCameraUsingContainer(position: Vector3): void;
  100139. /**
  100140. * Rotates the xr camera by rotating the camera's container around the camera's position
  100141. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  100142. * @param rotation the desired quaternion rotation to apply to the camera
  100143. */
  100144. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  100145. /**
  100146. * Checks if the creation options are supported by the xr session
  100147. * @param options creation options
  100148. * @returns true if supported
  100149. */
  100150. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  100151. /**
  100152. * Disposes of the experience helper
  100153. */
  100154. dispose(): void;
  100155. }
  100156. }
  100157. declare module BABYLON {
  100158. /**
  100159. * Button which can be used to enter a different mode of XR
  100160. */
  100161. export class WebXREnterExitUIButton {
  100162. /** button element */
  100163. element: HTMLElement;
  100164. /** XR initialization options for the button */
  100165. initializationOptions: XRSessionCreationOptions;
  100166. /**
  100167. * Creates a WebXREnterExitUIButton
  100168. * @param element button element
  100169. * @param initializationOptions XR initialization options for the button
  100170. */
  100171. constructor(
  100172. /** button element */
  100173. element: HTMLElement,
  100174. /** XR initialization options for the button */
  100175. initializationOptions: XRSessionCreationOptions);
  100176. /**
  100177. * Overwritable function which can be used to update the button's visuals when the state changes
  100178. * @param activeButton the current active button in the UI
  100179. */
  100180. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  100181. }
  100182. /**
  100183. * Options to create the webXR UI
  100184. */
  100185. export class WebXREnterExitUIOptions {
  100186. /**
  100187. * Context to enter xr with
  100188. */
  100189. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  100190. /**
  100191. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  100192. */
  100193. customButtons?: Array<WebXREnterExitUIButton>;
  100194. }
  100195. /**
  100196. * UI to allow the user to enter/exit XR mode
  100197. */
  100198. export class WebXREnterExitUI implements IDisposable {
  100199. private scene;
  100200. private _overlay;
  100201. private _buttons;
  100202. private _activeButton;
  100203. /**
  100204. * Fired every time the active button is changed.
  100205. *
  100206. * When xr is entered via a button that launches xr that button will be the callback parameter
  100207. *
  100208. * When exiting xr the callback parameter will be null)
  100209. */
  100210. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  100211. /**
  100212. * Creates UI to allow the user to enter/exit XR mode
  100213. * @param scene the scene to add the ui to
  100214. * @param helper the xr experience helper to enter/exit xr with
  100215. * @param options options to configure the UI
  100216. * @returns the created ui
  100217. */
  100218. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  100219. private constructor();
  100220. private _updateButtons;
  100221. /**
  100222. * Disposes of the object
  100223. */
  100224. dispose(): void;
  100225. }
  100226. }
  100227. declare module BABYLON {
  100228. /**
  100229. * Represents an XR input
  100230. */
  100231. export class WebXRController {
  100232. /**
  100233. * 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
  100234. */
  100235. grip?: AbstractMesh;
  100236. /**
  100237. * Pointer which can be used to select objects or attach a visible laser to
  100238. */
  100239. pointer: AbstractMesh;
  100240. /**
  100241. * Creates the controller
  100242. * @see https://doc.babylonjs.com/how_to/webxr
  100243. * @param scene the scene which the controller should be associated to
  100244. */
  100245. constructor(scene: Scene);
  100246. /**
  100247. * Disposes of the object
  100248. */
  100249. dispose(): void;
  100250. }
  100251. /**
  100252. * XR input used to track XR inputs such as controllers/rays
  100253. */
  100254. export class WebXRInput implements IDisposable {
  100255. private helper;
  100256. /**
  100257. * XR controllers being tracked
  100258. */
  100259. controllers: Array<WebXRController>;
  100260. private _tmpMatrix;
  100261. private _frameObserver;
  100262. /**
  100263. * Initializes the WebXRInput
  100264. * @param helper experience helper which the input should be created for
  100265. */
  100266. constructor(helper: WebXRExperienceHelper);
  100267. /**
  100268. * Disposes of the object
  100269. */
  100270. dispose(): void;
  100271. }
  100272. }
  100273. declare module BABYLON {
  100274. /**
  100275. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  100276. */
  100277. export class WebXRManagedOutputCanvas implements IDisposable {
  100278. private _canvas;
  100279. /**
  100280. * xrpresent context of the canvas which can be used to display/mirror xr content
  100281. */
  100282. canvasContext: Nullable<WebGLRenderingContext>;
  100283. /**
  100284. * Initializes the canvas to be added/removed upon entering/exiting xr
  100285. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  100286. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  100287. */
  100288. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  100289. /**
  100290. * Disposes of the object
  100291. */
  100292. dispose(): void;
  100293. private _setManagedOutputCanvas;
  100294. private _addCanvas;
  100295. private _removeCanvas;
  100296. }
  100297. }
  100298. declare module BABYLON {
  100299. /**
  100300. * Contains an array of blocks representing the octree
  100301. */
  100302. export interface IOctreeContainer<T> {
  100303. /**
  100304. * Blocks within the octree
  100305. */
  100306. blocks: Array<OctreeBlock<T>>;
  100307. }
  100308. /**
  100309. * Class used to store a cell in an octree
  100310. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  100311. */
  100312. export class OctreeBlock<T> {
  100313. /**
  100314. * Gets the content of the current block
  100315. */
  100316. entries: T[];
  100317. /**
  100318. * Gets the list of block children
  100319. */
  100320. blocks: Array<OctreeBlock<T>>;
  100321. private _depth;
  100322. private _maxDepth;
  100323. private _capacity;
  100324. private _minPoint;
  100325. private _maxPoint;
  100326. private _boundingVectors;
  100327. private _creationFunc;
  100328. /**
  100329. * Creates a new block
  100330. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  100331. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  100332. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  100333. * @param depth defines the current depth of this block in the octree
  100334. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  100335. * @param creationFunc defines a callback to call when an element is added to the block
  100336. */
  100337. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  100338. /**
  100339. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  100340. */
  100341. readonly capacity: number;
  100342. /**
  100343. * Gets the minimum vector (in world space) of the block's bounding box
  100344. */
  100345. readonly minPoint: Vector3;
  100346. /**
  100347. * Gets the maximum vector (in world space) of the block's bounding box
  100348. */
  100349. readonly maxPoint: Vector3;
  100350. /**
  100351. * Add a new element to this block
  100352. * @param entry defines the element to add
  100353. */
  100354. addEntry(entry: T): void;
  100355. /**
  100356. * Remove an element from this block
  100357. * @param entry defines the element to remove
  100358. */
  100359. removeEntry(entry: T): void;
  100360. /**
  100361. * Add an array of elements to this block
  100362. * @param entries defines the array of elements to add
  100363. */
  100364. addEntries(entries: T[]): void;
  100365. /**
  100366. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  100367. * @param frustumPlanes defines the frustum planes to test
  100368. * @param selection defines the array to store current content if selection is positive
  100369. * @param allowDuplicate defines if the selection array can contains duplicated entries
  100370. */
  100371. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  100372. /**
  100373. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  100374. * @param sphereCenter defines the bounding sphere center
  100375. * @param sphereRadius defines the bounding sphere radius
  100376. * @param selection defines the array to store current content if selection is positive
  100377. * @param allowDuplicate defines if the selection array can contains duplicated entries
  100378. */
  100379. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  100380. /**
  100381. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  100382. * @param ray defines the ray to test with
  100383. * @param selection defines the array to store current content if selection is positive
  100384. */
  100385. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  100386. /**
  100387. * Subdivide the content into child blocks (this block will then be empty)
  100388. */
  100389. createInnerBlocks(): void;
  100390. /**
  100391. * @hidden
  100392. */
  100393. 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;
  100394. }
  100395. }
  100396. declare module BABYLON {
  100397. /**
  100398. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  100399. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  100400. */
  100401. export class Octree<T> {
  100402. /** 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.) */
  100403. maxDepth: number;
  100404. /**
  100405. * Blocks within the octree containing objects
  100406. */
  100407. blocks: Array<OctreeBlock<T>>;
  100408. /**
  100409. * Content stored in the octree
  100410. */
  100411. dynamicContent: T[];
  100412. private _maxBlockCapacity;
  100413. private _selectionContent;
  100414. private _creationFunc;
  100415. /**
  100416. * Creates a octree
  100417. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  100418. * @param creationFunc function to be used to instatiate the octree
  100419. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  100420. * @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.)
  100421. */
  100422. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  100423. /** 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.) */
  100424. maxDepth?: number);
  100425. /**
  100426. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  100427. * @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);
  100428. * @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);
  100429. * @param entries meshes to be added to the octree blocks
  100430. */
  100431. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  100432. /**
  100433. * Adds a mesh to the octree
  100434. * @param entry Mesh to add to the octree
  100435. */
  100436. addMesh(entry: T): void;
  100437. /**
  100438. * Remove an element from the octree
  100439. * @param entry defines the element to remove
  100440. */
  100441. removeMesh(entry: T): void;
  100442. /**
  100443. * Selects an array of meshes within the frustum
  100444. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  100445. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  100446. * @returns array of meshes within the frustum
  100447. */
  100448. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  100449. /**
  100450. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  100451. * @param sphereCenter defines the bounding sphere center
  100452. * @param sphereRadius defines the bounding sphere radius
  100453. * @param allowDuplicate defines if the selection array can contains duplicated entries
  100454. * @returns an array of objects that intersect the sphere
  100455. */
  100456. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  100457. /**
  100458. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  100459. * @param ray defines the ray to test with
  100460. * @returns array of intersected objects
  100461. */
  100462. intersectsRay(ray: Ray): SmartArray<T>;
  100463. /**
  100464. * Adds a mesh into the octree block if it intersects the block
  100465. */
  100466. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  100467. /**
  100468. * Adds a submesh into the octree block if it intersects the block
  100469. */
  100470. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  100471. }
  100472. }
  100473. declare module BABYLON {
  100474. interface Scene {
  100475. /**
  100476. * @hidden
  100477. * Backing Filed
  100478. */
  100479. _selectionOctree: Octree<AbstractMesh>;
  100480. /**
  100481. * Gets the octree used to boost mesh selection (picking)
  100482. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  100483. */
  100484. selectionOctree: Octree<AbstractMesh>;
  100485. /**
  100486. * Creates or updates the octree used to boost selection (picking)
  100487. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  100488. * @param maxCapacity defines the maximum capacity per leaf
  100489. * @param maxDepth defines the maximum depth of the octree
  100490. * @returns an octree of AbstractMesh
  100491. */
  100492. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  100493. }
  100494. interface AbstractMesh {
  100495. /**
  100496. * @hidden
  100497. * Backing Field
  100498. */
  100499. _submeshesOctree: Octree<SubMesh>;
  100500. /**
  100501. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  100502. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  100503. * @param maxCapacity defines the maximum size of each block (64 by default)
  100504. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  100505. * @returns the new octree
  100506. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  100507. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  100508. */
  100509. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  100510. }
  100511. /**
  100512. * Defines the octree scene component responsible to manage any octrees
  100513. * in a given scene.
  100514. */
  100515. export class OctreeSceneComponent {
  100516. /**
  100517. * The component name help to identify the component in the list of scene components.
  100518. */
  100519. readonly name: string;
  100520. /**
  100521. * The scene the component belongs to.
  100522. */
  100523. scene: Scene;
  100524. /**
  100525. * Indicates if the meshes have been checked to make sure they are isEnabled()
  100526. */
  100527. readonly checksIsEnabled: boolean;
  100528. /**
  100529. * Creates a new instance of the component for the given scene
  100530. * @param scene Defines the scene to register the component in
  100531. */
  100532. constructor(scene: Scene);
  100533. /**
  100534. * Registers the component in a given scene
  100535. */
  100536. register(): void;
  100537. /**
  100538. * Return the list of active meshes
  100539. * @returns the list of active meshes
  100540. */
  100541. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  100542. /**
  100543. * Return the list of active sub meshes
  100544. * @param mesh The mesh to get the candidates sub meshes from
  100545. * @returns the list of active sub meshes
  100546. */
  100547. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  100548. private _tempRay;
  100549. /**
  100550. * Return the list of sub meshes intersecting with a given local ray
  100551. * @param mesh defines the mesh to find the submesh for
  100552. * @param localRay defines the ray in local space
  100553. * @returns the list of intersecting sub meshes
  100554. */
  100555. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  100556. /**
  100557. * Return the list of sub meshes colliding with a collider
  100558. * @param mesh defines the mesh to find the submesh for
  100559. * @param collider defines the collider to evaluate the collision against
  100560. * @returns the list of colliding sub meshes
  100561. */
  100562. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  100563. /**
  100564. * Rebuilds the elements related to this component in case of
  100565. * context lost for instance.
  100566. */
  100567. rebuild(): void;
  100568. /**
  100569. * Disposes the component and the associated ressources.
  100570. */
  100571. dispose(): void;
  100572. }
  100573. }
  100574. declare module BABYLON {
  100575. /**
  100576. * Renders a layer on top of an existing scene
  100577. */
  100578. export class UtilityLayerRenderer implements IDisposable {
  100579. /** the original scene that will be rendered on top of */
  100580. originalScene: Scene;
  100581. private _pointerCaptures;
  100582. private _lastPointerEvents;
  100583. private static _DefaultUtilityLayer;
  100584. private static _DefaultKeepDepthUtilityLayer;
  100585. private _sharedGizmoLight;
  100586. /**
  100587. * @hidden
  100588. * Light which used by gizmos to get light shading
  100589. */
  100590. _getSharedGizmoLight(): HemisphericLight;
  100591. /**
  100592. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  100593. */
  100594. pickUtilitySceneFirst: boolean;
  100595. /**
  100596. * 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)
  100597. */
  100598. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  100599. /**
  100600. * 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)
  100601. */
  100602. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  100603. /**
  100604. * The scene that is rendered on top of the original scene
  100605. */
  100606. utilityLayerScene: Scene;
  100607. /**
  100608. * If the utility layer should automatically be rendered on top of existing scene
  100609. */
  100610. shouldRender: boolean;
  100611. /**
  100612. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  100613. */
  100614. onlyCheckPointerDownEvents: boolean;
  100615. /**
  100616. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  100617. */
  100618. processAllEvents: boolean;
  100619. /**
  100620. * Observable raised when the pointer move from the utility layer scene to the main scene
  100621. */
  100622. onPointerOutObservable: Observable<number>;
  100623. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  100624. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  100625. private _afterRenderObserver;
  100626. private _sceneDisposeObserver;
  100627. private _originalPointerObserver;
  100628. /**
  100629. * Instantiates a UtilityLayerRenderer
  100630. * @param originalScene the original scene that will be rendered on top of
  100631. * @param handleEvents boolean indicating if the utility layer should handle events
  100632. */
  100633. constructor(
  100634. /** the original scene that will be rendered on top of */
  100635. originalScene: Scene, handleEvents?: boolean);
  100636. private _notifyObservers;
  100637. /**
  100638. * Renders the utility layers scene on top of the original scene
  100639. */
  100640. render(): void;
  100641. /**
  100642. * Disposes of the renderer
  100643. */
  100644. dispose(): void;
  100645. private _updateCamera;
  100646. }
  100647. }
  100648. declare module BABYLON {
  100649. /**
  100650. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  100651. */
  100652. export class Gizmo implements IDisposable {
  100653. /** The utility layer the gizmo will be added to */
  100654. gizmoLayer: UtilityLayerRenderer;
  100655. /**
  100656. * The root mesh of the gizmo
  100657. */
  100658. _rootMesh: Mesh;
  100659. private _attachedMesh;
  100660. /**
  100661. * Ratio for the scale of the gizmo (Default: 1)
  100662. */
  100663. scaleRatio: number;
  100664. /**
  100665. * If a custom mesh has been set (Default: false)
  100666. */
  100667. protected _customMeshSet: boolean;
  100668. /**
  100669. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  100670. * * When set, interactions will be enabled
  100671. */
  100672. attachedMesh: Nullable<AbstractMesh>;
  100673. /**
  100674. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  100675. * @param mesh The mesh to replace the default mesh of the gizmo
  100676. */
  100677. setCustomMesh(mesh: Mesh): void;
  100678. /**
  100679. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  100680. */
  100681. updateGizmoRotationToMatchAttachedMesh: boolean;
  100682. /**
  100683. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  100684. */
  100685. updateGizmoPositionToMatchAttachedMesh: boolean;
  100686. /**
  100687. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  100688. */
  100689. protected _updateScale: boolean;
  100690. protected _interactionsEnabled: boolean;
  100691. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  100692. private _beforeRenderObserver;
  100693. private _tempVector;
  100694. /**
  100695. * Creates a gizmo
  100696. * @param gizmoLayer The utility layer the gizmo will be added to
  100697. */
  100698. constructor(
  100699. /** The utility layer the gizmo will be added to */
  100700. gizmoLayer?: UtilityLayerRenderer);
  100701. /**
  100702. * Updates the gizmo to match the attached mesh's position/rotation
  100703. */
  100704. protected _update(): void;
  100705. /**
  100706. * Disposes of the gizmo
  100707. */
  100708. dispose(): void;
  100709. }
  100710. }
  100711. declare module BABYLON {
  100712. /**
  100713. * Single axis drag gizmo
  100714. */
  100715. export class AxisDragGizmo extends Gizmo {
  100716. /**
  100717. * Drag behavior responsible for the gizmos dragging interactions
  100718. */
  100719. dragBehavior: PointerDragBehavior;
  100720. private _pointerObserver;
  100721. /**
  100722. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  100723. */
  100724. snapDistance: number;
  100725. /**
  100726. * Event that fires each time the gizmo snaps to a new location.
  100727. * * snapDistance is the the change in distance
  100728. */
  100729. onSnapObservable: Observable<{
  100730. snapDistance: number;
  100731. }>;
  100732. /** @hidden */
  100733. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  100734. /** @hidden */
  100735. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  100736. /**
  100737. * Creates an AxisDragGizmo
  100738. * @param gizmoLayer The utility layer the gizmo will be added to
  100739. * @param dragAxis The axis which the gizmo will be able to drag on
  100740. * @param color The color of the gizmo
  100741. */
  100742. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  100743. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  100744. /**
  100745. * Disposes of the gizmo
  100746. */
  100747. dispose(): void;
  100748. }
  100749. }
  100750. declare module BABYLON.Debug {
  100751. /**
  100752. * The Axes viewer will show 3 axes in a specific point in space
  100753. */
  100754. export class AxesViewer {
  100755. private _xAxis;
  100756. private _yAxis;
  100757. private _zAxis;
  100758. private _scaleLinesFactor;
  100759. private _instanced;
  100760. /**
  100761. * Gets the hosting scene
  100762. */
  100763. scene: Scene;
  100764. /**
  100765. * Gets or sets a number used to scale line length
  100766. */
  100767. scaleLines: number;
  100768. /** Gets the node hierarchy used to render x-axis */
  100769. readonly xAxis: TransformNode;
  100770. /** Gets the node hierarchy used to render y-axis */
  100771. readonly yAxis: TransformNode;
  100772. /** Gets the node hierarchy used to render z-axis */
  100773. readonly zAxis: TransformNode;
  100774. /**
  100775. * Creates a new AxesViewer
  100776. * @param scene defines the hosting scene
  100777. * @param scaleLines defines a number used to scale line length (1 by default)
  100778. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  100779. * @param xAxis defines the node hierarchy used to render the x-axis
  100780. * @param yAxis defines the node hierarchy used to render the y-axis
  100781. * @param zAxis defines the node hierarchy used to render the z-axis
  100782. */
  100783. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  100784. /**
  100785. * Force the viewer to update
  100786. * @param position defines the position of the viewer
  100787. * @param xaxis defines the x axis of the viewer
  100788. * @param yaxis defines the y axis of the viewer
  100789. * @param zaxis defines the z axis of the viewer
  100790. */
  100791. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  100792. /**
  100793. * Creates an instance of this axes viewer.
  100794. * @returns a new axes viewer with instanced meshes
  100795. */
  100796. createInstance(): AxesViewer;
  100797. /** Releases resources */
  100798. dispose(): void;
  100799. private static _SetRenderingGroupId;
  100800. }
  100801. }
  100802. declare module BABYLON.Debug {
  100803. /**
  100804. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  100805. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  100806. */
  100807. export class BoneAxesViewer extends AxesViewer {
  100808. /**
  100809. * Gets or sets the target mesh where to display the axes viewer
  100810. */
  100811. mesh: Nullable<Mesh>;
  100812. /**
  100813. * Gets or sets the target bone where to display the axes viewer
  100814. */
  100815. bone: Nullable<Bone>;
  100816. /** Gets current position */
  100817. pos: Vector3;
  100818. /** Gets direction of X axis */
  100819. xaxis: Vector3;
  100820. /** Gets direction of Y axis */
  100821. yaxis: Vector3;
  100822. /** Gets direction of Z axis */
  100823. zaxis: Vector3;
  100824. /**
  100825. * Creates a new BoneAxesViewer
  100826. * @param scene defines the hosting scene
  100827. * @param bone defines the target bone
  100828. * @param mesh defines the target mesh
  100829. * @param scaleLines defines a scaling factor for line length (1 by default)
  100830. */
  100831. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  100832. /**
  100833. * Force the viewer to update
  100834. */
  100835. update(): void;
  100836. /** Releases resources */
  100837. dispose(): void;
  100838. }
  100839. }
  100840. declare module BABYLON {
  100841. /**
  100842. * Interface used to define scene explorer extensibility option
  100843. */
  100844. export interface IExplorerExtensibilityOption {
  100845. /**
  100846. * Define the option label
  100847. */
  100848. label: string;
  100849. /**
  100850. * Defines the action to execute on click
  100851. */
  100852. action: (entity: any) => void;
  100853. }
  100854. /**
  100855. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  100856. */
  100857. export interface IExplorerExtensibilityGroup {
  100858. /**
  100859. * Defines a predicate to test if a given type mut be extended
  100860. */
  100861. predicate: (entity: any) => boolean;
  100862. /**
  100863. * Gets the list of options added to a type
  100864. */
  100865. entries: IExplorerExtensibilityOption[];
  100866. }
  100867. /**
  100868. * Interface used to define the options to use to create the Inspector
  100869. */
  100870. export interface IInspectorOptions {
  100871. /**
  100872. * Display in overlay mode (default: false)
  100873. */
  100874. overlay?: boolean;
  100875. /**
  100876. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  100877. */
  100878. globalRoot?: HTMLElement;
  100879. /**
  100880. * Display the Scene explorer
  100881. */
  100882. showExplorer?: boolean;
  100883. /**
  100884. * Display the property inspector
  100885. */
  100886. showInspector?: boolean;
  100887. /**
  100888. * Display in embed mode (both panes on the right)
  100889. */
  100890. embedMode?: boolean;
  100891. /**
  100892. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  100893. */
  100894. handleResize?: boolean;
  100895. /**
  100896. * Allow the panes to popup (default: true)
  100897. */
  100898. enablePopup?: boolean;
  100899. /**
  100900. * Allow the panes to be closed by users (default: true)
  100901. */
  100902. enableClose?: boolean;
  100903. /**
  100904. * Optional list of extensibility entries
  100905. */
  100906. explorerExtensibility?: IExplorerExtensibilityGroup[];
  100907. /**
  100908. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  100909. */
  100910. inspectorURL?: string;
  100911. }
  100912. interface Scene {
  100913. /**
  100914. * @hidden
  100915. * Backing field
  100916. */
  100917. _debugLayer: DebugLayer;
  100918. /**
  100919. * Gets the debug layer (aka Inspector) associated with the scene
  100920. * @see http://doc.babylonjs.com/features/playground_debuglayer
  100921. */
  100922. debugLayer: DebugLayer;
  100923. }
  100924. /**
  100925. * The debug layer (aka Inspector) is the go to tool in order to better understand
  100926. * what is happening in your scene
  100927. * @see http://doc.babylonjs.com/features/playground_debuglayer
  100928. */
  100929. export class DebugLayer {
  100930. /**
  100931. * Define the url to get the inspector script from.
  100932. * By default it uses the babylonjs CDN.
  100933. * @ignoreNaming
  100934. */
  100935. static InspectorURL: string;
  100936. private _scene;
  100937. private BJSINSPECTOR;
  100938. /**
  100939. * Observable triggered when a property is changed through the inspector.
  100940. */
  100941. onPropertyChangedObservable: Observable<{
  100942. object: any;
  100943. property: string;
  100944. value: any;
  100945. initialValue: any;
  100946. }>;
  100947. /**
  100948. * Instantiates a new debug layer.
  100949. * The debug layer (aka Inspector) is the go to tool in order to better understand
  100950. * what is happening in your scene
  100951. * @see http://doc.babylonjs.com/features/playground_debuglayer
  100952. * @param scene Defines the scene to inspect
  100953. */
  100954. constructor(scene: Scene);
  100955. /** Creates the inspector window. */
  100956. private _createInspector;
  100957. /**
  100958. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  100959. * @param entity defines the entity to select
  100960. * @param lineContainerTitle defines the specific block to highlight
  100961. */
  100962. select(entity: any, lineContainerTitle?: string): void;
  100963. /** Get the inspector from bundle or global */
  100964. private _getGlobalInspector;
  100965. /**
  100966. * Get if the inspector is visible or not.
  100967. * @returns true if visible otherwise, false
  100968. */
  100969. isVisible(): boolean;
  100970. /**
  100971. * Hide the inspector and close its window.
  100972. */
  100973. hide(): void;
  100974. /**
  100975. * Launch the debugLayer.
  100976. * @param config Define the configuration of the inspector
  100977. * @return a promise fulfilled when the debug layer is visible
  100978. */
  100979. show(config?: IInspectorOptions): Promise<DebugLayer>;
  100980. }
  100981. }
  100982. declare module BABYLON {
  100983. /**
  100984. * Class containing static functions to help procedurally build meshes
  100985. */
  100986. export class BoxBuilder {
  100987. /**
  100988. * Creates a box mesh
  100989. * * The parameter `size` sets the size (float) of each box side (default 1)
  100990. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  100991. * * 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)
  100992. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  100993. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  100994. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  100995. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  100996. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  100997. * @param name defines the name of the mesh
  100998. * @param options defines the options used to create the mesh
  100999. * @param scene defines the hosting scene
  101000. * @returns the box mesh
  101001. */
  101002. static CreateBox(name: string, options: {
  101003. size?: number;
  101004. width?: number;
  101005. height?: number;
  101006. depth?: number;
  101007. faceUV?: Vector4[];
  101008. faceColors?: Color4[];
  101009. sideOrientation?: number;
  101010. frontUVs?: Vector4;
  101011. backUVs?: Vector4;
  101012. wrap?: boolean;
  101013. topBaseAt?: number;
  101014. bottomBaseAt?: number;
  101015. updatable?: boolean;
  101016. }, scene?: Nullable<Scene>): Mesh;
  101017. }
  101018. }
  101019. declare module BABYLON {
  101020. /**
  101021. * Class containing static functions to help procedurally build meshes
  101022. */
  101023. export class SphereBuilder {
  101024. /**
  101025. * Creates a sphere mesh
  101026. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  101027. * * 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`)
  101028. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  101029. * * 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
  101030. * * 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)
  101031. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  101032. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  101033. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  101034. * @param name defines the name of the mesh
  101035. * @param options defines the options used to create the mesh
  101036. * @param scene defines the hosting scene
  101037. * @returns the sphere mesh
  101038. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  101039. */
  101040. static CreateSphere(name: string, options: {
  101041. segments?: number;
  101042. diameter?: number;
  101043. diameterX?: number;
  101044. diameterY?: number;
  101045. diameterZ?: number;
  101046. arc?: number;
  101047. slice?: number;
  101048. sideOrientation?: number;
  101049. frontUVs?: Vector4;
  101050. backUVs?: Vector4;
  101051. updatable?: boolean;
  101052. }, scene: any): Mesh;
  101053. }
  101054. }
  101055. declare module BABYLON.Debug {
  101056. /**
  101057. * Used to show the physics impostor around the specific mesh
  101058. */
  101059. export class PhysicsViewer {
  101060. /** @hidden */
  101061. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  101062. /** @hidden */
  101063. protected _meshes: Array<Nullable<AbstractMesh>>;
  101064. /** @hidden */
  101065. protected _scene: Nullable<Scene>;
  101066. /** @hidden */
  101067. protected _numMeshes: number;
  101068. /** @hidden */
  101069. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  101070. private _renderFunction;
  101071. private _utilityLayer;
  101072. private _debugBoxMesh;
  101073. private _debugSphereMesh;
  101074. private _debugCylinderMesh;
  101075. private _debugMaterial;
  101076. private _debugMeshMeshes;
  101077. /**
  101078. * Creates a new PhysicsViewer
  101079. * @param scene defines the hosting scene
  101080. */
  101081. constructor(scene: Scene);
  101082. /** @hidden */
  101083. protected _updateDebugMeshes(): void;
  101084. /**
  101085. * Renders a specified physic impostor
  101086. * @param impostor defines the impostor to render
  101087. * @param targetMesh defines the mesh represented by the impostor
  101088. * @returns the new debug mesh used to render the impostor
  101089. */
  101090. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  101091. /**
  101092. * Hides a specified physic impostor
  101093. * @param impostor defines the impostor to hide
  101094. */
  101095. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  101096. private _getDebugMaterial;
  101097. private _getDebugBoxMesh;
  101098. private _getDebugSphereMesh;
  101099. private _getDebugCylinderMesh;
  101100. private _getDebugMeshMesh;
  101101. private _getDebugMesh;
  101102. /** Releases all resources */
  101103. dispose(): void;
  101104. }
  101105. }
  101106. declare module BABYLON {
  101107. /**
  101108. * Class containing static functions to help procedurally build meshes
  101109. */
  101110. export class LinesBuilder {
  101111. /**
  101112. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  101113. * * 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
  101114. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  101115. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  101116. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  101117. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  101118. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  101119. * * 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
  101120. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  101121. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  101122. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  101123. * @param name defines the name of the new line system
  101124. * @param options defines the options used to create the line system
  101125. * @param scene defines the hosting scene
  101126. * @returns a new line system mesh
  101127. */
  101128. static CreateLineSystem(name: string, options: {
  101129. lines: Vector3[][];
  101130. updatable?: boolean;
  101131. instance?: Nullable<LinesMesh>;
  101132. colors?: Nullable<Color4[][]>;
  101133. useVertexAlpha?: boolean;
  101134. }, scene: Nullable<Scene>): LinesMesh;
  101135. /**
  101136. * Creates a line mesh
  101137. * 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
  101138. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  101139. * * The parameter `points` is an array successive Vector3
  101140. * * 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
  101141. * * The optional parameter `colors` is an array of successive Color4, one per line point
  101142. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  101143. * * When updating an instance, remember that only point positions can change, not the number of points
  101144. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  101145. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  101146. * @param name defines the name of the new line system
  101147. * @param options defines the options used to create the line system
  101148. * @param scene defines the hosting scene
  101149. * @returns a new line mesh
  101150. */
  101151. static CreateLines(name: string, options: {
  101152. points: Vector3[];
  101153. updatable?: boolean;
  101154. instance?: Nullable<LinesMesh>;
  101155. colors?: Color4[];
  101156. useVertexAlpha?: boolean;
  101157. }, scene?: Nullable<Scene>): LinesMesh;
  101158. /**
  101159. * Creates a dashed line mesh
  101160. * * 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
  101161. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  101162. * * The parameter `points` is an array successive Vector3
  101163. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  101164. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  101165. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  101166. * * 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
  101167. * * When updating an instance, remember that only point positions can change, not the number of points
  101168. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  101169. * @param name defines the name of the mesh
  101170. * @param options defines the options used to create the mesh
  101171. * @param scene defines the hosting scene
  101172. * @returns the dashed line mesh
  101173. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  101174. */
  101175. static CreateDashedLines(name: string, options: {
  101176. points: Vector3[];
  101177. dashSize?: number;
  101178. gapSize?: number;
  101179. dashNb?: number;
  101180. updatable?: boolean;
  101181. instance?: LinesMesh;
  101182. }, scene?: Nullable<Scene>): LinesMesh;
  101183. }
  101184. }
  101185. declare module BABYLON {
  101186. /**
  101187. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  101188. * in order to better appreciate the issue one might have.
  101189. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  101190. */
  101191. export class RayHelper {
  101192. /**
  101193. * Defines the ray we are currently tryin to visualize.
  101194. */
  101195. ray: Nullable<Ray>;
  101196. private _renderPoints;
  101197. private _renderLine;
  101198. private _renderFunction;
  101199. private _scene;
  101200. private _updateToMeshFunction;
  101201. private _attachedToMesh;
  101202. private _meshSpaceDirection;
  101203. private _meshSpaceOrigin;
  101204. /**
  101205. * Helper function to create a colored helper in a scene in one line.
  101206. * @param ray Defines the ray we are currently tryin to visualize
  101207. * @param scene Defines the scene the ray is used in
  101208. * @param color Defines the color we want to see the ray in
  101209. * @returns The newly created ray helper.
  101210. */
  101211. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  101212. /**
  101213. * Instantiate a new ray helper.
  101214. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  101215. * in order to better appreciate the issue one might have.
  101216. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  101217. * @param ray Defines the ray we are currently tryin to visualize
  101218. */
  101219. constructor(ray: Ray);
  101220. /**
  101221. * Shows the ray we are willing to debug.
  101222. * @param scene Defines the scene the ray needs to be rendered in
  101223. * @param color Defines the color the ray needs to be rendered in
  101224. */
  101225. show(scene: Scene, color?: Color3): void;
  101226. /**
  101227. * Hides the ray we are debugging.
  101228. */
  101229. hide(): void;
  101230. private _render;
  101231. /**
  101232. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  101233. * @param mesh Defines the mesh we want the helper attached to
  101234. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  101235. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  101236. * @param length Defines the length of the ray
  101237. */
  101238. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  101239. /**
  101240. * Detach the ray helper from the mesh it has previously been attached to.
  101241. */
  101242. detachFromMesh(): void;
  101243. private _updateToMesh;
  101244. /**
  101245. * Dispose the helper and release its associated resources.
  101246. */
  101247. dispose(): void;
  101248. }
  101249. }
  101250. declare module BABYLON.Debug {
  101251. /**
  101252. * Class used to render a debug view of a given skeleton
  101253. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  101254. */
  101255. export class SkeletonViewer {
  101256. /** defines the skeleton to render */
  101257. skeleton: Skeleton;
  101258. /** defines the mesh attached to the skeleton */
  101259. mesh: AbstractMesh;
  101260. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  101261. autoUpdateBonesMatrices: boolean;
  101262. /** defines the rendering group id to use with the viewer */
  101263. renderingGroupId: number;
  101264. /** Gets or sets the color used to render the skeleton */
  101265. color: Color3;
  101266. private _scene;
  101267. private _debugLines;
  101268. private _debugMesh;
  101269. private _isEnabled;
  101270. private _renderFunction;
  101271. private _utilityLayer;
  101272. /**
  101273. * Returns the mesh used to render the bones
  101274. */
  101275. readonly debugMesh: Nullable<LinesMesh>;
  101276. /**
  101277. * Creates a new SkeletonViewer
  101278. * @param skeleton defines the skeleton to render
  101279. * @param mesh defines the mesh attached to the skeleton
  101280. * @param scene defines the hosting scene
  101281. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  101282. * @param renderingGroupId defines the rendering group id to use with the viewer
  101283. */
  101284. constructor(
  101285. /** defines the skeleton to render */
  101286. skeleton: Skeleton,
  101287. /** defines the mesh attached to the skeleton */
  101288. mesh: AbstractMesh, scene: Scene,
  101289. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  101290. autoUpdateBonesMatrices?: boolean,
  101291. /** defines the rendering group id to use with the viewer */
  101292. renderingGroupId?: number);
  101293. /** Gets or sets a boolean indicating if the viewer is enabled */
  101294. isEnabled: boolean;
  101295. private _getBonePosition;
  101296. private _getLinesForBonesWithLength;
  101297. private _getLinesForBonesNoLength;
  101298. /** Update the viewer to sync with current skeleton state */
  101299. update(): void;
  101300. /** Release associated resources */
  101301. dispose(): void;
  101302. }
  101303. }
  101304. declare module BABYLON {
  101305. /**
  101306. * Options to create the null engine
  101307. */
  101308. export class NullEngineOptions {
  101309. /**
  101310. * Render width (Default: 512)
  101311. */
  101312. renderWidth: number;
  101313. /**
  101314. * Render height (Default: 256)
  101315. */
  101316. renderHeight: number;
  101317. /**
  101318. * Texture size (Default: 512)
  101319. */
  101320. textureSize: number;
  101321. /**
  101322. * If delta time between frames should be constant
  101323. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  101324. */
  101325. deterministicLockstep: boolean;
  101326. /**
  101327. * Maximum about of steps between frames (Default: 4)
  101328. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  101329. */
  101330. lockstepMaxSteps: number;
  101331. }
  101332. /**
  101333. * The null engine class provides support for headless version of babylon.js.
  101334. * This can be used in server side scenario or for testing purposes
  101335. */
  101336. export class NullEngine extends Engine {
  101337. private _options;
  101338. /**
  101339. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  101340. */
  101341. isDeterministicLockStep(): boolean;
  101342. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  101343. getLockstepMaxSteps(): number;
  101344. /**
  101345. * Sets hardware scaling, used to save performance if needed
  101346. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  101347. */
  101348. getHardwareScalingLevel(): number;
  101349. constructor(options?: NullEngineOptions);
  101350. createVertexBuffer(vertices: FloatArray): DataBuffer;
  101351. createIndexBuffer(indices: IndicesArray): DataBuffer;
  101352. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  101353. getRenderWidth(useScreen?: boolean): number;
  101354. getRenderHeight(useScreen?: boolean): number;
  101355. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  101356. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  101357. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  101358. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  101359. bindSamplers(effect: Effect): void;
  101360. enableEffect(effect: Effect): void;
  101361. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  101362. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  101363. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  101364. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  101365. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  101366. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  101367. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  101368. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  101369. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  101370. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  101371. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  101372. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  101373. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  101374. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  101375. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  101376. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  101377. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  101378. setFloat(uniform: WebGLUniformLocation, value: number): void;
  101379. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  101380. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  101381. setBool(uniform: WebGLUniformLocation, bool: number): void;
  101382. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  101383. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  101384. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  101385. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  101386. bindBuffers(vertexBuffers: {
  101387. [key: string]: VertexBuffer;
  101388. }, indexBuffer: DataBuffer, effect: Effect): void;
  101389. wipeCaches(bruteForce?: boolean): void;
  101390. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  101391. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  101392. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  101393. /** @hidden */
  101394. _createTexture(): WebGLTexture;
  101395. /** @hidden */
  101396. _releaseTexture(texture: InternalTexture): void;
  101397. 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;
  101398. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  101399. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  101400. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  101401. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  101402. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  101403. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  101404. areAllEffectsReady(): boolean;
  101405. /**
  101406. * @hidden
  101407. * Get the current error code of the webGL context
  101408. * @returns the error code
  101409. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  101410. */
  101411. getError(): number;
  101412. /** @hidden */
  101413. _getUnpackAlignement(): number;
  101414. /** @hidden */
  101415. _unpackFlipY(value: boolean): void;
  101416. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  101417. /**
  101418. * Updates a dynamic vertex buffer.
  101419. * @param vertexBuffer the vertex buffer to update
  101420. * @param data the data used to update the vertex buffer
  101421. * @param byteOffset the byte offset of the data (optional)
  101422. * @param byteLength the byte length of the data (optional)
  101423. */
  101424. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  101425. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  101426. /** @hidden */
  101427. _bindTexture(channel: number, texture: InternalTexture): void;
  101428. /** @hidden */
  101429. _releaseBuffer(buffer: DataBuffer): boolean;
  101430. releaseEffects(): void;
  101431. displayLoadingUI(): void;
  101432. hideLoadingUI(): void;
  101433. /** @hidden */
  101434. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  101435. /** @hidden */
  101436. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  101437. /** @hidden */
  101438. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  101439. /** @hidden */
  101440. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  101441. }
  101442. }
  101443. declare module BABYLON {
  101444. /** @hidden */
  101445. export class _OcclusionDataStorage {
  101446. /** @hidden */
  101447. occlusionInternalRetryCounter: number;
  101448. /** @hidden */
  101449. isOcclusionQueryInProgress: boolean;
  101450. /** @hidden */
  101451. isOccluded: boolean;
  101452. /** @hidden */
  101453. occlusionRetryCount: number;
  101454. /** @hidden */
  101455. occlusionType: number;
  101456. /** @hidden */
  101457. occlusionQueryAlgorithmType: number;
  101458. }
  101459. interface Engine {
  101460. /**
  101461. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  101462. * @return the new query
  101463. */
  101464. createQuery(): WebGLQuery;
  101465. /**
  101466. * Delete and release a webGL query
  101467. * @param query defines the query to delete
  101468. * @return the current engine
  101469. */
  101470. deleteQuery(query: WebGLQuery): Engine;
  101471. /**
  101472. * Check if a given query has resolved and got its value
  101473. * @param query defines the query to check
  101474. * @returns true if the query got its value
  101475. */
  101476. isQueryResultAvailable(query: WebGLQuery): boolean;
  101477. /**
  101478. * Gets the value of a given query
  101479. * @param query defines the query to check
  101480. * @returns the value of the query
  101481. */
  101482. getQueryResult(query: WebGLQuery): number;
  101483. /**
  101484. * Initiates an occlusion query
  101485. * @param algorithmType defines the algorithm to use
  101486. * @param query defines the query to use
  101487. * @returns the current engine
  101488. * @see http://doc.babylonjs.com/features/occlusionquery
  101489. */
  101490. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  101491. /**
  101492. * Ends an occlusion query
  101493. * @see http://doc.babylonjs.com/features/occlusionquery
  101494. * @param algorithmType defines the algorithm to use
  101495. * @returns the current engine
  101496. */
  101497. endOcclusionQuery(algorithmType: number): Engine;
  101498. /**
  101499. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  101500. * Please note that only one query can be issued at a time
  101501. * @returns a time token used to track the time span
  101502. */
  101503. startTimeQuery(): Nullable<_TimeToken>;
  101504. /**
  101505. * Ends a time query
  101506. * @param token defines the token used to measure the time span
  101507. * @returns the time spent (in ns)
  101508. */
  101509. endTimeQuery(token: _TimeToken): int;
  101510. /** @hidden */
  101511. _currentNonTimestampToken: Nullable<_TimeToken>;
  101512. /** @hidden */
  101513. _createTimeQuery(): WebGLQuery;
  101514. /** @hidden */
  101515. _deleteTimeQuery(query: WebGLQuery): void;
  101516. /** @hidden */
  101517. _getGlAlgorithmType(algorithmType: number): number;
  101518. /** @hidden */
  101519. _getTimeQueryResult(query: WebGLQuery): any;
  101520. /** @hidden */
  101521. _getTimeQueryAvailability(query: WebGLQuery): any;
  101522. }
  101523. interface AbstractMesh {
  101524. /**
  101525. * Backing filed
  101526. * @hidden
  101527. */
  101528. __occlusionDataStorage: _OcclusionDataStorage;
  101529. /**
  101530. * Access property
  101531. * @hidden
  101532. */
  101533. _occlusionDataStorage: _OcclusionDataStorage;
  101534. /**
  101535. * 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.
  101536. * The default value is -1 which means don't break the query and wait till the result
  101537. * @see http://doc.babylonjs.com/features/occlusionquery
  101538. */
  101539. occlusionRetryCount: number;
  101540. /**
  101541. * 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:
  101542. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  101543. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  101544. * * 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.
  101545. * @see http://doc.babylonjs.com/features/occlusionquery
  101546. */
  101547. occlusionType: number;
  101548. /**
  101549. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  101550. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  101551. * * 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.
  101552. * @see http://doc.babylonjs.com/features/occlusionquery
  101553. */
  101554. occlusionQueryAlgorithmType: number;
  101555. /**
  101556. * 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
  101557. * @see http://doc.babylonjs.com/features/occlusionquery
  101558. */
  101559. isOccluded: boolean;
  101560. /**
  101561. * Flag to check the progress status of the query
  101562. * @see http://doc.babylonjs.com/features/occlusionquery
  101563. */
  101564. isOcclusionQueryInProgress: boolean;
  101565. }
  101566. }
  101567. declare module BABYLON {
  101568. /** @hidden */
  101569. export var _forceTransformFeedbackToBundle: boolean;
  101570. interface Engine {
  101571. /**
  101572. * Creates a webGL transform feedback object
  101573. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  101574. * @returns the webGL transform feedback object
  101575. */
  101576. createTransformFeedback(): WebGLTransformFeedback;
  101577. /**
  101578. * Delete a webGL transform feedback object
  101579. * @param value defines the webGL transform feedback object to delete
  101580. */
  101581. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  101582. /**
  101583. * Bind a webGL transform feedback object to the webgl context
  101584. * @param value defines the webGL transform feedback object to bind
  101585. */
  101586. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  101587. /**
  101588. * Begins a transform feedback operation
  101589. * @param usePoints defines if points or triangles must be used
  101590. */
  101591. beginTransformFeedback(usePoints: boolean): void;
  101592. /**
  101593. * Ends a transform feedback operation
  101594. */
  101595. endTransformFeedback(): void;
  101596. /**
  101597. * Specify the varyings to use with transform feedback
  101598. * @param program defines the associated webGL program
  101599. * @param value defines the list of strings representing the varying names
  101600. */
  101601. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  101602. /**
  101603. * Bind a webGL buffer for a transform feedback operation
  101604. * @param value defines the webGL buffer to bind
  101605. */
  101606. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  101607. }
  101608. }
  101609. declare module BABYLON {
  101610. /**
  101611. * Creation options of the multi render target texture.
  101612. */
  101613. export interface IMultiRenderTargetOptions {
  101614. /**
  101615. * Define if the texture needs to create mip maps after render.
  101616. */
  101617. generateMipMaps?: boolean;
  101618. /**
  101619. * Define the types of all the draw buffers we want to create
  101620. */
  101621. types?: number[];
  101622. /**
  101623. * Define the sampling modes of all the draw buffers we want to create
  101624. */
  101625. samplingModes?: number[];
  101626. /**
  101627. * Define if a depth buffer is required
  101628. */
  101629. generateDepthBuffer?: boolean;
  101630. /**
  101631. * Define if a stencil buffer is required
  101632. */
  101633. generateStencilBuffer?: boolean;
  101634. /**
  101635. * Define if a depth texture is required instead of a depth buffer
  101636. */
  101637. generateDepthTexture?: boolean;
  101638. /**
  101639. * Define the number of desired draw buffers
  101640. */
  101641. textureCount?: number;
  101642. /**
  101643. * Define if aspect ratio should be adapted to the texture or stay the scene one
  101644. */
  101645. doNotChangeAspectRatio?: boolean;
  101646. /**
  101647. * Define the default type of the buffers we are creating
  101648. */
  101649. defaultType?: number;
  101650. }
  101651. /**
  101652. * A multi render target, like a render target provides the ability to render to a texture.
  101653. * Unlike the render target, it can render to several draw buffers in one draw.
  101654. * This is specially interesting in deferred rendering or for any effects requiring more than
  101655. * just one color from a single pass.
  101656. */
  101657. export class MultiRenderTarget extends RenderTargetTexture {
  101658. private _internalTextures;
  101659. private _textures;
  101660. private _multiRenderTargetOptions;
  101661. /**
  101662. * Get if draw buffers are currently supported by the used hardware and browser.
  101663. */
  101664. readonly isSupported: boolean;
  101665. /**
  101666. * Get the list of textures generated by the multi render target.
  101667. */
  101668. readonly textures: Texture[];
  101669. /**
  101670. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  101671. */
  101672. readonly depthTexture: Texture;
  101673. /**
  101674. * Set the wrapping mode on U of all the textures we are rendering to.
  101675. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  101676. */
  101677. wrapU: number;
  101678. /**
  101679. * Set the wrapping mode on V of all the textures we are rendering to.
  101680. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  101681. */
  101682. wrapV: number;
  101683. /**
  101684. * Instantiate a new multi render target texture.
  101685. * A multi render target, like a render target provides the ability to render to a texture.
  101686. * Unlike the render target, it can render to several draw buffers in one draw.
  101687. * This is specially interesting in deferred rendering or for any effects requiring more than
  101688. * just one color from a single pass.
  101689. * @param name Define the name of the texture
  101690. * @param size Define the size of the buffers to render to
  101691. * @param count Define the number of target we are rendering into
  101692. * @param scene Define the scene the texture belongs to
  101693. * @param options Define the options used to create the multi render target
  101694. */
  101695. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  101696. /** @hidden */
  101697. _rebuild(): void;
  101698. private _createInternalTextures;
  101699. private _createTextures;
  101700. /**
  101701. * Define the number of samples used if MSAA is enabled.
  101702. */
  101703. samples: number;
  101704. /**
  101705. * Resize all the textures in the multi render target.
  101706. * Be carrefull as it will recreate all the data in the new texture.
  101707. * @param size Define the new size
  101708. */
  101709. resize(size: any): void;
  101710. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  101711. /**
  101712. * Dispose the render targets and their associated resources
  101713. */
  101714. dispose(): void;
  101715. /**
  101716. * Release all the underlying texture used as draw buffers.
  101717. */
  101718. releaseInternalTextures(): void;
  101719. }
  101720. }
  101721. declare module BABYLON {
  101722. interface Engine {
  101723. /**
  101724. * Unbind a list of render target textures from the webGL context
  101725. * This is used only when drawBuffer extension or webGL2 are active
  101726. * @param textures defines the render target textures to unbind
  101727. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  101728. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  101729. */
  101730. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  101731. /**
  101732. * Create a multi render target texture
  101733. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  101734. * @param size defines the size of the texture
  101735. * @param options defines the creation options
  101736. * @returns the cube texture as an InternalTexture
  101737. */
  101738. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  101739. /**
  101740. * Update the sample count for a given multiple render target texture
  101741. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  101742. * @param textures defines the textures to update
  101743. * @param samples defines the sample count to set
  101744. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  101745. */
  101746. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  101747. }
  101748. }
  101749. declare module BABYLON {
  101750. /**
  101751. * Gather the list of clipboard event types as constants.
  101752. */
  101753. export class ClipboardEventTypes {
  101754. /**
  101755. * The clipboard event is fired when a copy command is active (pressed).
  101756. */
  101757. static readonly COPY: number;
  101758. /**
  101759. * The clipboard event is fired when a cut command is active (pressed).
  101760. */
  101761. static readonly CUT: number;
  101762. /**
  101763. * The clipboard event is fired when a paste command is active (pressed).
  101764. */
  101765. static readonly PASTE: number;
  101766. }
  101767. /**
  101768. * This class is used to store clipboard related info for the onClipboardObservable event.
  101769. */
  101770. export class ClipboardInfo {
  101771. /**
  101772. * Defines the type of event (BABYLON.ClipboardEventTypes)
  101773. */
  101774. type: number;
  101775. /**
  101776. * Defines the related dom event
  101777. */
  101778. event: ClipboardEvent;
  101779. /**
  101780. *Creates an instance of ClipboardInfo.
  101781. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  101782. * @param event Defines the related dom event
  101783. */
  101784. constructor(
  101785. /**
  101786. * Defines the type of event (BABYLON.ClipboardEventTypes)
  101787. */
  101788. type: number,
  101789. /**
  101790. * Defines the related dom event
  101791. */
  101792. event: ClipboardEvent);
  101793. /**
  101794. * Get the clipboard event's type from the keycode.
  101795. * @param keyCode Defines the keyCode for the current keyboard event.
  101796. * @return {number}
  101797. */
  101798. static GetTypeFromCharacter(keyCode: number): number;
  101799. }
  101800. }
  101801. declare module BABYLON {
  101802. /**
  101803. * Class used to represent data loading progression
  101804. */
  101805. export class SceneLoaderProgressEvent {
  101806. /** defines if data length to load can be evaluated */
  101807. readonly lengthComputable: boolean;
  101808. /** defines the loaded data length */
  101809. readonly loaded: number;
  101810. /** defines the data length to load */
  101811. readonly total: number;
  101812. /**
  101813. * Create a new progress event
  101814. * @param lengthComputable defines if data length to load can be evaluated
  101815. * @param loaded defines the loaded data length
  101816. * @param total defines the data length to load
  101817. */
  101818. constructor(
  101819. /** defines if data length to load can be evaluated */
  101820. lengthComputable: boolean,
  101821. /** defines the loaded data length */
  101822. loaded: number,
  101823. /** defines the data length to load */
  101824. total: number);
  101825. /**
  101826. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  101827. * @param event defines the source event
  101828. * @returns a new SceneLoaderProgressEvent
  101829. */
  101830. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  101831. }
  101832. /**
  101833. * Interface used by SceneLoader plugins to define supported file extensions
  101834. */
  101835. export interface ISceneLoaderPluginExtensions {
  101836. /**
  101837. * Defines the list of supported extensions
  101838. */
  101839. [extension: string]: {
  101840. isBinary: boolean;
  101841. };
  101842. }
  101843. /**
  101844. * Interface used by SceneLoader plugin factory
  101845. */
  101846. export interface ISceneLoaderPluginFactory {
  101847. /**
  101848. * Defines the name of the factory
  101849. */
  101850. name: string;
  101851. /**
  101852. * Function called to create a new plugin
  101853. * @return the new plugin
  101854. */
  101855. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  101856. /**
  101857. * Boolean indicating if the plugin can direct load specific data
  101858. */
  101859. canDirectLoad?: (data: string) => boolean;
  101860. }
  101861. /**
  101862. * Interface used to define a SceneLoader plugin
  101863. */
  101864. export interface ISceneLoaderPlugin {
  101865. /**
  101866. * The friendly name of this plugin.
  101867. */
  101868. name: string;
  101869. /**
  101870. * The file extensions supported by this plugin.
  101871. */
  101872. extensions: string | ISceneLoaderPluginExtensions;
  101873. /**
  101874. * Import meshes into a scene.
  101875. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  101876. * @param scene The scene to import into
  101877. * @param data The data to import
  101878. * @param rootUrl The root url for scene and resources
  101879. * @param meshes The meshes array to import into
  101880. * @param particleSystems The particle systems array to import into
  101881. * @param skeletons The skeletons array to import into
  101882. * @param onError The callback when import fails
  101883. * @returns True if successful or false otherwise
  101884. */
  101885. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  101886. /**
  101887. * Load into a scene.
  101888. * @param scene The scene to load into
  101889. * @param data The data to import
  101890. * @param rootUrl The root url for scene and resources
  101891. * @param onError The callback when import fails
  101892. * @returns true if successful or false otherwise
  101893. */
  101894. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  101895. /**
  101896. * The callback that returns true if the data can be directly loaded.
  101897. */
  101898. canDirectLoad?: (data: string) => boolean;
  101899. /**
  101900. * The callback that allows custom handling of the root url based on the response url.
  101901. */
  101902. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  101903. /**
  101904. * Load into an asset container.
  101905. * @param scene The scene to load into
  101906. * @param data The data to import
  101907. * @param rootUrl The root url for scene and resources
  101908. * @param onError The callback when import fails
  101909. * @returns The loaded asset container
  101910. */
  101911. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  101912. }
  101913. /**
  101914. * Interface used to define an async SceneLoader plugin
  101915. */
  101916. export interface ISceneLoaderPluginAsync {
  101917. /**
  101918. * The friendly name of this plugin.
  101919. */
  101920. name: string;
  101921. /**
  101922. * The file extensions supported by this plugin.
  101923. */
  101924. extensions: string | ISceneLoaderPluginExtensions;
  101925. /**
  101926. * Import meshes into a scene.
  101927. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  101928. * @param scene The scene to import into
  101929. * @param data The data to import
  101930. * @param rootUrl The root url for scene and resources
  101931. * @param onProgress The callback when the load progresses
  101932. * @param fileName Defines the name of the file to load
  101933. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  101934. */
  101935. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  101936. meshes: AbstractMesh[];
  101937. particleSystems: IParticleSystem[];
  101938. skeletons: Skeleton[];
  101939. animationGroups: AnimationGroup[];
  101940. }>;
  101941. /**
  101942. * Load into a scene.
  101943. * @param scene The scene to load into
  101944. * @param data The data to import
  101945. * @param rootUrl The root url for scene and resources
  101946. * @param onProgress The callback when the load progresses
  101947. * @param fileName Defines the name of the file to load
  101948. * @returns Nothing
  101949. */
  101950. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  101951. /**
  101952. * The callback that returns true if the data can be directly loaded.
  101953. */
  101954. canDirectLoad?: (data: string) => boolean;
  101955. /**
  101956. * The callback that allows custom handling of the root url based on the response url.
  101957. */
  101958. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  101959. /**
  101960. * Load into an asset container.
  101961. * @param scene The scene to load into
  101962. * @param data The data to import
  101963. * @param rootUrl The root url for scene and resources
  101964. * @param onProgress The callback when the load progresses
  101965. * @param fileName Defines the name of the file to load
  101966. * @returns The loaded asset container
  101967. */
  101968. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  101969. }
  101970. /**
  101971. * Class used to load scene from various file formats using registered plugins
  101972. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  101973. */
  101974. export class SceneLoader {
  101975. /**
  101976. * No logging while loading
  101977. */
  101978. static readonly NO_LOGGING: number;
  101979. /**
  101980. * Minimal logging while loading
  101981. */
  101982. static readonly MINIMAL_LOGGING: number;
  101983. /**
  101984. * Summary logging while loading
  101985. */
  101986. static readonly SUMMARY_LOGGING: number;
  101987. /**
  101988. * Detailled logging while loading
  101989. */
  101990. static readonly DETAILED_LOGGING: number;
  101991. /**
  101992. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  101993. */
  101994. static ForceFullSceneLoadingForIncremental: boolean;
  101995. /**
  101996. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  101997. */
  101998. static ShowLoadingScreen: boolean;
  101999. /**
  102000. * Defines the current logging level (while loading the scene)
  102001. * @ignorenaming
  102002. */
  102003. static loggingLevel: number;
  102004. /**
  102005. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  102006. */
  102007. static CleanBoneMatrixWeights: boolean;
  102008. /**
  102009. * Event raised when a plugin is used to load a scene
  102010. */
  102011. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  102012. private static _registeredPlugins;
  102013. private static _getDefaultPlugin;
  102014. private static _getPluginForExtension;
  102015. private static _getPluginForDirectLoad;
  102016. private static _getPluginForFilename;
  102017. private static _getDirectLoad;
  102018. private static _loadData;
  102019. private static _getFileInfo;
  102020. /**
  102021. * Gets a plugin that can load the given extension
  102022. * @param extension defines the extension to load
  102023. * @returns a plugin or null if none works
  102024. */
  102025. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  102026. /**
  102027. * Gets a boolean indicating that the given extension can be loaded
  102028. * @param extension defines the extension to load
  102029. * @returns true if the extension is supported
  102030. */
  102031. static IsPluginForExtensionAvailable(extension: string): boolean;
  102032. /**
  102033. * Adds a new plugin to the list of registered plugins
  102034. * @param plugin defines the plugin to add
  102035. */
  102036. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  102037. /**
  102038. * Import meshes into a scene
  102039. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  102040. * @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)
  102041. * @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)
  102042. * @param scene the instance of BABYLON.Scene to append to
  102043. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  102044. * @param onProgress a callback with a progress event for each file being loaded
  102045. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  102046. * @param pluginExtension the extension used to determine the plugin
  102047. * @returns The loaded plugin
  102048. */
  102049. 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>;
  102050. /**
  102051. * Import meshes into a scene
  102052. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  102053. * @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)
  102054. * @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)
  102055. * @param scene the instance of BABYLON.Scene to append to
  102056. * @param onProgress a callback with a progress event for each file being loaded
  102057. * @param pluginExtension the extension used to determine the plugin
  102058. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  102059. */
  102060. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  102061. meshes: AbstractMesh[];
  102062. particleSystems: IParticleSystem[];
  102063. skeletons: Skeleton[];
  102064. animationGroups: AnimationGroup[];
  102065. }>;
  102066. /**
  102067. * Load a scene
  102068. * @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)
  102069. * @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)
  102070. * @param engine is the instance of BABYLON.Engine to use to create the scene
  102071. * @param onSuccess a callback with the scene when import succeeds
  102072. * @param onProgress a callback with a progress event for each file being loaded
  102073. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  102074. * @param pluginExtension the extension used to determine the plugin
  102075. * @returns The loaded plugin
  102076. */
  102077. 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>;
  102078. /**
  102079. * Load a scene
  102080. * @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)
  102081. * @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)
  102082. * @param engine is the instance of BABYLON.Engine to use to create the scene
  102083. * @param onProgress a callback with a progress event for each file being loaded
  102084. * @param pluginExtension the extension used to determine the plugin
  102085. * @returns The loaded scene
  102086. */
  102087. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  102088. /**
  102089. * Append a scene
  102090. * @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)
  102091. * @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)
  102092. * @param scene is the instance of BABYLON.Scene to append to
  102093. * @param onSuccess a callback with the scene when import succeeds
  102094. * @param onProgress a callback with a progress event for each file being loaded
  102095. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  102096. * @param pluginExtension the extension used to determine the plugin
  102097. * @returns The loaded plugin
  102098. */
  102099. 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>;
  102100. /**
  102101. * Append a scene
  102102. * @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)
  102103. * @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)
  102104. * @param scene is the instance of BABYLON.Scene to append to
  102105. * @param onProgress a callback with a progress event for each file being loaded
  102106. * @param pluginExtension the extension used to determine the plugin
  102107. * @returns The given scene
  102108. */
  102109. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  102110. /**
  102111. * Load a scene into an asset container
  102112. * @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)
  102113. * @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)
  102114. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  102115. * @param onSuccess a callback with the scene when import succeeds
  102116. * @param onProgress a callback with a progress event for each file being loaded
  102117. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  102118. * @param pluginExtension the extension used to determine the plugin
  102119. * @returns The loaded plugin
  102120. */
  102121. 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>;
  102122. /**
  102123. * Load a scene into an asset container
  102124. * @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)
  102125. * @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)
  102126. * @param scene is the instance of Scene to append to
  102127. * @param onProgress a callback with a progress event for each file being loaded
  102128. * @param pluginExtension the extension used to determine the plugin
  102129. * @returns The loaded asset container
  102130. */
  102131. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  102132. }
  102133. }
  102134. declare module BABYLON {
  102135. /**
  102136. * Google Daydream controller
  102137. */
  102138. export class DaydreamController extends WebVRController {
  102139. /**
  102140. * Base Url for the controller model.
  102141. */
  102142. static MODEL_BASE_URL: string;
  102143. /**
  102144. * File name for the controller model.
  102145. */
  102146. static MODEL_FILENAME: string;
  102147. /**
  102148. * Gamepad Id prefix used to identify Daydream Controller.
  102149. */
  102150. static readonly GAMEPAD_ID_PREFIX: string;
  102151. /**
  102152. * Creates a new DaydreamController from a gamepad
  102153. * @param vrGamepad the gamepad that the controller should be created from
  102154. */
  102155. constructor(vrGamepad: any);
  102156. /**
  102157. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  102158. * @param scene scene in which to add meshes
  102159. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  102160. */
  102161. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  102162. /**
  102163. * Called once for each button that changed state since the last frame
  102164. * @param buttonIdx Which button index changed
  102165. * @param state New state of the button
  102166. * @param changes Which properties on the state changed since last frame
  102167. */
  102168. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  102169. }
  102170. }
  102171. declare module BABYLON {
  102172. /**
  102173. * Gear VR Controller
  102174. */
  102175. export class GearVRController extends WebVRController {
  102176. /**
  102177. * Base Url for the controller model.
  102178. */
  102179. static MODEL_BASE_URL: string;
  102180. /**
  102181. * File name for the controller model.
  102182. */
  102183. static MODEL_FILENAME: string;
  102184. /**
  102185. * Gamepad Id prefix used to identify this controller.
  102186. */
  102187. static readonly GAMEPAD_ID_PREFIX: string;
  102188. private readonly _buttonIndexToObservableNameMap;
  102189. /**
  102190. * Creates a new GearVRController from a gamepad
  102191. * @param vrGamepad the gamepad that the controller should be created from
  102192. */
  102193. constructor(vrGamepad: any);
  102194. /**
  102195. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  102196. * @param scene scene in which to add meshes
  102197. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  102198. */
  102199. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  102200. /**
  102201. * Called once for each button that changed state since the last frame
  102202. * @param buttonIdx Which button index changed
  102203. * @param state New state of the button
  102204. * @param changes Which properties on the state changed since last frame
  102205. */
  102206. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  102207. }
  102208. }
  102209. declare module BABYLON {
  102210. /**
  102211. * Generic Controller
  102212. */
  102213. export class GenericController extends WebVRController {
  102214. /**
  102215. * Base Url for the controller model.
  102216. */
  102217. static readonly MODEL_BASE_URL: string;
  102218. /**
  102219. * File name for the controller model.
  102220. */
  102221. static readonly MODEL_FILENAME: string;
  102222. /**
  102223. * Creates a new GenericController from a gamepad
  102224. * @param vrGamepad the gamepad that the controller should be created from
  102225. */
  102226. constructor(vrGamepad: any);
  102227. /**
  102228. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  102229. * @param scene scene in which to add meshes
  102230. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  102231. */
  102232. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  102233. /**
  102234. * Called once for each button that changed state since the last frame
  102235. * @param buttonIdx Which button index changed
  102236. * @param state New state of the button
  102237. * @param changes Which properties on the state changed since last frame
  102238. */
  102239. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  102240. }
  102241. }
  102242. declare module BABYLON {
  102243. /**
  102244. * Oculus Touch Controller
  102245. */
  102246. export class OculusTouchController extends WebVRController {
  102247. /**
  102248. * Base Url for the controller model.
  102249. */
  102250. static MODEL_BASE_URL: string;
  102251. /**
  102252. * File name for the left controller model.
  102253. */
  102254. static MODEL_LEFT_FILENAME: string;
  102255. /**
  102256. * File name for the right controller model.
  102257. */
  102258. static MODEL_RIGHT_FILENAME: string;
  102259. /**
  102260. * Fired when the secondary trigger on this controller is modified
  102261. */
  102262. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  102263. /**
  102264. * Fired when the thumb rest on this controller is modified
  102265. */
  102266. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  102267. /**
  102268. * Creates a new OculusTouchController from a gamepad
  102269. * @param vrGamepad the gamepad that the controller should be created from
  102270. */
  102271. constructor(vrGamepad: any);
  102272. /**
  102273. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  102274. * @param scene scene in which to add meshes
  102275. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  102276. */
  102277. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  102278. /**
  102279. * Fired when the A button on this controller is modified
  102280. */
  102281. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102282. /**
  102283. * Fired when the B button on this controller is modified
  102284. */
  102285. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102286. /**
  102287. * Fired when the X button on this controller is modified
  102288. */
  102289. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102290. /**
  102291. * Fired when the Y button on this controller is modified
  102292. */
  102293. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102294. /**
  102295. * Called once for each button that changed state since the last frame
  102296. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  102297. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  102298. * 2) secondary trigger (same)
  102299. * 3) A (right) X (left), touch, pressed = value
  102300. * 4) B / Y
  102301. * 5) thumb rest
  102302. * @param buttonIdx Which button index changed
  102303. * @param state New state of the button
  102304. * @param changes Which properties on the state changed since last frame
  102305. */
  102306. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  102307. }
  102308. }
  102309. declare module BABYLON {
  102310. /**
  102311. * Vive Controller
  102312. */
  102313. export class ViveController extends WebVRController {
  102314. /**
  102315. * Base Url for the controller model.
  102316. */
  102317. static MODEL_BASE_URL: string;
  102318. /**
  102319. * File name for the controller model.
  102320. */
  102321. static MODEL_FILENAME: string;
  102322. /**
  102323. * Creates a new ViveController from a gamepad
  102324. * @param vrGamepad the gamepad that the controller should be created from
  102325. */
  102326. constructor(vrGamepad: any);
  102327. /**
  102328. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  102329. * @param scene scene in which to add meshes
  102330. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  102331. */
  102332. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  102333. /**
  102334. * Fired when the left button on this controller is modified
  102335. */
  102336. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102337. /**
  102338. * Fired when the right button on this controller is modified
  102339. */
  102340. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102341. /**
  102342. * Fired when the menu button on this controller is modified
  102343. */
  102344. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102345. /**
  102346. * Called once for each button that changed state since the last frame
  102347. * Vive mapping:
  102348. * 0: touchpad
  102349. * 1: trigger
  102350. * 2: left AND right buttons
  102351. * 3: menu button
  102352. * @param buttonIdx Which button index changed
  102353. * @param state New state of the button
  102354. * @param changes Which properties on the state changed since last frame
  102355. */
  102356. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  102357. }
  102358. }
  102359. declare module BABYLON {
  102360. /**
  102361. * Defines the WindowsMotionController object that the state of the windows motion controller
  102362. */
  102363. export class WindowsMotionController extends WebVRController {
  102364. /**
  102365. * The base url used to load the left and right controller models
  102366. */
  102367. static MODEL_BASE_URL: string;
  102368. /**
  102369. * The name of the left controller model file
  102370. */
  102371. static MODEL_LEFT_FILENAME: string;
  102372. /**
  102373. * The name of the right controller model file
  102374. */
  102375. static MODEL_RIGHT_FILENAME: string;
  102376. /**
  102377. * The controller name prefix for this controller type
  102378. */
  102379. static readonly GAMEPAD_ID_PREFIX: string;
  102380. /**
  102381. * The controller id pattern for this controller type
  102382. */
  102383. private static readonly GAMEPAD_ID_PATTERN;
  102384. private _loadedMeshInfo;
  102385. private readonly _mapping;
  102386. /**
  102387. * Fired when the trackpad on this controller is clicked
  102388. */
  102389. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  102390. /**
  102391. * Fired when the trackpad on this controller is modified
  102392. */
  102393. onTrackpadValuesChangedObservable: Observable<StickValues>;
  102394. /**
  102395. * The current x and y values of this controller's trackpad
  102396. */
  102397. trackpad: StickValues;
  102398. /**
  102399. * Creates a new WindowsMotionController from a gamepad
  102400. * @param vrGamepad the gamepad that the controller should be created from
  102401. */
  102402. constructor(vrGamepad: any);
  102403. /**
  102404. * Fired when the trigger on this controller is modified
  102405. */
  102406. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102407. /**
  102408. * Fired when the menu button on this controller is modified
  102409. */
  102410. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102411. /**
  102412. * Fired when the grip button on this controller is modified
  102413. */
  102414. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102415. /**
  102416. * Fired when the thumbstick button on this controller is modified
  102417. */
  102418. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102419. /**
  102420. * Fired when the touchpad button on this controller is modified
  102421. */
  102422. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102423. /**
  102424. * Fired when the touchpad values on this controller are modified
  102425. */
  102426. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  102427. private _updateTrackpad;
  102428. /**
  102429. * Called once per frame by the engine.
  102430. */
  102431. update(): void;
  102432. /**
  102433. * Called once for each button that changed state since the last frame
  102434. * @param buttonIdx Which button index changed
  102435. * @param state New state of the button
  102436. * @param changes Which properties on the state changed since last frame
  102437. */
  102438. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  102439. /**
  102440. * Moves the buttons on the controller mesh based on their current state
  102441. * @param buttonName the name of the button to move
  102442. * @param buttonValue the value of the button which determines the buttons new position
  102443. */
  102444. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  102445. /**
  102446. * Moves the axis on the controller mesh based on its current state
  102447. * @param axis the index of the axis
  102448. * @param axisValue the value of the axis which determines the meshes new position
  102449. * @hidden
  102450. */
  102451. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  102452. /**
  102453. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  102454. * @param scene scene in which to add meshes
  102455. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  102456. */
  102457. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  102458. /**
  102459. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  102460. * can be transformed by button presses and axes values, based on this._mapping.
  102461. *
  102462. * @param scene scene in which the meshes exist
  102463. * @param meshes list of meshes that make up the controller model to process
  102464. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  102465. */
  102466. private processModel;
  102467. private createMeshInfo;
  102468. /**
  102469. * Gets the ray of the controller in the direction the controller is pointing
  102470. * @param length the length the resulting ray should be
  102471. * @returns a ray in the direction the controller is pointing
  102472. */
  102473. getForwardRay(length?: number): Ray;
  102474. /**
  102475. * Disposes of the controller
  102476. */
  102477. dispose(): void;
  102478. }
  102479. }
  102480. declare module BABYLON {
  102481. /**
  102482. * Single axis scale gizmo
  102483. */
  102484. export class AxisScaleGizmo extends Gizmo {
  102485. private _coloredMaterial;
  102486. /**
  102487. * Drag behavior responsible for the gizmos dragging interactions
  102488. */
  102489. dragBehavior: PointerDragBehavior;
  102490. private _pointerObserver;
  102491. /**
  102492. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  102493. */
  102494. snapDistance: number;
  102495. /**
  102496. * Event that fires each time the gizmo snaps to a new location.
  102497. * * snapDistance is the the change in distance
  102498. */
  102499. onSnapObservable: Observable<{
  102500. snapDistance: number;
  102501. }>;
  102502. /**
  102503. * If the scaling operation should be done on all axis (default: false)
  102504. */
  102505. uniformScaling: boolean;
  102506. /**
  102507. * Creates an AxisScaleGizmo
  102508. * @param gizmoLayer The utility layer the gizmo will be added to
  102509. * @param dragAxis The axis which the gizmo will be able to scale on
  102510. * @param color The color of the gizmo
  102511. */
  102512. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  102513. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  102514. /**
  102515. * Disposes of the gizmo
  102516. */
  102517. dispose(): void;
  102518. /**
  102519. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  102520. * @param mesh The mesh to replace the default mesh of the gizmo
  102521. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  102522. */
  102523. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  102524. }
  102525. }
  102526. declare module BABYLON {
  102527. /**
  102528. * Bounding box gizmo
  102529. */
  102530. export class BoundingBoxGizmo extends Gizmo {
  102531. private _lineBoundingBox;
  102532. private _rotateSpheresParent;
  102533. private _scaleBoxesParent;
  102534. private _boundingDimensions;
  102535. private _renderObserver;
  102536. private _pointerObserver;
  102537. private _scaleDragSpeed;
  102538. private _tmpQuaternion;
  102539. private _tmpVector;
  102540. private _tmpRotationMatrix;
  102541. /**
  102542. * 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)
  102543. */
  102544. ignoreChildren: boolean;
  102545. /**
  102546. * 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)
  102547. */
  102548. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  102549. /**
  102550. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  102551. */
  102552. rotationSphereSize: number;
  102553. /**
  102554. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  102555. */
  102556. scaleBoxSize: number;
  102557. /**
  102558. * 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)
  102559. */
  102560. fixedDragMeshScreenSize: boolean;
  102561. /**
  102562. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  102563. */
  102564. fixedDragMeshScreenSizeDistanceFactor: number;
  102565. /**
  102566. * Fired when a rotation sphere or scale box is dragged
  102567. */
  102568. onDragStartObservable: Observable<{}>;
  102569. /**
  102570. * Fired when a scale box is dragged
  102571. */
  102572. onScaleBoxDragObservable: Observable<{}>;
  102573. /**
  102574. * Fired when a scale box drag is ended
  102575. */
  102576. onScaleBoxDragEndObservable: Observable<{}>;
  102577. /**
  102578. * Fired when a rotation sphere is dragged
  102579. */
  102580. onRotationSphereDragObservable: Observable<{}>;
  102581. /**
  102582. * Fired when a rotation sphere drag is ended
  102583. */
  102584. onRotationSphereDragEndObservable: Observable<{}>;
  102585. /**
  102586. * 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)
  102587. */
  102588. scalePivot: Nullable<Vector3>;
  102589. /**
  102590. * Mesh used as a pivot to rotate the attached mesh
  102591. */
  102592. private _anchorMesh;
  102593. private _existingMeshScale;
  102594. private _dragMesh;
  102595. private pointerDragBehavior;
  102596. private coloredMaterial;
  102597. private hoverColoredMaterial;
  102598. /**
  102599. * Sets the color of the bounding box gizmo
  102600. * @param color the color to set
  102601. */
  102602. setColor(color: Color3): void;
  102603. /**
  102604. * Creates an BoundingBoxGizmo
  102605. * @param gizmoLayer The utility layer the gizmo will be added to
  102606. * @param color The color of the gizmo
  102607. */
  102608. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  102609. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  102610. private _selectNode;
  102611. /**
  102612. * Updates the bounding box information for the Gizmo
  102613. */
  102614. updateBoundingBox(): void;
  102615. private _updateRotationSpheres;
  102616. private _updateScaleBoxes;
  102617. /**
  102618. * Enables rotation on the specified axis and disables rotation on the others
  102619. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  102620. */
  102621. setEnabledRotationAxis(axis: string): void;
  102622. /**
  102623. * Enables/disables scaling
  102624. * @param enable if scaling should be enabled
  102625. */
  102626. setEnabledScaling(enable: boolean): void;
  102627. private _updateDummy;
  102628. /**
  102629. * Enables a pointer drag behavior on the bounding box of the gizmo
  102630. */
  102631. enableDragBehavior(): void;
  102632. /**
  102633. * Disposes of the gizmo
  102634. */
  102635. dispose(): void;
  102636. /**
  102637. * 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)
  102638. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  102639. * @returns the bounding box mesh with the passed in mesh as a child
  102640. */
  102641. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  102642. /**
  102643. * CustomMeshes are not supported by this gizmo
  102644. * @param mesh The mesh to replace the default mesh of the gizmo
  102645. */
  102646. setCustomMesh(mesh: Mesh): void;
  102647. }
  102648. }
  102649. declare module BABYLON {
  102650. /**
  102651. * Single plane rotation gizmo
  102652. */
  102653. export class PlaneRotationGizmo extends Gizmo {
  102654. /**
  102655. * Drag behavior responsible for the gizmos dragging interactions
  102656. */
  102657. dragBehavior: PointerDragBehavior;
  102658. private _pointerObserver;
  102659. /**
  102660. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  102661. */
  102662. snapDistance: number;
  102663. /**
  102664. * Event that fires each time the gizmo snaps to a new location.
  102665. * * snapDistance is the the change in distance
  102666. */
  102667. onSnapObservable: Observable<{
  102668. snapDistance: number;
  102669. }>;
  102670. /**
  102671. * Creates a PlaneRotationGizmo
  102672. * @param gizmoLayer The utility layer the gizmo will be added to
  102673. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  102674. * @param color The color of the gizmo
  102675. * @param tessellation Amount of tessellation to be used when creating rotation circles
  102676. */
  102677. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  102678. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  102679. /**
  102680. * Disposes of the gizmo
  102681. */
  102682. dispose(): void;
  102683. }
  102684. }
  102685. declare module BABYLON {
  102686. /**
  102687. * Gizmo that enables rotating a mesh along 3 axis
  102688. */
  102689. export class RotationGizmo extends Gizmo {
  102690. /**
  102691. * Internal gizmo used for interactions on the x axis
  102692. */
  102693. xGizmo: PlaneRotationGizmo;
  102694. /**
  102695. * Internal gizmo used for interactions on the y axis
  102696. */
  102697. yGizmo: PlaneRotationGizmo;
  102698. /**
  102699. * Internal gizmo used for interactions on the z axis
  102700. */
  102701. zGizmo: PlaneRotationGizmo;
  102702. /** Fires an event when any of it's sub gizmos are dragged */
  102703. onDragStartObservable: Observable<{}>;
  102704. /** Fires an event when any of it's sub gizmos are released from dragging */
  102705. onDragEndObservable: Observable<{}>;
  102706. attachedMesh: Nullable<AbstractMesh>;
  102707. /**
  102708. * Creates a RotationGizmo
  102709. * @param gizmoLayer The utility layer the gizmo will be added to
  102710. * @param tessellation Amount of tessellation to be used when creating rotation circles
  102711. */
  102712. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  102713. updateGizmoRotationToMatchAttachedMesh: boolean;
  102714. /**
  102715. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  102716. */
  102717. snapDistance: number;
  102718. /**
  102719. * Ratio for the scale of the gizmo (Default: 1)
  102720. */
  102721. scaleRatio: number;
  102722. /**
  102723. * Disposes of the gizmo
  102724. */
  102725. dispose(): void;
  102726. /**
  102727. * CustomMeshes are not supported by this gizmo
  102728. * @param mesh The mesh to replace the default mesh of the gizmo
  102729. */
  102730. setCustomMesh(mesh: Mesh): void;
  102731. }
  102732. }
  102733. declare module BABYLON {
  102734. /**
  102735. * Gizmo that enables dragging a mesh along 3 axis
  102736. */
  102737. export class PositionGizmo extends Gizmo {
  102738. /**
  102739. * Internal gizmo used for interactions on the x axis
  102740. */
  102741. xGizmo: AxisDragGizmo;
  102742. /**
  102743. * Internal gizmo used for interactions on the y axis
  102744. */
  102745. yGizmo: AxisDragGizmo;
  102746. /**
  102747. * Internal gizmo used for interactions on the z axis
  102748. */
  102749. zGizmo: AxisDragGizmo;
  102750. /** Fires an event when any of it's sub gizmos are dragged */
  102751. onDragStartObservable: Observable<{}>;
  102752. /** Fires an event when any of it's sub gizmos are released from dragging */
  102753. onDragEndObservable: Observable<{}>;
  102754. attachedMesh: Nullable<AbstractMesh>;
  102755. /**
  102756. * Creates a PositionGizmo
  102757. * @param gizmoLayer The utility layer the gizmo will be added to
  102758. */
  102759. constructor(gizmoLayer?: UtilityLayerRenderer);
  102760. updateGizmoRotationToMatchAttachedMesh: boolean;
  102761. /**
  102762. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  102763. */
  102764. snapDistance: number;
  102765. /**
  102766. * Ratio for the scale of the gizmo (Default: 1)
  102767. */
  102768. scaleRatio: number;
  102769. /**
  102770. * Disposes of the gizmo
  102771. */
  102772. dispose(): void;
  102773. /**
  102774. * CustomMeshes are not supported by this gizmo
  102775. * @param mesh The mesh to replace the default mesh of the gizmo
  102776. */
  102777. setCustomMesh(mesh: Mesh): void;
  102778. }
  102779. }
  102780. declare module BABYLON {
  102781. /**
  102782. * Class containing static functions to help procedurally build meshes
  102783. */
  102784. export class PolyhedronBuilder {
  102785. /**
  102786. * Creates a polyhedron mesh
  102787. * * 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
  102788. * * The parameter `size` (positive float, default 1) sets the polygon size
  102789. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  102790. * * 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`
  102791. * * 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
  102792. * * 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)`)
  102793. * * 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
  102794. * * 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
  102795. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  102796. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  102797. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  102798. * @param name defines the name of the mesh
  102799. * @param options defines the options used to create the mesh
  102800. * @param scene defines the hosting scene
  102801. * @returns the polyhedron mesh
  102802. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  102803. */
  102804. static CreatePolyhedron(name: string, options: {
  102805. type?: number;
  102806. size?: number;
  102807. sizeX?: number;
  102808. sizeY?: number;
  102809. sizeZ?: number;
  102810. custom?: any;
  102811. faceUV?: Vector4[];
  102812. faceColors?: Color4[];
  102813. flat?: boolean;
  102814. updatable?: boolean;
  102815. sideOrientation?: number;
  102816. frontUVs?: Vector4;
  102817. backUVs?: Vector4;
  102818. }, scene?: Nullable<Scene>): Mesh;
  102819. }
  102820. }
  102821. declare module BABYLON {
  102822. /**
  102823. * Gizmo that enables scaling a mesh along 3 axis
  102824. */
  102825. export class ScaleGizmo extends Gizmo {
  102826. /**
  102827. * Internal gizmo used for interactions on the x axis
  102828. */
  102829. xGizmo: AxisScaleGizmo;
  102830. /**
  102831. * Internal gizmo used for interactions on the y axis
  102832. */
  102833. yGizmo: AxisScaleGizmo;
  102834. /**
  102835. * Internal gizmo used for interactions on the z axis
  102836. */
  102837. zGizmo: AxisScaleGizmo;
  102838. /**
  102839. * Internal gizmo used to scale all axis equally
  102840. */
  102841. uniformScaleGizmo: AxisScaleGizmo;
  102842. /** Fires an event when any of it's sub gizmos are dragged */
  102843. onDragStartObservable: Observable<{}>;
  102844. /** Fires an event when any of it's sub gizmos are released from dragging */
  102845. onDragEndObservable: Observable<{}>;
  102846. attachedMesh: Nullable<AbstractMesh>;
  102847. /**
  102848. * Creates a ScaleGizmo
  102849. * @param gizmoLayer The utility layer the gizmo will be added to
  102850. */
  102851. constructor(gizmoLayer?: UtilityLayerRenderer);
  102852. updateGizmoRotationToMatchAttachedMesh: boolean;
  102853. /**
  102854. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  102855. */
  102856. snapDistance: number;
  102857. /**
  102858. * Ratio for the scale of the gizmo (Default: 1)
  102859. */
  102860. scaleRatio: number;
  102861. /**
  102862. * Disposes of the gizmo
  102863. */
  102864. dispose(): void;
  102865. }
  102866. }
  102867. declare module BABYLON {
  102868. /**
  102869. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  102870. */
  102871. export class GizmoManager implements IDisposable {
  102872. private scene;
  102873. /**
  102874. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  102875. */
  102876. gizmos: {
  102877. positionGizmo: Nullable<PositionGizmo>;
  102878. rotationGizmo: Nullable<RotationGizmo>;
  102879. scaleGizmo: Nullable<ScaleGizmo>;
  102880. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  102881. };
  102882. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  102883. clearGizmoOnEmptyPointerEvent: boolean;
  102884. /** Fires an event when the manager is attached to a mesh */
  102885. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  102886. private _gizmosEnabled;
  102887. private _pointerObserver;
  102888. private _attachedMesh;
  102889. private _boundingBoxColor;
  102890. private _defaultUtilityLayer;
  102891. private _defaultKeepDepthUtilityLayer;
  102892. /**
  102893. * When bounding box gizmo is enabled, this can be used to track drag/end events
  102894. */
  102895. boundingBoxDragBehavior: SixDofDragBehavior;
  102896. /**
  102897. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  102898. */
  102899. attachableMeshes: Nullable<Array<AbstractMesh>>;
  102900. /**
  102901. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  102902. */
  102903. usePointerToAttachGizmos: boolean;
  102904. /**
  102905. * Instatiates a gizmo manager
  102906. * @param scene the scene to overlay the gizmos on top of
  102907. */
  102908. constructor(scene: Scene);
  102909. /**
  102910. * Attaches a set of gizmos to the specified mesh
  102911. * @param mesh The mesh the gizmo's should be attached to
  102912. */
  102913. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  102914. /**
  102915. * If the position gizmo is enabled
  102916. */
  102917. positionGizmoEnabled: boolean;
  102918. /**
  102919. * If the rotation gizmo is enabled
  102920. */
  102921. rotationGizmoEnabled: boolean;
  102922. /**
  102923. * If the scale gizmo is enabled
  102924. */
  102925. scaleGizmoEnabled: boolean;
  102926. /**
  102927. * If the boundingBox gizmo is enabled
  102928. */
  102929. boundingBoxGizmoEnabled: boolean;
  102930. /**
  102931. * Disposes of the gizmo manager
  102932. */
  102933. dispose(): void;
  102934. }
  102935. }
  102936. declare module BABYLON {
  102937. /**
  102938. * A directional light is defined by a direction (what a surprise!).
  102939. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  102940. * 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.
  102941. * Documentation: https://doc.babylonjs.com/babylon101/lights
  102942. */
  102943. export class DirectionalLight extends ShadowLight {
  102944. private _shadowFrustumSize;
  102945. /**
  102946. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  102947. */
  102948. /**
  102949. * Specifies a fix frustum size for the shadow generation.
  102950. */
  102951. shadowFrustumSize: number;
  102952. private _shadowOrthoScale;
  102953. /**
  102954. * Gets the shadow projection scale against the optimal computed one.
  102955. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  102956. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  102957. */
  102958. /**
  102959. * Sets the shadow projection scale against the optimal computed one.
  102960. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  102961. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  102962. */
  102963. shadowOrthoScale: number;
  102964. /**
  102965. * Automatically compute the projection matrix to best fit (including all the casters)
  102966. * on each frame.
  102967. */
  102968. autoUpdateExtends: boolean;
  102969. private _orthoLeft;
  102970. private _orthoRight;
  102971. private _orthoTop;
  102972. private _orthoBottom;
  102973. /**
  102974. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  102975. * The directional light is emitted from everywhere in the given direction.
  102976. * It can cast shadows.
  102977. * Documentation : https://doc.babylonjs.com/babylon101/lights
  102978. * @param name The friendly name of the light
  102979. * @param direction The direction of the light
  102980. * @param scene The scene the light belongs to
  102981. */
  102982. constructor(name: string, direction: Vector3, scene: Scene);
  102983. /**
  102984. * Returns the string "DirectionalLight".
  102985. * @return The class name
  102986. */
  102987. getClassName(): string;
  102988. /**
  102989. * Returns the integer 1.
  102990. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  102991. */
  102992. getTypeID(): number;
  102993. /**
  102994. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  102995. * Returns the DirectionalLight Shadow projection matrix.
  102996. */
  102997. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  102998. /**
  102999. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  103000. * Returns the DirectionalLight Shadow projection matrix.
  103001. */
  103002. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  103003. /**
  103004. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  103005. * Returns the DirectionalLight Shadow projection matrix.
  103006. */
  103007. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  103008. protected _buildUniformLayout(): void;
  103009. /**
  103010. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  103011. * @param effect The effect to update
  103012. * @param lightIndex The index of the light in the effect to update
  103013. * @returns The directional light
  103014. */
  103015. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  103016. /**
  103017. * Gets the minZ used for shadow according to both the scene and the light.
  103018. *
  103019. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  103020. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  103021. * @param activeCamera The camera we are returning the min for
  103022. * @returns the depth min z
  103023. */
  103024. getDepthMinZ(activeCamera: Camera): number;
  103025. /**
  103026. * Gets the maxZ used for shadow according to both the scene and the light.
  103027. *
  103028. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  103029. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  103030. * @param activeCamera The camera we are returning the max for
  103031. * @returns the depth max z
  103032. */
  103033. getDepthMaxZ(activeCamera: Camera): number;
  103034. /**
  103035. * Prepares the list of defines specific to the light type.
  103036. * @param defines the list of defines
  103037. * @param lightIndex defines the index of the light for the effect
  103038. */
  103039. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  103040. }
  103041. }
  103042. declare module BABYLON {
  103043. /**
  103044. * Class containing static functions to help procedurally build meshes
  103045. */
  103046. export class HemisphereBuilder {
  103047. /**
  103048. * Creates a hemisphere mesh
  103049. * @param name defines the name of the mesh
  103050. * @param options defines the options used to create the mesh
  103051. * @param scene defines the hosting scene
  103052. * @returns the hemisphere mesh
  103053. */
  103054. static CreateHemisphere(name: string, options: {
  103055. segments?: number;
  103056. diameter?: number;
  103057. sideOrientation?: number;
  103058. }, scene: any): Mesh;
  103059. }
  103060. }
  103061. declare module BABYLON {
  103062. /**
  103063. * A spot light is defined by a position, a direction, an angle, and an exponent.
  103064. * These values define a cone of light starting from the position, emitting toward the direction.
  103065. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  103066. * and the exponent defines the speed of the decay of the light with distance (reach).
  103067. * Documentation: https://doc.babylonjs.com/babylon101/lights
  103068. */
  103069. export class SpotLight extends ShadowLight {
  103070. private _angle;
  103071. private _innerAngle;
  103072. private _cosHalfAngle;
  103073. private _lightAngleScale;
  103074. private _lightAngleOffset;
  103075. /**
  103076. * Gets the cone angle of the spot light in Radians.
  103077. */
  103078. /**
  103079. * Sets the cone angle of the spot light in Radians.
  103080. */
  103081. angle: number;
  103082. /**
  103083. * Only used in gltf falloff mode, this defines the angle where
  103084. * the directional falloff will start before cutting at angle which could be seen
  103085. * as outer angle.
  103086. */
  103087. /**
  103088. * Only used in gltf falloff mode, this defines the angle where
  103089. * the directional falloff will start before cutting at angle which could be seen
  103090. * as outer angle.
  103091. */
  103092. innerAngle: number;
  103093. private _shadowAngleScale;
  103094. /**
  103095. * Allows scaling the angle of the light for shadow generation only.
  103096. */
  103097. /**
  103098. * Allows scaling the angle of the light for shadow generation only.
  103099. */
  103100. shadowAngleScale: number;
  103101. /**
  103102. * The light decay speed with the distance from the emission spot.
  103103. */
  103104. exponent: number;
  103105. private _projectionTextureMatrix;
  103106. /**
  103107. * Allows reading the projecton texture
  103108. */
  103109. readonly projectionTextureMatrix: Matrix;
  103110. protected _projectionTextureLightNear: number;
  103111. /**
  103112. * Gets the near clip of the Spotlight for texture projection.
  103113. */
  103114. /**
  103115. * Sets the near clip of the Spotlight for texture projection.
  103116. */
  103117. projectionTextureLightNear: number;
  103118. protected _projectionTextureLightFar: number;
  103119. /**
  103120. * Gets the far clip of the Spotlight for texture projection.
  103121. */
  103122. /**
  103123. * Sets the far clip of the Spotlight for texture projection.
  103124. */
  103125. projectionTextureLightFar: number;
  103126. protected _projectionTextureUpDirection: Vector3;
  103127. /**
  103128. * Gets the Up vector of the Spotlight for texture projection.
  103129. */
  103130. /**
  103131. * Sets the Up vector of the Spotlight for texture projection.
  103132. */
  103133. projectionTextureUpDirection: Vector3;
  103134. private _projectionTexture;
  103135. /**
  103136. * Gets the projection texture of the light.
  103137. */
  103138. /**
  103139. * Sets the projection texture of the light.
  103140. */
  103141. projectionTexture: Nullable<BaseTexture>;
  103142. private _projectionTextureViewLightDirty;
  103143. private _projectionTextureProjectionLightDirty;
  103144. private _projectionTextureDirty;
  103145. private _projectionTextureViewTargetVector;
  103146. private _projectionTextureViewLightMatrix;
  103147. private _projectionTextureProjectionLightMatrix;
  103148. private _projectionTextureScalingMatrix;
  103149. /**
  103150. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  103151. * It can cast shadows.
  103152. * Documentation : https://doc.babylonjs.com/babylon101/lights
  103153. * @param name The light friendly name
  103154. * @param position The position of the spot light in the scene
  103155. * @param direction The direction of the light in the scene
  103156. * @param angle The cone angle of the light in Radians
  103157. * @param exponent The light decay speed with the distance from the emission spot
  103158. * @param scene The scene the lights belongs to
  103159. */
  103160. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  103161. /**
  103162. * Returns the string "SpotLight".
  103163. * @returns the class name
  103164. */
  103165. getClassName(): string;
  103166. /**
  103167. * Returns the integer 2.
  103168. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  103169. */
  103170. getTypeID(): number;
  103171. /**
  103172. * Overrides the direction setter to recompute the projection texture view light Matrix.
  103173. */
  103174. protected _setDirection(value: Vector3): void;
  103175. /**
  103176. * Overrides the position setter to recompute the projection texture view light Matrix.
  103177. */
  103178. protected _setPosition(value: Vector3): void;
  103179. /**
  103180. * 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.
  103181. * Returns the SpotLight.
  103182. */
  103183. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  103184. protected _computeProjectionTextureViewLightMatrix(): void;
  103185. protected _computeProjectionTextureProjectionLightMatrix(): void;
  103186. /**
  103187. * Main function for light texture projection matrix computing.
  103188. */
  103189. protected _computeProjectionTextureMatrix(): void;
  103190. protected _buildUniformLayout(): void;
  103191. private _computeAngleValues;
  103192. /**
  103193. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  103194. * @param effect The effect to update
  103195. * @param lightIndex The index of the light in the effect to update
  103196. * @returns The spot light
  103197. */
  103198. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  103199. /**
  103200. * Disposes the light and the associated resources.
  103201. */
  103202. dispose(): void;
  103203. /**
  103204. * Prepares the list of defines specific to the light type.
  103205. * @param defines the list of defines
  103206. * @param lightIndex defines the index of the light for the effect
  103207. */
  103208. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  103209. }
  103210. }
  103211. declare module BABYLON {
  103212. /**
  103213. * Gizmo that enables viewing a light
  103214. */
  103215. export class LightGizmo extends Gizmo {
  103216. private _lightMesh;
  103217. private _material;
  103218. private cachedPosition;
  103219. private cachedForward;
  103220. /**
  103221. * Creates a LightGizmo
  103222. * @param gizmoLayer The utility layer the gizmo will be added to
  103223. */
  103224. constructor(gizmoLayer?: UtilityLayerRenderer);
  103225. private _light;
  103226. /**
  103227. * The light that the gizmo is attached to
  103228. */
  103229. light: Nullable<Light>;
  103230. /**
  103231. * @hidden
  103232. * Updates the gizmo to match the attached mesh's position/rotation
  103233. */
  103234. protected _update(): void;
  103235. private static _Scale;
  103236. /**
  103237. * Creates the lines for a light mesh
  103238. */
  103239. private static _createLightLines;
  103240. private static _CreateHemisphericLightMesh;
  103241. private static _CreatePointLightMesh;
  103242. private static _CreateSpotLightMesh;
  103243. private static _CreateDirectionalLightMesh;
  103244. }
  103245. }
  103246. declare module BABYLON {
  103247. /** @hidden */
  103248. export var backgroundFragmentDeclaration: {
  103249. name: string;
  103250. shader: string;
  103251. };
  103252. }
  103253. declare module BABYLON {
  103254. /** @hidden */
  103255. export var backgroundUboDeclaration: {
  103256. name: string;
  103257. shader: string;
  103258. };
  103259. }
  103260. declare module BABYLON {
  103261. /** @hidden */
  103262. export var backgroundPixelShader: {
  103263. name: string;
  103264. shader: string;
  103265. };
  103266. }
  103267. declare module BABYLON {
  103268. /** @hidden */
  103269. export var backgroundVertexDeclaration: {
  103270. name: string;
  103271. shader: string;
  103272. };
  103273. }
  103274. declare module BABYLON {
  103275. /** @hidden */
  103276. export var backgroundVertexShader: {
  103277. name: string;
  103278. shader: string;
  103279. };
  103280. }
  103281. declare module BABYLON {
  103282. /**
  103283. * Background material used to create an efficient environement around your scene.
  103284. */
  103285. export class BackgroundMaterial extends PushMaterial {
  103286. /**
  103287. * Standard reflectance value at parallel view angle.
  103288. */
  103289. static StandardReflectance0: number;
  103290. /**
  103291. * Standard reflectance value at grazing angle.
  103292. */
  103293. static StandardReflectance90: number;
  103294. protected _primaryColor: Color3;
  103295. /**
  103296. * Key light Color (multiply against the environement texture)
  103297. */
  103298. primaryColor: Color3;
  103299. protected __perceptualColor: Nullable<Color3>;
  103300. /**
  103301. * Experimental Internal Use Only.
  103302. *
  103303. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  103304. * This acts as a helper to set the primary color to a more "human friendly" value.
  103305. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  103306. * output color as close as possible from the chosen value.
  103307. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  103308. * part of lighting setup.)
  103309. */
  103310. _perceptualColor: Nullable<Color3>;
  103311. protected _primaryColorShadowLevel: float;
  103312. /**
  103313. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  103314. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  103315. */
  103316. primaryColorShadowLevel: float;
  103317. protected _primaryColorHighlightLevel: float;
  103318. /**
  103319. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  103320. * The primary color is used at the level chosen to define what the white area would look.
  103321. */
  103322. primaryColorHighlightLevel: float;
  103323. protected _reflectionTexture: Nullable<BaseTexture>;
  103324. /**
  103325. * Reflection Texture used in the material.
  103326. * Should be author in a specific way for the best result (refer to the documentation).
  103327. */
  103328. reflectionTexture: Nullable<BaseTexture>;
  103329. protected _reflectionBlur: float;
  103330. /**
  103331. * Reflection Texture level of blur.
  103332. *
  103333. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  103334. * texture twice.
  103335. */
  103336. reflectionBlur: float;
  103337. protected _diffuseTexture: Nullable<BaseTexture>;
  103338. /**
  103339. * Diffuse Texture used in the material.
  103340. * Should be author in a specific way for the best result (refer to the documentation).
  103341. */
  103342. diffuseTexture: Nullable<BaseTexture>;
  103343. protected _shadowLights: Nullable<IShadowLight[]>;
  103344. /**
  103345. * Specify the list of lights casting shadow on the material.
  103346. * All scene shadow lights will be included if null.
  103347. */
  103348. shadowLights: Nullable<IShadowLight[]>;
  103349. protected _shadowLevel: float;
  103350. /**
  103351. * Helps adjusting the shadow to a softer level if required.
  103352. * 0 means black shadows and 1 means no shadows.
  103353. */
  103354. shadowLevel: float;
  103355. protected _sceneCenter: Vector3;
  103356. /**
  103357. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  103358. * It is usually zero but might be interesting to modify according to your setup.
  103359. */
  103360. sceneCenter: Vector3;
  103361. protected _opacityFresnel: boolean;
  103362. /**
  103363. * This helps specifying that the material is falling off to the sky box at grazing angle.
  103364. * This helps ensuring a nice transition when the camera goes under the ground.
  103365. */
  103366. opacityFresnel: boolean;
  103367. protected _reflectionFresnel: boolean;
  103368. /**
  103369. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  103370. * This helps adding a mirror texture on the ground.
  103371. */
  103372. reflectionFresnel: boolean;
  103373. protected _reflectionFalloffDistance: number;
  103374. /**
  103375. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  103376. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  103377. */
  103378. reflectionFalloffDistance: number;
  103379. protected _reflectionAmount: number;
  103380. /**
  103381. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  103382. */
  103383. reflectionAmount: number;
  103384. protected _reflectionReflectance0: number;
  103385. /**
  103386. * This specifies the weight of the reflection at grazing angle.
  103387. */
  103388. reflectionReflectance0: number;
  103389. protected _reflectionReflectance90: number;
  103390. /**
  103391. * This specifies the weight of the reflection at a perpendicular point of view.
  103392. */
  103393. reflectionReflectance90: number;
  103394. /**
  103395. * Sets the reflection reflectance fresnel values according to the default standard
  103396. * empirically know to work well :-)
  103397. */
  103398. reflectionStandardFresnelWeight: number;
  103399. protected _useRGBColor: boolean;
  103400. /**
  103401. * Helps to directly use the maps channels instead of their level.
  103402. */
  103403. useRGBColor: boolean;
  103404. protected _enableNoise: boolean;
  103405. /**
  103406. * This helps reducing the banding effect that could occur on the background.
  103407. */
  103408. enableNoise: boolean;
  103409. /**
  103410. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  103411. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  103412. * Recommended to be keep at 1.0 except for special cases.
  103413. */
  103414. fovMultiplier: number;
  103415. private _fovMultiplier;
  103416. /**
  103417. * Enable the FOV adjustment feature controlled by fovMultiplier.
  103418. */
  103419. useEquirectangularFOV: boolean;
  103420. private _maxSimultaneousLights;
  103421. /**
  103422. * Number of Simultaneous lights allowed on the material.
  103423. */
  103424. maxSimultaneousLights: int;
  103425. /**
  103426. * Default configuration related to image processing available in the Background Material.
  103427. */
  103428. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  103429. /**
  103430. * Keep track of the image processing observer to allow dispose and replace.
  103431. */
  103432. private _imageProcessingObserver;
  103433. /**
  103434. * Attaches a new image processing configuration to the PBR Material.
  103435. * @param configuration (if null the scene configuration will be use)
  103436. */
  103437. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  103438. /**
  103439. * Gets the image processing configuration used either in this material.
  103440. */
  103441. /**
  103442. * Sets the Default image processing configuration used either in the this material.
  103443. *
  103444. * If sets to null, the scene one is in use.
  103445. */
  103446. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  103447. /**
  103448. * Gets wether the color curves effect is enabled.
  103449. */
  103450. /**
  103451. * Sets wether the color curves effect is enabled.
  103452. */
  103453. cameraColorCurvesEnabled: boolean;
  103454. /**
  103455. * Gets wether the color grading effect is enabled.
  103456. */
  103457. /**
  103458. * Gets wether the color grading effect is enabled.
  103459. */
  103460. cameraColorGradingEnabled: boolean;
  103461. /**
  103462. * Gets wether tonemapping is enabled or not.
  103463. */
  103464. /**
  103465. * Sets wether tonemapping is enabled or not
  103466. */
  103467. cameraToneMappingEnabled: boolean;
  103468. /**
  103469. * The camera exposure used on this material.
  103470. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  103471. * This corresponds to a photographic exposure.
  103472. */
  103473. /**
  103474. * The camera exposure used on this material.
  103475. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  103476. * This corresponds to a photographic exposure.
  103477. */
  103478. cameraExposure: float;
  103479. /**
  103480. * Gets The camera contrast used on this material.
  103481. */
  103482. /**
  103483. * Sets The camera contrast used on this material.
  103484. */
  103485. cameraContrast: float;
  103486. /**
  103487. * Gets the Color Grading 2D Lookup Texture.
  103488. */
  103489. /**
  103490. * Sets the Color Grading 2D Lookup Texture.
  103491. */
  103492. cameraColorGradingTexture: Nullable<BaseTexture>;
  103493. /**
  103494. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  103495. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  103496. * 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;
  103497. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  103498. */
  103499. /**
  103500. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  103501. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  103502. * 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;
  103503. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  103504. */
  103505. cameraColorCurves: Nullable<ColorCurves>;
  103506. /**
  103507. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  103508. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  103509. */
  103510. switchToBGR: boolean;
  103511. private _renderTargets;
  103512. private _reflectionControls;
  103513. private _white;
  103514. private _primaryShadowColor;
  103515. private _primaryHighlightColor;
  103516. /**
  103517. * Instantiates a Background Material in the given scene
  103518. * @param name The friendly name of the material
  103519. * @param scene The scene to add the material to
  103520. */
  103521. constructor(name: string, scene: Scene);
  103522. /**
  103523. * Gets a boolean indicating that current material needs to register RTT
  103524. */
  103525. readonly hasRenderTargetTextures: boolean;
  103526. /**
  103527. * The entire material has been created in order to prevent overdraw.
  103528. * @returns false
  103529. */
  103530. needAlphaTesting(): boolean;
  103531. /**
  103532. * The entire material has been created in order to prevent overdraw.
  103533. * @returns true if blending is enable
  103534. */
  103535. needAlphaBlending(): boolean;
  103536. /**
  103537. * Checks wether the material is ready to be rendered for a given mesh.
  103538. * @param mesh The mesh to render
  103539. * @param subMesh The submesh to check against
  103540. * @param useInstances Specify wether or not the material is used with instances
  103541. * @returns true if all the dependencies are ready (Textures, Effects...)
  103542. */
  103543. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  103544. /**
  103545. * Compute the primary color according to the chosen perceptual color.
  103546. */
  103547. private _computePrimaryColorFromPerceptualColor;
  103548. /**
  103549. * Compute the highlights and shadow colors according to their chosen levels.
  103550. */
  103551. private _computePrimaryColors;
  103552. /**
  103553. * Build the uniform buffer used in the material.
  103554. */
  103555. buildUniformLayout(): void;
  103556. /**
  103557. * Unbind the material.
  103558. */
  103559. unbind(): void;
  103560. /**
  103561. * Bind only the world matrix to the material.
  103562. * @param world The world matrix to bind.
  103563. */
  103564. bindOnlyWorldMatrix(world: Matrix): void;
  103565. /**
  103566. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  103567. * @param world The world matrix to bind.
  103568. * @param subMesh The submesh to bind for.
  103569. */
  103570. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  103571. /**
  103572. * Dispose the material.
  103573. * @param forceDisposeEffect Force disposal of the associated effect.
  103574. * @param forceDisposeTextures Force disposal of the associated textures.
  103575. */
  103576. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  103577. /**
  103578. * Clones the material.
  103579. * @param name The cloned name.
  103580. * @returns The cloned material.
  103581. */
  103582. clone(name: string): BackgroundMaterial;
  103583. /**
  103584. * Serializes the current material to its JSON representation.
  103585. * @returns The JSON representation.
  103586. */
  103587. serialize(): any;
  103588. /**
  103589. * Gets the class name of the material
  103590. * @returns "BackgroundMaterial"
  103591. */
  103592. getClassName(): string;
  103593. /**
  103594. * Parse a JSON input to create back a background material.
  103595. * @param source The JSON data to parse
  103596. * @param scene The scene to create the parsed material in
  103597. * @param rootUrl The root url of the assets the material depends upon
  103598. * @returns the instantiated BackgroundMaterial.
  103599. */
  103600. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  103601. }
  103602. }
  103603. declare module BABYLON {
  103604. /**
  103605. * Represents the different options available during the creation of
  103606. * a Environment helper.
  103607. *
  103608. * This can control the default ground, skybox and image processing setup of your scene.
  103609. */
  103610. export interface IEnvironmentHelperOptions {
  103611. /**
  103612. * Specifies wether or not to create a ground.
  103613. * True by default.
  103614. */
  103615. createGround: boolean;
  103616. /**
  103617. * Specifies the ground size.
  103618. * 15 by default.
  103619. */
  103620. groundSize: number;
  103621. /**
  103622. * The texture used on the ground for the main color.
  103623. * Comes from the BabylonJS CDN by default.
  103624. *
  103625. * Remarks: Can be either a texture or a url.
  103626. */
  103627. groundTexture: string | BaseTexture;
  103628. /**
  103629. * The color mixed in the ground texture by default.
  103630. * BabylonJS clearColor by default.
  103631. */
  103632. groundColor: Color3;
  103633. /**
  103634. * Specifies the ground opacity.
  103635. * 1 by default.
  103636. */
  103637. groundOpacity: number;
  103638. /**
  103639. * Enables the ground to receive shadows.
  103640. * True by default.
  103641. */
  103642. enableGroundShadow: boolean;
  103643. /**
  103644. * Helps preventing the shadow to be fully black on the ground.
  103645. * 0.5 by default.
  103646. */
  103647. groundShadowLevel: number;
  103648. /**
  103649. * Creates a mirror texture attach to the ground.
  103650. * false by default.
  103651. */
  103652. enableGroundMirror: boolean;
  103653. /**
  103654. * Specifies the ground mirror size ratio.
  103655. * 0.3 by default as the default kernel is 64.
  103656. */
  103657. groundMirrorSizeRatio: number;
  103658. /**
  103659. * Specifies the ground mirror blur kernel size.
  103660. * 64 by default.
  103661. */
  103662. groundMirrorBlurKernel: number;
  103663. /**
  103664. * Specifies the ground mirror visibility amount.
  103665. * 1 by default
  103666. */
  103667. groundMirrorAmount: number;
  103668. /**
  103669. * Specifies the ground mirror reflectance weight.
  103670. * This uses the standard weight of the background material to setup the fresnel effect
  103671. * of the mirror.
  103672. * 1 by default.
  103673. */
  103674. groundMirrorFresnelWeight: number;
  103675. /**
  103676. * Specifies the ground mirror Falloff distance.
  103677. * This can helps reducing the size of the reflection.
  103678. * 0 by Default.
  103679. */
  103680. groundMirrorFallOffDistance: number;
  103681. /**
  103682. * Specifies the ground mirror texture type.
  103683. * Unsigned Int by Default.
  103684. */
  103685. groundMirrorTextureType: number;
  103686. /**
  103687. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  103688. * the shown objects.
  103689. */
  103690. groundYBias: number;
  103691. /**
  103692. * Specifies wether or not to create a skybox.
  103693. * True by default.
  103694. */
  103695. createSkybox: boolean;
  103696. /**
  103697. * Specifies the skybox size.
  103698. * 20 by default.
  103699. */
  103700. skyboxSize: number;
  103701. /**
  103702. * The texture used on the skybox for the main color.
  103703. * Comes from the BabylonJS CDN by default.
  103704. *
  103705. * Remarks: Can be either a texture or a url.
  103706. */
  103707. skyboxTexture: string | BaseTexture;
  103708. /**
  103709. * The color mixed in the skybox texture by default.
  103710. * BabylonJS clearColor by default.
  103711. */
  103712. skyboxColor: Color3;
  103713. /**
  103714. * The background rotation around the Y axis of the scene.
  103715. * This helps aligning the key lights of your scene with the background.
  103716. * 0 by default.
  103717. */
  103718. backgroundYRotation: number;
  103719. /**
  103720. * Compute automatically the size of the elements to best fit with the scene.
  103721. */
  103722. sizeAuto: boolean;
  103723. /**
  103724. * Default position of the rootMesh if autoSize is not true.
  103725. */
  103726. rootPosition: Vector3;
  103727. /**
  103728. * Sets up the image processing in the scene.
  103729. * true by default.
  103730. */
  103731. setupImageProcessing: boolean;
  103732. /**
  103733. * The texture used as your environment texture in the scene.
  103734. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  103735. *
  103736. * Remarks: Can be either a texture or a url.
  103737. */
  103738. environmentTexture: string | BaseTexture;
  103739. /**
  103740. * The value of the exposure to apply to the scene.
  103741. * 0.6 by default if setupImageProcessing is true.
  103742. */
  103743. cameraExposure: number;
  103744. /**
  103745. * The value of the contrast to apply to the scene.
  103746. * 1.6 by default if setupImageProcessing is true.
  103747. */
  103748. cameraContrast: number;
  103749. /**
  103750. * Specifies wether or not tonemapping should be enabled in the scene.
  103751. * true by default if setupImageProcessing is true.
  103752. */
  103753. toneMappingEnabled: boolean;
  103754. }
  103755. /**
  103756. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  103757. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  103758. * It also helps with the default setup of your imageProcessing configuration.
  103759. */
  103760. export class EnvironmentHelper {
  103761. /**
  103762. * Default ground texture URL.
  103763. */
  103764. private static _groundTextureCDNUrl;
  103765. /**
  103766. * Default skybox texture URL.
  103767. */
  103768. private static _skyboxTextureCDNUrl;
  103769. /**
  103770. * Default environment texture URL.
  103771. */
  103772. private static _environmentTextureCDNUrl;
  103773. /**
  103774. * Creates the default options for the helper.
  103775. */
  103776. private static _getDefaultOptions;
  103777. private _rootMesh;
  103778. /**
  103779. * Gets the root mesh created by the helper.
  103780. */
  103781. readonly rootMesh: Mesh;
  103782. private _skybox;
  103783. /**
  103784. * Gets the skybox created by the helper.
  103785. */
  103786. readonly skybox: Nullable<Mesh>;
  103787. private _skyboxTexture;
  103788. /**
  103789. * Gets the skybox texture created by the helper.
  103790. */
  103791. readonly skyboxTexture: Nullable<BaseTexture>;
  103792. private _skyboxMaterial;
  103793. /**
  103794. * Gets the skybox material created by the helper.
  103795. */
  103796. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  103797. private _ground;
  103798. /**
  103799. * Gets the ground mesh created by the helper.
  103800. */
  103801. readonly ground: Nullable<Mesh>;
  103802. private _groundTexture;
  103803. /**
  103804. * Gets the ground texture created by the helper.
  103805. */
  103806. readonly groundTexture: Nullable<BaseTexture>;
  103807. private _groundMirror;
  103808. /**
  103809. * Gets the ground mirror created by the helper.
  103810. */
  103811. readonly groundMirror: Nullable<MirrorTexture>;
  103812. /**
  103813. * Gets the ground mirror render list to helps pushing the meshes
  103814. * you wish in the ground reflection.
  103815. */
  103816. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  103817. private _groundMaterial;
  103818. /**
  103819. * Gets the ground material created by the helper.
  103820. */
  103821. readonly groundMaterial: Nullable<BackgroundMaterial>;
  103822. /**
  103823. * Stores the creation options.
  103824. */
  103825. private readonly _scene;
  103826. private _options;
  103827. /**
  103828. * This observable will be notified with any error during the creation of the environment,
  103829. * mainly texture creation errors.
  103830. */
  103831. onErrorObservable: Observable<{
  103832. message?: string;
  103833. exception?: any;
  103834. }>;
  103835. /**
  103836. * constructor
  103837. * @param options Defines the options we want to customize the helper
  103838. * @param scene The scene to add the material to
  103839. */
  103840. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  103841. /**
  103842. * Updates the background according to the new options
  103843. * @param options
  103844. */
  103845. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  103846. /**
  103847. * Sets the primary color of all the available elements.
  103848. * @param color the main color to affect to the ground and the background
  103849. */
  103850. setMainColor(color: Color3): void;
  103851. /**
  103852. * Setup the image processing according to the specified options.
  103853. */
  103854. private _setupImageProcessing;
  103855. /**
  103856. * Setup the environment texture according to the specified options.
  103857. */
  103858. private _setupEnvironmentTexture;
  103859. /**
  103860. * Setup the background according to the specified options.
  103861. */
  103862. private _setupBackground;
  103863. /**
  103864. * Get the scene sizes according to the setup.
  103865. */
  103866. private _getSceneSize;
  103867. /**
  103868. * Setup the ground according to the specified options.
  103869. */
  103870. private _setupGround;
  103871. /**
  103872. * Setup the ground material according to the specified options.
  103873. */
  103874. private _setupGroundMaterial;
  103875. /**
  103876. * Setup the ground diffuse texture according to the specified options.
  103877. */
  103878. private _setupGroundDiffuseTexture;
  103879. /**
  103880. * Setup the ground mirror texture according to the specified options.
  103881. */
  103882. private _setupGroundMirrorTexture;
  103883. /**
  103884. * Setup the ground to receive the mirror texture.
  103885. */
  103886. private _setupMirrorInGroundMaterial;
  103887. /**
  103888. * Setup the skybox according to the specified options.
  103889. */
  103890. private _setupSkybox;
  103891. /**
  103892. * Setup the skybox material according to the specified options.
  103893. */
  103894. private _setupSkyboxMaterial;
  103895. /**
  103896. * Setup the skybox reflection texture according to the specified options.
  103897. */
  103898. private _setupSkyboxReflectionTexture;
  103899. private _errorHandler;
  103900. /**
  103901. * Dispose all the elements created by the Helper.
  103902. */
  103903. dispose(): void;
  103904. }
  103905. }
  103906. declare module BABYLON {
  103907. /**
  103908. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  103909. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  103910. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  103911. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  103912. */
  103913. export class PhotoDome extends TransformNode {
  103914. private _useDirectMapping;
  103915. /**
  103916. * The texture being displayed on the sphere
  103917. */
  103918. protected _photoTexture: Texture;
  103919. /**
  103920. * Gets or sets the texture being displayed on the sphere
  103921. */
  103922. photoTexture: Texture;
  103923. /**
  103924. * Observable raised when an error occured while loading the 360 image
  103925. */
  103926. onLoadErrorObservable: Observable<string>;
  103927. /**
  103928. * The skybox material
  103929. */
  103930. protected _material: BackgroundMaterial;
  103931. /**
  103932. * The surface used for the skybox
  103933. */
  103934. protected _mesh: Mesh;
  103935. /**
  103936. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  103937. * Also see the options.resolution property.
  103938. */
  103939. fovMultiplier: number;
  103940. /**
  103941. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  103942. * @param name Element's name, child elements will append suffixes for their own names.
  103943. * @param urlsOfPhoto defines the url of the photo to display
  103944. * @param options defines an object containing optional or exposed sub element properties
  103945. * @param onError defines a callback called when an error occured while loading the texture
  103946. */
  103947. constructor(name: string, urlOfPhoto: string, options: {
  103948. resolution?: number;
  103949. size?: number;
  103950. useDirectMapping?: boolean;
  103951. faceForward?: boolean;
  103952. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  103953. /**
  103954. * Releases resources associated with this node.
  103955. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  103956. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  103957. */
  103958. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  103959. }
  103960. }
  103961. declare module BABYLON {
  103962. /** @hidden */
  103963. export var rgbdDecodePixelShader: {
  103964. name: string;
  103965. shader: string;
  103966. };
  103967. }
  103968. declare module BABYLON {
  103969. /**
  103970. * Class used to host texture specific utilities
  103971. */
  103972. export class BRDFTextureTools {
  103973. /**
  103974. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  103975. * @param texture the texture to expand.
  103976. */
  103977. private static _ExpandDefaultBRDFTexture;
  103978. /**
  103979. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  103980. * @param scene defines the hosting scene
  103981. * @returns the environment BRDF texture
  103982. */
  103983. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  103984. private static _environmentBRDFBase64Texture;
  103985. }
  103986. }
  103987. declare module BABYLON {
  103988. /**
  103989. * @hidden
  103990. */
  103991. export interface IMaterialClearCoatDefines {
  103992. CLEARCOAT: boolean;
  103993. CLEARCOAT_DEFAULTIOR: boolean;
  103994. CLEARCOAT_TEXTURE: boolean;
  103995. CLEARCOAT_TEXTUREDIRECTUV: number;
  103996. CLEARCOAT_BUMP: boolean;
  103997. CLEARCOAT_BUMPDIRECTUV: number;
  103998. CLEARCOAT_TINT: boolean;
  103999. CLEARCOAT_TINT_TEXTURE: boolean;
  104000. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  104001. /** @hidden */
  104002. _areTexturesDirty: boolean;
  104003. }
  104004. /**
  104005. * Define the code related to the clear coat parameters of the pbr material.
  104006. */
  104007. export class PBRClearCoatConfiguration {
  104008. /**
  104009. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  104010. * The default fits with a polyurethane material.
  104011. */
  104012. private static readonly _DefaultIndiceOfRefraction;
  104013. private _isEnabled;
  104014. /**
  104015. * Defines if the clear coat is enabled in the material.
  104016. */
  104017. isEnabled: boolean;
  104018. /**
  104019. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  104020. */
  104021. intensity: number;
  104022. /**
  104023. * Defines the clear coat layer roughness.
  104024. */
  104025. roughness: number;
  104026. private _indiceOfRefraction;
  104027. /**
  104028. * Defines the indice of refraction of the clear coat.
  104029. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  104030. * The default fits with a polyurethane material.
  104031. * Changing the default value is more performance intensive.
  104032. */
  104033. indiceOfRefraction: number;
  104034. private _texture;
  104035. /**
  104036. * Stores the clear coat values in a texture.
  104037. */
  104038. texture: Nullable<BaseTexture>;
  104039. private _bumpTexture;
  104040. /**
  104041. * Define the clear coat specific bump texture.
  104042. */
  104043. bumpTexture: Nullable<BaseTexture>;
  104044. private _isTintEnabled;
  104045. /**
  104046. * Defines if the clear coat tint is enabled in the material.
  104047. */
  104048. isTintEnabled: boolean;
  104049. /**
  104050. * Defines the clear coat tint of the material.
  104051. * This is only use if tint is enabled
  104052. */
  104053. tintColor: Color3;
  104054. /**
  104055. * Defines the distance at which the tint color should be found in the
  104056. * clear coat media.
  104057. * This is only use if tint is enabled
  104058. */
  104059. tintColorAtDistance: number;
  104060. /**
  104061. * Defines the clear coat layer thickness.
  104062. * This is only use if tint is enabled
  104063. */
  104064. tintThickness: number;
  104065. private _tintTexture;
  104066. /**
  104067. * Stores the clear tint values in a texture.
  104068. * rgb is tint
  104069. * a is a thickness factor
  104070. */
  104071. tintTexture: Nullable<BaseTexture>;
  104072. /** @hidden */
  104073. private _internalMarkAllSubMeshesAsTexturesDirty;
  104074. /** @hidden */
  104075. _markAllSubMeshesAsTexturesDirty(): void;
  104076. /**
  104077. * Instantiate a new istance of clear coat configuration.
  104078. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  104079. */
  104080. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  104081. /**
  104082. * Gets wehter the submesh is ready to be used or not.
  104083. * @param defines the list of "defines" to update.
  104084. * @param scene defines the scene the material belongs to.
  104085. * @param engine defines the engine the material belongs to.
  104086. * @param disableBumpMap defines wether the material disables bump or not.
  104087. * @returns - boolean indicating that the submesh is ready or not.
  104088. */
  104089. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  104090. /**
  104091. * Checks to see if a texture is used in the material.
  104092. * @param defines the list of "defines" to update.
  104093. * @param scene defines the scene to the material belongs to.
  104094. */
  104095. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  104096. /**
  104097. * Binds the material data.
  104098. * @param uniformBuffer defines the Uniform buffer to fill in.
  104099. * @param scene defines the scene the material belongs to.
  104100. * @param engine defines the engine the material belongs to.
  104101. * @param disableBumpMap defines wether the material disables bump or not.
  104102. * @param isFrozen defines wether the material is frozen or not.
  104103. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  104104. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  104105. */
  104106. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  104107. /**
  104108. * Checks to see if a texture is used in the material.
  104109. * @param texture - Base texture to use.
  104110. * @returns - Boolean specifying if a texture is used in the material.
  104111. */
  104112. hasTexture(texture: BaseTexture): boolean;
  104113. /**
  104114. * Returns an array of the actively used textures.
  104115. * @param activeTextures Array of BaseTextures
  104116. */
  104117. getActiveTextures(activeTextures: BaseTexture[]): void;
  104118. /**
  104119. * Returns the animatable textures.
  104120. * @param animatables Array of animatable textures.
  104121. */
  104122. getAnimatables(animatables: IAnimatable[]): void;
  104123. /**
  104124. * Disposes the resources of the material.
  104125. * @param forceDisposeTextures - Forces the disposal of all textures.
  104126. */
  104127. dispose(forceDisposeTextures?: boolean): void;
  104128. /**
  104129. * Get the current class name of the texture useful for serialization or dynamic coding.
  104130. * @returns "PBRClearCoatConfiguration"
  104131. */
  104132. getClassName(): string;
  104133. /**
  104134. * Add fallbacks to the effect fallbacks list.
  104135. * @param defines defines the Base texture to use.
  104136. * @param fallbacks defines the current fallback list.
  104137. * @param currentRank defines the current fallback rank.
  104138. * @returns the new fallback rank.
  104139. */
  104140. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  104141. /**
  104142. * Add the required uniforms to the current list.
  104143. * @param uniforms defines the current uniform list.
  104144. */
  104145. static AddUniforms(uniforms: string[]): void;
  104146. /**
  104147. * Add the required samplers to the current list.
  104148. * @param samplers defines the current sampler list.
  104149. */
  104150. static AddSamplers(samplers: string[]): void;
  104151. /**
  104152. * Add the required uniforms to the current buffer.
  104153. * @param uniformBuffer defines the current uniform buffer.
  104154. */
  104155. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  104156. /**
  104157. * Makes a duplicate of the current configuration into another one.
  104158. * @param clearCoatConfiguration define the config where to copy the info
  104159. */
  104160. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  104161. /**
  104162. * Serializes this clear coat configuration.
  104163. * @returns - An object with the serialized config.
  104164. */
  104165. serialize(): any;
  104166. /**
  104167. * Parses a Clear Coat Configuration from a serialized object.
  104168. * @param source - Serialized object.
  104169. */
  104170. parse(source: any): void;
  104171. }
  104172. }
  104173. declare module BABYLON {
  104174. /**
  104175. * @hidden
  104176. */
  104177. export interface IMaterialAnisotropicDefines {
  104178. ANISOTROPIC: boolean;
  104179. ANISOTROPIC_TEXTURE: boolean;
  104180. ANISOTROPIC_TEXTUREDIRECTUV: number;
  104181. MAINUV1: boolean;
  104182. _areTexturesDirty: boolean;
  104183. _needUVs: boolean;
  104184. }
  104185. /**
  104186. * Define the code related to the anisotropic parameters of the pbr material.
  104187. */
  104188. export class PBRAnisotropicConfiguration {
  104189. private _isEnabled;
  104190. /**
  104191. * Defines if the anisotropy is enabled in the material.
  104192. */
  104193. isEnabled: boolean;
  104194. /**
  104195. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  104196. */
  104197. intensity: number;
  104198. /**
  104199. * Defines if the effect is along the tangents, bitangents or in between.
  104200. * By default, the effect is "strectching" the highlights along the tangents.
  104201. */
  104202. direction: Vector2;
  104203. private _texture;
  104204. /**
  104205. * Stores the anisotropy values in a texture.
  104206. * rg is direction (like normal from -1 to 1)
  104207. * b is a intensity
  104208. */
  104209. texture: Nullable<BaseTexture>;
  104210. /** @hidden */
  104211. private _internalMarkAllSubMeshesAsTexturesDirty;
  104212. /** @hidden */
  104213. _markAllSubMeshesAsTexturesDirty(): void;
  104214. /**
  104215. * Instantiate a new istance of anisotropy configuration.
  104216. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  104217. */
  104218. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  104219. /**
  104220. * Specifies that the submesh is ready to be used.
  104221. * @param defines the list of "defines" to update.
  104222. * @param scene defines the scene the material belongs to.
  104223. * @returns - boolean indicating that the submesh is ready or not.
  104224. */
  104225. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  104226. /**
  104227. * Checks to see if a texture is used in the material.
  104228. * @param defines the list of "defines" to update.
  104229. * @param mesh the mesh we are preparing the defines for.
  104230. * @param scene defines the scene the material belongs to.
  104231. */
  104232. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  104233. /**
  104234. * Binds the material data.
  104235. * @param uniformBuffer defines the Uniform buffer to fill in.
  104236. * @param scene defines the scene the material belongs to.
  104237. * @param isFrozen defines wether the material is frozen or not.
  104238. */
  104239. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  104240. /**
  104241. * Checks to see if a texture is used in the material.
  104242. * @param texture - Base texture to use.
  104243. * @returns - Boolean specifying if a texture is used in the material.
  104244. */
  104245. hasTexture(texture: BaseTexture): boolean;
  104246. /**
  104247. * Returns an array of the actively used textures.
  104248. * @param activeTextures Array of BaseTextures
  104249. */
  104250. getActiveTextures(activeTextures: BaseTexture[]): void;
  104251. /**
  104252. * Returns the animatable textures.
  104253. * @param animatables Array of animatable textures.
  104254. */
  104255. getAnimatables(animatables: IAnimatable[]): void;
  104256. /**
  104257. * Disposes the resources of the material.
  104258. * @param forceDisposeTextures - Forces the disposal of all textures.
  104259. */
  104260. dispose(forceDisposeTextures?: boolean): void;
  104261. /**
  104262. * Get the current class name of the texture useful for serialization or dynamic coding.
  104263. * @returns "PBRAnisotropicConfiguration"
  104264. */
  104265. getClassName(): string;
  104266. /**
  104267. * Add fallbacks to the effect fallbacks list.
  104268. * @param defines defines the Base texture to use.
  104269. * @param fallbacks defines the current fallback list.
  104270. * @param currentRank defines the current fallback rank.
  104271. * @returns the new fallback rank.
  104272. */
  104273. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  104274. /**
  104275. * Add the required uniforms to the current list.
  104276. * @param uniforms defines the current uniform list.
  104277. */
  104278. static AddUniforms(uniforms: string[]): void;
  104279. /**
  104280. * Add the required uniforms to the current buffer.
  104281. * @param uniformBuffer defines the current uniform buffer.
  104282. */
  104283. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  104284. /**
  104285. * Add the required samplers to the current list.
  104286. * @param samplers defines the current sampler list.
  104287. */
  104288. static AddSamplers(samplers: string[]): void;
  104289. /**
  104290. * Makes a duplicate of the current configuration into another one.
  104291. * @param anisotropicConfiguration define the config where to copy the info
  104292. */
  104293. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  104294. /**
  104295. * Serializes this anisotropy configuration.
  104296. * @returns - An object with the serialized config.
  104297. */
  104298. serialize(): any;
  104299. /**
  104300. * Parses a anisotropy Configuration from a serialized object.
  104301. * @param source - Serialized object.
  104302. */
  104303. parse(source: any): void;
  104304. }
  104305. }
  104306. declare module BABYLON {
  104307. /**
  104308. * @hidden
  104309. */
  104310. export interface IMaterialBRDFDefines {
  104311. BRDF_V_HEIGHT_CORRELATED: boolean;
  104312. MS_BRDF_ENERGY_CONSERVATION: boolean;
  104313. SPHERICAL_HARMONICS: boolean;
  104314. /** @hidden */
  104315. _areMiscDirty: boolean;
  104316. }
  104317. /**
  104318. * Define the code related to the BRDF parameters of the pbr material.
  104319. */
  104320. export class PBRBRDFConfiguration {
  104321. /**
  104322. * Default value used for the energy conservation.
  104323. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  104324. */
  104325. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  104326. /**
  104327. * Default value used for the Smith Visibility Height Correlated mode.
  104328. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  104329. */
  104330. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  104331. /**
  104332. * Default value used for the IBL diffuse part.
  104333. * This can help switching back to the polynomials mode globally which is a tiny bit
  104334. * less GPU intensive at the drawback of a lower quality.
  104335. */
  104336. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  104337. private _useEnergyConservation;
  104338. /**
  104339. * Defines if the material uses energy conservation.
  104340. */
  104341. useEnergyConservation: boolean;
  104342. private _useSmithVisibilityHeightCorrelated;
  104343. /**
  104344. * LEGACY Mode set to false
  104345. * Defines if the material uses height smith correlated visibility term.
  104346. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  104347. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  104348. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  104349. * Not relying on height correlated will also disable energy conservation.
  104350. */
  104351. useSmithVisibilityHeightCorrelated: boolean;
  104352. private _useSphericalHarmonics;
  104353. /**
  104354. * LEGACY Mode set to false
  104355. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  104356. * diffuse part of the IBL.
  104357. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  104358. * to the ground truth.
  104359. */
  104360. useSphericalHarmonics: boolean;
  104361. /** @hidden */
  104362. private _internalMarkAllSubMeshesAsMiscDirty;
  104363. /** @hidden */
  104364. _markAllSubMeshesAsMiscDirty(): void;
  104365. /**
  104366. * Instantiate a new istance of clear coat configuration.
  104367. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  104368. */
  104369. constructor(markAllSubMeshesAsMiscDirty: () => void);
  104370. /**
  104371. * Checks to see if a texture is used in the material.
  104372. * @param defines the list of "defines" to update.
  104373. */
  104374. prepareDefines(defines: IMaterialBRDFDefines): void;
  104375. /**
  104376. * Get the current class name of the texture useful for serialization or dynamic coding.
  104377. * @returns "PBRClearCoatConfiguration"
  104378. */
  104379. getClassName(): string;
  104380. /**
  104381. * Makes a duplicate of the current configuration into another one.
  104382. * @param brdfConfiguration define the config where to copy the info
  104383. */
  104384. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  104385. /**
  104386. * Serializes this BRDF configuration.
  104387. * @returns - An object with the serialized config.
  104388. */
  104389. serialize(): any;
  104390. /**
  104391. * Parses a BRDF Configuration from a serialized object.
  104392. * @param source - Serialized object.
  104393. */
  104394. parse(source: any): void;
  104395. }
  104396. }
  104397. declare module BABYLON {
  104398. /**
  104399. * @hidden
  104400. */
  104401. export interface IMaterialSheenDefines {
  104402. SHEEN: boolean;
  104403. SHEEN_TEXTURE: boolean;
  104404. SHEEN_TEXTUREDIRECTUV: number;
  104405. SHEEN_LINKWITHALBEDO: boolean;
  104406. /** @hidden */
  104407. _areTexturesDirty: boolean;
  104408. }
  104409. /**
  104410. * Define the code related to the Sheen parameters of the pbr material.
  104411. */
  104412. export class PBRSheenConfiguration {
  104413. private _isEnabled;
  104414. /**
  104415. * Defines if the material uses sheen.
  104416. */
  104417. isEnabled: boolean;
  104418. private _linkSheenWithAlbedo;
  104419. /**
  104420. * Defines if the sheen is linked to the sheen color.
  104421. */
  104422. linkSheenWithAlbedo: boolean;
  104423. /**
  104424. * Defines the sheen intensity.
  104425. */
  104426. intensity: number;
  104427. /**
  104428. * Defines the sheen color.
  104429. */
  104430. color: Color3;
  104431. private _texture;
  104432. /**
  104433. * Stores the sheen tint values in a texture.
  104434. * rgb is tint
  104435. * a is a intensity
  104436. */
  104437. texture: Nullable<BaseTexture>;
  104438. /** @hidden */
  104439. private _internalMarkAllSubMeshesAsTexturesDirty;
  104440. /** @hidden */
  104441. _markAllSubMeshesAsTexturesDirty(): void;
  104442. /**
  104443. * Instantiate a new istance of clear coat configuration.
  104444. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  104445. */
  104446. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  104447. /**
  104448. * Specifies that the submesh is ready to be used.
  104449. * @param defines the list of "defines" to update.
  104450. * @param scene defines the scene the material belongs to.
  104451. * @returns - boolean indicating that the submesh is ready or not.
  104452. */
  104453. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  104454. /**
  104455. * Checks to see if a texture is used in the material.
  104456. * @param defines the list of "defines" to update.
  104457. * @param scene defines the scene the material belongs to.
  104458. */
  104459. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  104460. /**
  104461. * Binds the material data.
  104462. * @param uniformBuffer defines the Uniform buffer to fill in.
  104463. * @param scene defines the scene the material belongs to.
  104464. * @param isFrozen defines wether the material is frozen or not.
  104465. */
  104466. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  104467. /**
  104468. * Checks to see if a texture is used in the material.
  104469. * @param texture - Base texture to use.
  104470. * @returns - Boolean specifying if a texture is used in the material.
  104471. */
  104472. hasTexture(texture: BaseTexture): boolean;
  104473. /**
  104474. * Returns an array of the actively used textures.
  104475. * @param activeTextures Array of BaseTextures
  104476. */
  104477. getActiveTextures(activeTextures: BaseTexture[]): void;
  104478. /**
  104479. * Returns the animatable textures.
  104480. * @param animatables Array of animatable textures.
  104481. */
  104482. getAnimatables(animatables: IAnimatable[]): void;
  104483. /**
  104484. * Disposes the resources of the material.
  104485. * @param forceDisposeTextures - Forces the disposal of all textures.
  104486. */
  104487. dispose(forceDisposeTextures?: boolean): void;
  104488. /**
  104489. * Get the current class name of the texture useful for serialization or dynamic coding.
  104490. * @returns "PBRSheenConfiguration"
  104491. */
  104492. getClassName(): string;
  104493. /**
  104494. * Add fallbacks to the effect fallbacks list.
  104495. * @param defines defines the Base texture to use.
  104496. * @param fallbacks defines the current fallback list.
  104497. * @param currentRank defines the current fallback rank.
  104498. * @returns the new fallback rank.
  104499. */
  104500. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  104501. /**
  104502. * Add the required uniforms to the current list.
  104503. * @param uniforms defines the current uniform list.
  104504. */
  104505. static AddUniforms(uniforms: string[]): void;
  104506. /**
  104507. * Add the required uniforms to the current buffer.
  104508. * @param uniformBuffer defines the current uniform buffer.
  104509. */
  104510. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  104511. /**
  104512. * Add the required samplers to the current list.
  104513. * @param samplers defines the current sampler list.
  104514. */
  104515. static AddSamplers(samplers: string[]): void;
  104516. /**
  104517. * Makes a duplicate of the current configuration into another one.
  104518. * @param sheenConfiguration define the config where to copy the info
  104519. */
  104520. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  104521. /**
  104522. * Serializes this BRDF configuration.
  104523. * @returns - An object with the serialized config.
  104524. */
  104525. serialize(): any;
  104526. /**
  104527. * Parses a Sheen Configuration from a serialized object.
  104528. * @param source - Serialized object.
  104529. */
  104530. parse(source: any): void;
  104531. }
  104532. }
  104533. declare module BABYLON {
  104534. /**
  104535. * @hidden
  104536. */
  104537. export interface IMaterialSubSurfaceDefines {
  104538. SUBSURFACE: boolean;
  104539. SS_REFRACTION: boolean;
  104540. SS_TRANSLUCENCY: boolean;
  104541. SS_SCATERRING: boolean;
  104542. SS_THICKNESSANDMASK_TEXTURE: boolean;
  104543. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  104544. SS_REFRACTIONMAP_3D: boolean;
  104545. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  104546. SS_LODINREFRACTIONALPHA: boolean;
  104547. SS_GAMMAREFRACTION: boolean;
  104548. SS_RGBDREFRACTION: boolean;
  104549. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  104550. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  104551. /** @hidden */
  104552. _areTexturesDirty: boolean;
  104553. }
  104554. /**
  104555. * Define the code related to the sub surface parameters of the pbr material.
  104556. */
  104557. export class PBRSubSurfaceConfiguration {
  104558. private _isRefractionEnabled;
  104559. /**
  104560. * Defines if the refraction is enabled in the material.
  104561. */
  104562. isRefractionEnabled: boolean;
  104563. private _isTranslucencyEnabled;
  104564. /**
  104565. * Defines if the translucency is enabled in the material.
  104566. */
  104567. isTranslucencyEnabled: boolean;
  104568. private _isScatteringEnabled;
  104569. /**
  104570. * Defines the refraction intensity of the material.
  104571. * The refraction when enabled replaces the Diffuse part of the material.
  104572. * The intensity helps transitionning between diffuse and refraction.
  104573. */
  104574. refractionIntensity: number;
  104575. /**
  104576. * Defines the translucency intensity of the material.
  104577. * When translucency has been enabled, this defines how much of the "translucency"
  104578. * is addded to the diffuse part of the material.
  104579. */
  104580. translucencyIntensity: number;
  104581. /**
  104582. * Defines the scattering intensity of the material.
  104583. * When scattering has been enabled, this defines how much of the "scattered light"
  104584. * is addded to the diffuse part of the material.
  104585. */
  104586. scatteringIntensity: number;
  104587. private _thicknessTexture;
  104588. /**
  104589. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  104590. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  104591. * 0 would mean minimumThickness
  104592. * 1 would mean maximumThickness
  104593. * The other channels might be use as a mask to vary the different effects intensity.
  104594. */
  104595. thicknessTexture: Nullable<BaseTexture>;
  104596. private _refractionTexture;
  104597. /**
  104598. * Defines the texture to use for refraction.
  104599. */
  104600. refractionTexture: Nullable<BaseTexture>;
  104601. private _indexOfRefraction;
  104602. /**
  104603. * Defines the indice of refraction used in the material.
  104604. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  104605. */
  104606. indexOfRefraction: number;
  104607. private _invertRefractionY;
  104608. /**
  104609. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  104610. */
  104611. invertRefractionY: boolean;
  104612. private _linkRefractionWithTransparency;
  104613. /**
  104614. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  104615. * Materials half opaque for instance using refraction could benefit from this control.
  104616. */
  104617. linkRefractionWithTransparency: boolean;
  104618. /**
  104619. * Defines the minimum thickness stored in the thickness map.
  104620. * If no thickness map is defined, this value will be used to simulate thickness.
  104621. */
  104622. minimumThickness: number;
  104623. /**
  104624. * Defines the maximum thickness stored in the thickness map.
  104625. */
  104626. maximumThickness: number;
  104627. /**
  104628. * Defines the volume tint of the material.
  104629. * This is used for both translucency and scattering.
  104630. */
  104631. tintColor: Color3;
  104632. /**
  104633. * Defines the distance at which the tint color should be found in the media.
  104634. * This is used for refraction only.
  104635. */
  104636. tintColorAtDistance: number;
  104637. /**
  104638. * Defines how far each channel transmit through the media.
  104639. * It is defined as a color to simplify it selection.
  104640. */
  104641. diffusionDistance: Color3;
  104642. private _useMaskFromThicknessTexture;
  104643. /**
  104644. * Stores the intensity of the different subsurface effects in the thickness texture.
  104645. * * the green channel is the translucency intensity.
  104646. * * the blue channel is the scattering intensity.
  104647. * * the alpha channel is the refraction intensity.
  104648. */
  104649. useMaskFromThicknessTexture: boolean;
  104650. /** @hidden */
  104651. private _internalMarkAllSubMeshesAsTexturesDirty;
  104652. /** @hidden */
  104653. _markAllSubMeshesAsTexturesDirty(): void;
  104654. /**
  104655. * Instantiate a new istance of sub surface configuration.
  104656. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  104657. */
  104658. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  104659. /**
  104660. * Gets wehter the submesh is ready to be used or not.
  104661. * @param defines the list of "defines" to update.
  104662. * @param scene defines the scene the material belongs to.
  104663. * @returns - boolean indicating that the submesh is ready or not.
  104664. */
  104665. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  104666. /**
  104667. * Checks to see if a texture is used in the material.
  104668. * @param defines the list of "defines" to update.
  104669. * @param scene defines the scene to the material belongs to.
  104670. */
  104671. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  104672. /**
  104673. * Binds the material data.
  104674. * @param uniformBuffer defines the Uniform buffer to fill in.
  104675. * @param scene defines the scene the material belongs to.
  104676. * @param engine defines the engine the material belongs to.
  104677. * @param isFrozen defines wether the material is frozen or not.
  104678. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  104679. */
  104680. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  104681. /**
  104682. * Unbinds the material from the mesh.
  104683. * @param activeEffect defines the effect that should be unbound from.
  104684. * @returns true if unbound, otherwise false
  104685. */
  104686. unbind(activeEffect: Effect): boolean;
  104687. /**
  104688. * Returns the texture used for refraction or null if none is used.
  104689. * @param scene defines the scene the material belongs to.
  104690. * @returns - Refraction texture if present. If no refraction texture and refraction
  104691. * is linked with transparency, returns environment texture. Otherwise, returns null.
  104692. */
  104693. private _getRefractionTexture;
  104694. /**
  104695. * Returns true if alpha blending should be disabled.
  104696. */
  104697. readonly disableAlphaBlending: boolean;
  104698. /**
  104699. * Fills the list of render target textures.
  104700. * @param renderTargets the list of render targets to update
  104701. */
  104702. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  104703. /**
  104704. * Checks to see if a texture is used in the material.
  104705. * @param texture - Base texture to use.
  104706. * @returns - Boolean specifying if a texture is used in the material.
  104707. */
  104708. hasTexture(texture: BaseTexture): boolean;
  104709. /**
  104710. * Gets a boolean indicating that current material needs to register RTT
  104711. * @returns true if this uses a render target otherwise false.
  104712. */
  104713. hasRenderTargetTextures(): boolean;
  104714. /**
  104715. * Returns an array of the actively used textures.
  104716. * @param activeTextures Array of BaseTextures
  104717. */
  104718. getActiveTextures(activeTextures: BaseTexture[]): void;
  104719. /**
  104720. * Returns the animatable textures.
  104721. * @param animatables Array of animatable textures.
  104722. */
  104723. getAnimatables(animatables: IAnimatable[]): void;
  104724. /**
  104725. * Disposes the resources of the material.
  104726. * @param forceDisposeTextures - Forces the disposal of all textures.
  104727. */
  104728. dispose(forceDisposeTextures?: boolean): void;
  104729. /**
  104730. * Get the current class name of the texture useful for serialization or dynamic coding.
  104731. * @returns "PBRSubSurfaceConfiguration"
  104732. */
  104733. getClassName(): string;
  104734. /**
  104735. * Add fallbacks to the effect fallbacks list.
  104736. * @param defines defines the Base texture to use.
  104737. * @param fallbacks defines the current fallback list.
  104738. * @param currentRank defines the current fallback rank.
  104739. * @returns the new fallback rank.
  104740. */
  104741. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  104742. /**
  104743. * Add the required uniforms to the current list.
  104744. * @param uniforms defines the current uniform list.
  104745. */
  104746. static AddUniforms(uniforms: string[]): void;
  104747. /**
  104748. * Add the required samplers to the current list.
  104749. * @param samplers defines the current sampler list.
  104750. */
  104751. static AddSamplers(samplers: string[]): void;
  104752. /**
  104753. * Add the required uniforms to the current buffer.
  104754. * @param uniformBuffer defines the current uniform buffer.
  104755. */
  104756. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  104757. /**
  104758. * Makes a duplicate of the current configuration into another one.
  104759. * @param configuration define the config where to copy the info
  104760. */
  104761. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  104762. /**
  104763. * Serializes this Sub Surface configuration.
  104764. * @returns - An object with the serialized config.
  104765. */
  104766. serialize(): any;
  104767. /**
  104768. * Parses a Sub Surface Configuration from a serialized object.
  104769. * @param source - Serialized object.
  104770. */
  104771. parse(source: any): void;
  104772. }
  104773. }
  104774. declare module BABYLON {
  104775. /** @hidden */
  104776. export var pbrFragmentDeclaration: {
  104777. name: string;
  104778. shader: string;
  104779. };
  104780. }
  104781. declare module BABYLON {
  104782. /** @hidden */
  104783. export var pbrUboDeclaration: {
  104784. name: string;
  104785. shader: string;
  104786. };
  104787. }
  104788. declare module BABYLON {
  104789. /** @hidden */
  104790. export var pbrFragmentExtraDeclaration: {
  104791. name: string;
  104792. shader: string;
  104793. };
  104794. }
  104795. declare module BABYLON {
  104796. /** @hidden */
  104797. export var pbrFragmentSamplersDeclaration: {
  104798. name: string;
  104799. shader: string;
  104800. };
  104801. }
  104802. declare module BABYLON {
  104803. /** @hidden */
  104804. export var pbrHelperFunctions: {
  104805. name: string;
  104806. shader: string;
  104807. };
  104808. }
  104809. declare module BABYLON {
  104810. /** @hidden */
  104811. export var harmonicsFunctions: {
  104812. name: string;
  104813. shader: string;
  104814. };
  104815. }
  104816. declare module BABYLON {
  104817. /** @hidden */
  104818. export var pbrDirectLightingSetupFunctions: {
  104819. name: string;
  104820. shader: string;
  104821. };
  104822. }
  104823. declare module BABYLON {
  104824. /** @hidden */
  104825. export var pbrDirectLightingFalloffFunctions: {
  104826. name: string;
  104827. shader: string;
  104828. };
  104829. }
  104830. declare module BABYLON {
  104831. /** @hidden */
  104832. export var pbrBRDFFunctions: {
  104833. name: string;
  104834. shader: string;
  104835. };
  104836. }
  104837. declare module BABYLON {
  104838. /** @hidden */
  104839. export var pbrDirectLightingFunctions: {
  104840. name: string;
  104841. shader: string;
  104842. };
  104843. }
  104844. declare module BABYLON {
  104845. /** @hidden */
  104846. export var pbrIBLFunctions: {
  104847. name: string;
  104848. shader: string;
  104849. };
  104850. }
  104851. declare module BABYLON {
  104852. /** @hidden */
  104853. export var pbrDebug: {
  104854. name: string;
  104855. shader: string;
  104856. };
  104857. }
  104858. declare module BABYLON {
  104859. /** @hidden */
  104860. export var pbrPixelShader: {
  104861. name: string;
  104862. shader: string;
  104863. };
  104864. }
  104865. declare module BABYLON {
  104866. /** @hidden */
  104867. export var pbrVertexDeclaration: {
  104868. name: string;
  104869. shader: string;
  104870. };
  104871. }
  104872. declare module BABYLON {
  104873. /** @hidden */
  104874. export var pbrVertexShader: {
  104875. name: string;
  104876. shader: string;
  104877. };
  104878. }
  104879. declare module BABYLON {
  104880. /**
  104881. * Manages the defines for the PBR Material.
  104882. * @hidden
  104883. */
  104884. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  104885. PBR: boolean;
  104886. MAINUV1: boolean;
  104887. MAINUV2: boolean;
  104888. UV1: boolean;
  104889. UV2: boolean;
  104890. ALBEDO: boolean;
  104891. ALBEDODIRECTUV: number;
  104892. VERTEXCOLOR: boolean;
  104893. AMBIENT: boolean;
  104894. AMBIENTDIRECTUV: number;
  104895. AMBIENTINGRAYSCALE: boolean;
  104896. OPACITY: boolean;
  104897. VERTEXALPHA: boolean;
  104898. OPACITYDIRECTUV: number;
  104899. OPACITYRGB: boolean;
  104900. ALPHATEST: boolean;
  104901. DEPTHPREPASS: boolean;
  104902. ALPHABLEND: boolean;
  104903. ALPHAFROMALBEDO: boolean;
  104904. ALPHATESTVALUE: string;
  104905. SPECULAROVERALPHA: boolean;
  104906. RADIANCEOVERALPHA: boolean;
  104907. ALPHAFRESNEL: boolean;
  104908. LINEARALPHAFRESNEL: boolean;
  104909. PREMULTIPLYALPHA: boolean;
  104910. EMISSIVE: boolean;
  104911. EMISSIVEDIRECTUV: number;
  104912. REFLECTIVITY: boolean;
  104913. REFLECTIVITYDIRECTUV: number;
  104914. SPECULARTERM: boolean;
  104915. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  104916. MICROSURFACEAUTOMATIC: boolean;
  104917. LODBASEDMICROSFURACE: boolean;
  104918. MICROSURFACEMAP: boolean;
  104919. MICROSURFACEMAPDIRECTUV: number;
  104920. METALLICWORKFLOW: boolean;
  104921. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  104922. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  104923. METALLNESSSTOREINMETALMAPBLUE: boolean;
  104924. AOSTOREINMETALMAPRED: boolean;
  104925. ENVIRONMENTBRDF: boolean;
  104926. ENVIRONMENTBRDF_RGBD: boolean;
  104927. NORMAL: boolean;
  104928. TANGENT: boolean;
  104929. BUMP: boolean;
  104930. BUMPDIRECTUV: number;
  104931. OBJECTSPACE_NORMALMAP: boolean;
  104932. PARALLAX: boolean;
  104933. PARALLAXOCCLUSION: boolean;
  104934. NORMALXYSCALE: boolean;
  104935. LIGHTMAP: boolean;
  104936. LIGHTMAPDIRECTUV: number;
  104937. USELIGHTMAPASSHADOWMAP: boolean;
  104938. GAMMALIGHTMAP: boolean;
  104939. REFLECTION: boolean;
  104940. REFLECTIONMAP_3D: boolean;
  104941. REFLECTIONMAP_SPHERICAL: boolean;
  104942. REFLECTIONMAP_PLANAR: boolean;
  104943. REFLECTIONMAP_CUBIC: boolean;
  104944. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  104945. REFLECTIONMAP_PROJECTION: boolean;
  104946. REFLECTIONMAP_SKYBOX: boolean;
  104947. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  104948. REFLECTIONMAP_EXPLICIT: boolean;
  104949. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  104950. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  104951. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  104952. INVERTCUBICMAP: boolean;
  104953. USESPHERICALFROMREFLECTIONMAP: boolean;
  104954. SPHERICAL_HARMONICS: boolean;
  104955. USESPHERICALINVERTEX: boolean;
  104956. REFLECTIONMAP_OPPOSITEZ: boolean;
  104957. LODINREFLECTIONALPHA: boolean;
  104958. GAMMAREFLECTION: boolean;
  104959. RGBDREFLECTION: boolean;
  104960. RADIANCEOCCLUSION: boolean;
  104961. HORIZONOCCLUSION: boolean;
  104962. INSTANCES: boolean;
  104963. NUM_BONE_INFLUENCERS: number;
  104964. BonesPerMesh: number;
  104965. BONETEXTURE: boolean;
  104966. NONUNIFORMSCALING: boolean;
  104967. MORPHTARGETS: boolean;
  104968. MORPHTARGETS_NORMAL: boolean;
  104969. MORPHTARGETS_TANGENT: boolean;
  104970. NUM_MORPH_INFLUENCERS: number;
  104971. IMAGEPROCESSING: boolean;
  104972. VIGNETTE: boolean;
  104973. VIGNETTEBLENDMODEMULTIPLY: boolean;
  104974. VIGNETTEBLENDMODEOPAQUE: boolean;
  104975. TONEMAPPING: boolean;
  104976. TONEMAPPING_ACES: boolean;
  104977. CONTRAST: boolean;
  104978. COLORCURVES: boolean;
  104979. COLORGRADING: boolean;
  104980. COLORGRADING3D: boolean;
  104981. SAMPLER3DGREENDEPTH: boolean;
  104982. SAMPLER3DBGRMAP: boolean;
  104983. IMAGEPROCESSINGPOSTPROCESS: boolean;
  104984. EXPOSURE: boolean;
  104985. MULTIVIEW: boolean;
  104986. USEPHYSICALLIGHTFALLOFF: boolean;
  104987. USEGLTFLIGHTFALLOFF: boolean;
  104988. TWOSIDEDLIGHTING: boolean;
  104989. SHADOWFLOAT: boolean;
  104990. CLIPPLANE: boolean;
  104991. CLIPPLANE2: boolean;
  104992. CLIPPLANE3: boolean;
  104993. CLIPPLANE4: boolean;
  104994. POINTSIZE: boolean;
  104995. FOG: boolean;
  104996. LOGARITHMICDEPTH: boolean;
  104997. FORCENORMALFORWARD: boolean;
  104998. SPECULARAA: boolean;
  104999. CLEARCOAT: boolean;
  105000. CLEARCOAT_DEFAULTIOR: boolean;
  105001. CLEARCOAT_TEXTURE: boolean;
  105002. CLEARCOAT_TEXTUREDIRECTUV: number;
  105003. CLEARCOAT_BUMP: boolean;
  105004. CLEARCOAT_BUMPDIRECTUV: number;
  105005. CLEARCOAT_TINT: boolean;
  105006. CLEARCOAT_TINT_TEXTURE: boolean;
  105007. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  105008. ANISOTROPIC: boolean;
  105009. ANISOTROPIC_TEXTURE: boolean;
  105010. ANISOTROPIC_TEXTUREDIRECTUV: number;
  105011. BRDF_V_HEIGHT_CORRELATED: boolean;
  105012. MS_BRDF_ENERGY_CONSERVATION: boolean;
  105013. SHEEN: boolean;
  105014. SHEEN_TEXTURE: boolean;
  105015. SHEEN_TEXTUREDIRECTUV: number;
  105016. SHEEN_LINKWITHALBEDO: boolean;
  105017. SUBSURFACE: boolean;
  105018. SS_REFRACTION: boolean;
  105019. SS_TRANSLUCENCY: boolean;
  105020. SS_SCATERRING: boolean;
  105021. SS_THICKNESSANDMASK_TEXTURE: boolean;
  105022. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  105023. SS_REFRACTIONMAP_3D: boolean;
  105024. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  105025. SS_LODINREFRACTIONALPHA: boolean;
  105026. SS_GAMMAREFRACTION: boolean;
  105027. SS_RGBDREFRACTION: boolean;
  105028. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  105029. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  105030. UNLIT: boolean;
  105031. DEBUGMODE: number;
  105032. /**
  105033. * Initializes the PBR Material defines.
  105034. */
  105035. constructor();
  105036. /**
  105037. * Resets the PBR Material defines.
  105038. */
  105039. reset(): void;
  105040. }
  105041. /**
  105042. * The Physically based material base class of BJS.
  105043. *
  105044. * This offers the main features of a standard PBR material.
  105045. * For more information, please refer to the documentation :
  105046. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  105047. */
  105048. export abstract class PBRBaseMaterial extends PushMaterial {
  105049. /**
  105050. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  105051. */
  105052. static readonly PBRMATERIAL_OPAQUE: number;
  105053. /**
  105054. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  105055. */
  105056. static readonly PBRMATERIAL_ALPHATEST: number;
  105057. /**
  105058. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  105059. */
  105060. static readonly PBRMATERIAL_ALPHABLEND: number;
  105061. /**
  105062. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  105063. * They are also discarded below the alpha cutoff threshold to improve performances.
  105064. */
  105065. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  105066. /**
  105067. * Defines the default value of how much AO map is occluding the analytical lights
  105068. * (point spot...).
  105069. */
  105070. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  105071. /**
  105072. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  105073. */
  105074. static readonly LIGHTFALLOFF_PHYSICAL: number;
  105075. /**
  105076. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  105077. * to enhance interoperability with other engines.
  105078. */
  105079. static readonly LIGHTFALLOFF_GLTF: number;
  105080. /**
  105081. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  105082. * to enhance interoperability with other materials.
  105083. */
  105084. static readonly LIGHTFALLOFF_STANDARD: number;
  105085. /**
  105086. * Intensity of the direct lights e.g. the four lights available in your scene.
  105087. * This impacts both the direct diffuse and specular highlights.
  105088. */
  105089. protected _directIntensity: number;
  105090. /**
  105091. * Intensity of the emissive part of the material.
  105092. * This helps controlling the emissive effect without modifying the emissive color.
  105093. */
  105094. protected _emissiveIntensity: number;
  105095. /**
  105096. * Intensity of the environment e.g. how much the environment will light the object
  105097. * either through harmonics for rough material or through the refelction for shiny ones.
  105098. */
  105099. protected _environmentIntensity: number;
  105100. /**
  105101. * This is a special control allowing the reduction of the specular highlights coming from the
  105102. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  105103. */
  105104. protected _specularIntensity: number;
  105105. /**
  105106. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  105107. */
  105108. private _lightingInfos;
  105109. /**
  105110. * Debug Control allowing disabling the bump map on this material.
  105111. */
  105112. protected _disableBumpMap: boolean;
  105113. /**
  105114. * AKA Diffuse Texture in standard nomenclature.
  105115. */
  105116. protected _albedoTexture: Nullable<BaseTexture>;
  105117. /**
  105118. * AKA Occlusion Texture in other nomenclature.
  105119. */
  105120. protected _ambientTexture: Nullable<BaseTexture>;
  105121. /**
  105122. * AKA Occlusion Texture Intensity in other nomenclature.
  105123. */
  105124. protected _ambientTextureStrength: number;
  105125. /**
  105126. * Defines how much the AO map is occluding the analytical lights (point spot...).
  105127. * 1 means it completely occludes it
  105128. * 0 mean it has no impact
  105129. */
  105130. protected _ambientTextureImpactOnAnalyticalLights: number;
  105131. /**
  105132. * Stores the alpha values in a texture.
  105133. */
  105134. protected _opacityTexture: Nullable<BaseTexture>;
  105135. /**
  105136. * Stores the reflection values in a texture.
  105137. */
  105138. protected _reflectionTexture: Nullable<BaseTexture>;
  105139. /**
  105140. * Stores the emissive values in a texture.
  105141. */
  105142. protected _emissiveTexture: Nullable<BaseTexture>;
  105143. /**
  105144. * AKA Specular texture in other nomenclature.
  105145. */
  105146. protected _reflectivityTexture: Nullable<BaseTexture>;
  105147. /**
  105148. * Used to switch from specular/glossiness to metallic/roughness workflow.
  105149. */
  105150. protected _metallicTexture: Nullable<BaseTexture>;
  105151. /**
  105152. * Specifies the metallic scalar of the metallic/roughness workflow.
  105153. * Can also be used to scale the metalness values of the metallic texture.
  105154. */
  105155. protected _metallic: Nullable<number>;
  105156. /**
  105157. * Specifies the roughness scalar of the metallic/roughness workflow.
  105158. * Can also be used to scale the roughness values of the metallic texture.
  105159. */
  105160. protected _roughness: Nullable<number>;
  105161. /**
  105162. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  105163. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  105164. */
  105165. protected _microSurfaceTexture: Nullable<BaseTexture>;
  105166. /**
  105167. * Stores surface normal data used to displace a mesh in a texture.
  105168. */
  105169. protected _bumpTexture: Nullable<BaseTexture>;
  105170. /**
  105171. * Stores the pre-calculated light information of a mesh in a texture.
  105172. */
  105173. protected _lightmapTexture: Nullable<BaseTexture>;
  105174. /**
  105175. * The color of a material in ambient lighting.
  105176. */
  105177. protected _ambientColor: Color3;
  105178. /**
  105179. * AKA Diffuse Color in other nomenclature.
  105180. */
  105181. protected _albedoColor: Color3;
  105182. /**
  105183. * AKA Specular Color in other nomenclature.
  105184. */
  105185. protected _reflectivityColor: Color3;
  105186. /**
  105187. * The color applied when light is reflected from a material.
  105188. */
  105189. protected _reflectionColor: Color3;
  105190. /**
  105191. * The color applied when light is emitted from a material.
  105192. */
  105193. protected _emissiveColor: Color3;
  105194. /**
  105195. * AKA Glossiness in other nomenclature.
  105196. */
  105197. protected _microSurface: number;
  105198. /**
  105199. * Specifies that the material will use the light map as a show map.
  105200. */
  105201. protected _useLightmapAsShadowmap: boolean;
  105202. /**
  105203. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  105204. * makes the reflect vector face the model (under horizon).
  105205. */
  105206. protected _useHorizonOcclusion: boolean;
  105207. /**
  105208. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  105209. * too much the area relying on ambient texture to define their ambient occlusion.
  105210. */
  105211. protected _useRadianceOcclusion: boolean;
  105212. /**
  105213. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  105214. */
  105215. protected _useAlphaFromAlbedoTexture: boolean;
  105216. /**
  105217. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  105218. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  105219. */
  105220. protected _useSpecularOverAlpha: boolean;
  105221. /**
  105222. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  105223. */
  105224. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  105225. /**
  105226. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  105227. */
  105228. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  105229. /**
  105230. * Specifies if the metallic texture contains the roughness information in its green channel.
  105231. */
  105232. protected _useRoughnessFromMetallicTextureGreen: boolean;
  105233. /**
  105234. * Specifies if the metallic texture contains the metallness information in its blue channel.
  105235. */
  105236. protected _useMetallnessFromMetallicTextureBlue: boolean;
  105237. /**
  105238. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  105239. */
  105240. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  105241. /**
  105242. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  105243. */
  105244. protected _useAmbientInGrayScale: boolean;
  105245. /**
  105246. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  105247. * The material will try to infer what glossiness each pixel should be.
  105248. */
  105249. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  105250. /**
  105251. * Defines the falloff type used in this material.
  105252. * It by default is Physical.
  105253. */
  105254. protected _lightFalloff: number;
  105255. /**
  105256. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  105257. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  105258. */
  105259. protected _useRadianceOverAlpha: boolean;
  105260. /**
  105261. * Allows using an object space normal map (instead of tangent space).
  105262. */
  105263. protected _useObjectSpaceNormalMap: boolean;
  105264. /**
  105265. * Allows using the bump map in parallax mode.
  105266. */
  105267. protected _useParallax: boolean;
  105268. /**
  105269. * Allows using the bump map in parallax occlusion mode.
  105270. */
  105271. protected _useParallaxOcclusion: boolean;
  105272. /**
  105273. * Controls the scale bias of the parallax mode.
  105274. */
  105275. protected _parallaxScaleBias: number;
  105276. /**
  105277. * If sets to true, disables all the lights affecting the material.
  105278. */
  105279. protected _disableLighting: boolean;
  105280. /**
  105281. * Number of Simultaneous lights allowed on the material.
  105282. */
  105283. protected _maxSimultaneousLights: number;
  105284. /**
  105285. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  105286. */
  105287. protected _invertNormalMapX: boolean;
  105288. /**
  105289. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  105290. */
  105291. protected _invertNormalMapY: boolean;
  105292. /**
  105293. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  105294. */
  105295. protected _twoSidedLighting: boolean;
  105296. /**
  105297. * Defines the alpha limits in alpha test mode.
  105298. */
  105299. protected _alphaCutOff: number;
  105300. /**
  105301. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  105302. */
  105303. protected _forceAlphaTest: boolean;
  105304. /**
  105305. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  105306. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  105307. */
  105308. protected _useAlphaFresnel: boolean;
  105309. /**
  105310. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  105311. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  105312. */
  105313. protected _useLinearAlphaFresnel: boolean;
  105314. /**
  105315. * The transparency mode of the material.
  105316. */
  105317. protected _transparencyMode: Nullable<number>;
  105318. /**
  105319. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  105320. * from cos thetav and roughness:
  105321. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  105322. */
  105323. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  105324. /**
  105325. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  105326. */
  105327. protected _forceIrradianceInFragment: boolean;
  105328. /**
  105329. * Force normal to face away from face.
  105330. */
  105331. protected _forceNormalForward: boolean;
  105332. /**
  105333. * Enables specular anti aliasing in the PBR shader.
  105334. * It will both interacts on the Geometry for analytical and IBL lighting.
  105335. * It also prefilter the roughness map based on the bump values.
  105336. */
  105337. protected _enableSpecularAntiAliasing: boolean;
  105338. /**
  105339. * Default configuration related to image processing available in the PBR Material.
  105340. */
  105341. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  105342. /**
  105343. * Keep track of the image processing observer to allow dispose and replace.
  105344. */
  105345. private _imageProcessingObserver;
  105346. /**
  105347. * Attaches a new image processing configuration to the PBR Material.
  105348. * @param configuration
  105349. */
  105350. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  105351. /**
  105352. * Stores the available render targets.
  105353. */
  105354. private _renderTargets;
  105355. /**
  105356. * Sets the global ambient color for the material used in lighting calculations.
  105357. */
  105358. private _globalAmbientColor;
  105359. /**
  105360. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  105361. */
  105362. private _useLogarithmicDepth;
  105363. /**
  105364. * If set to true, no lighting calculations will be applied.
  105365. */
  105366. private _unlit;
  105367. private _debugMode;
  105368. /**
  105369. * @hidden
  105370. * This is reserved for the inspector.
  105371. * Defines the material debug mode.
  105372. * It helps seeing only some components of the material while troubleshooting.
  105373. */
  105374. debugMode: number;
  105375. /**
  105376. * @hidden
  105377. * This is reserved for the inspector.
  105378. * Specify from where on screen the debug mode should start.
  105379. * The value goes from -1 (full screen) to 1 (not visible)
  105380. * It helps with side by side comparison against the final render
  105381. * This defaults to -1
  105382. */
  105383. private debugLimit;
  105384. /**
  105385. * @hidden
  105386. * This is reserved for the inspector.
  105387. * As the default viewing range might not be enough (if the ambient is really small for instance)
  105388. * You can use the factor to better multiply the final value.
  105389. */
  105390. private debugFactor;
  105391. /**
  105392. * Defines the clear coat layer parameters for the material.
  105393. */
  105394. readonly clearCoat: PBRClearCoatConfiguration;
  105395. /**
  105396. * Defines the anisotropic parameters for the material.
  105397. */
  105398. readonly anisotropy: PBRAnisotropicConfiguration;
  105399. /**
  105400. * Defines the BRDF parameters for the material.
  105401. */
  105402. readonly brdf: PBRBRDFConfiguration;
  105403. /**
  105404. * Defines the Sheen parameters for the material.
  105405. */
  105406. readonly sheen: PBRSheenConfiguration;
  105407. /**
  105408. * Defines the SubSurface parameters for the material.
  105409. */
  105410. readonly subSurface: PBRSubSurfaceConfiguration;
  105411. /**
  105412. * Custom callback helping to override the default shader used in the material.
  105413. */
  105414. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  105415. /**
  105416. * Instantiates a new PBRMaterial instance.
  105417. *
  105418. * @param name The material name
  105419. * @param scene The scene the material will be use in.
  105420. */
  105421. constructor(name: string, scene: Scene);
  105422. /**
  105423. * Gets a boolean indicating that current material needs to register RTT
  105424. */
  105425. readonly hasRenderTargetTextures: boolean;
  105426. /**
  105427. * Gets the name of the material class.
  105428. */
  105429. getClassName(): string;
  105430. /**
  105431. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  105432. */
  105433. /**
  105434. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  105435. */
  105436. useLogarithmicDepth: boolean;
  105437. /**
  105438. * Gets the current transparency mode.
  105439. */
  105440. /**
  105441. * Sets the transparency mode of the material.
  105442. *
  105443. * | Value | Type | Description |
  105444. * | ----- | ----------------------------------- | ----------- |
  105445. * | 0 | OPAQUE | |
  105446. * | 1 | ALPHATEST | |
  105447. * | 2 | ALPHABLEND | |
  105448. * | 3 | ALPHATESTANDBLEND | |
  105449. *
  105450. */
  105451. transparencyMode: Nullable<number>;
  105452. /**
  105453. * Returns true if alpha blending should be disabled.
  105454. */
  105455. private readonly _disableAlphaBlending;
  105456. /**
  105457. * Specifies whether or not this material should be rendered in alpha blend mode.
  105458. */
  105459. needAlphaBlending(): boolean;
  105460. /**
  105461. * Specifies if the mesh will require alpha blending.
  105462. * @param mesh - BJS mesh.
  105463. */
  105464. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  105465. /**
  105466. * Specifies whether or not this material should be rendered in alpha test mode.
  105467. */
  105468. needAlphaTesting(): boolean;
  105469. /**
  105470. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  105471. */
  105472. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  105473. /**
  105474. * Gets the texture used for the alpha test.
  105475. */
  105476. getAlphaTestTexture(): Nullable<BaseTexture>;
  105477. /**
  105478. * Specifies that the submesh is ready to be used.
  105479. * @param mesh - BJS mesh.
  105480. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  105481. * @param useInstances - Specifies that instances should be used.
  105482. * @returns - boolean indicating that the submesh is ready or not.
  105483. */
  105484. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  105485. /**
  105486. * Specifies if the material uses metallic roughness workflow.
  105487. * @returns boolean specifiying if the material uses metallic roughness workflow.
  105488. */
  105489. isMetallicWorkflow(): boolean;
  105490. private _prepareEffect;
  105491. private _prepareDefines;
  105492. /**
  105493. * Force shader compilation
  105494. */
  105495. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  105496. clipPlane: boolean;
  105497. }>): void;
  105498. /**
  105499. * Initializes the uniform buffer layout for the shader.
  105500. */
  105501. buildUniformLayout(): void;
  105502. /**
  105503. * Unbinds the material from the mesh
  105504. */
  105505. unbind(): void;
  105506. /**
  105507. * Binds the submesh data.
  105508. * @param world - The world matrix.
  105509. * @param mesh - The BJS mesh.
  105510. * @param subMesh - A submesh of the BJS mesh.
  105511. */
  105512. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  105513. /**
  105514. * Returns the animatable textures.
  105515. * @returns - Array of animatable textures.
  105516. */
  105517. getAnimatables(): IAnimatable[];
  105518. /**
  105519. * Returns the texture used for reflections.
  105520. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  105521. */
  105522. private _getReflectionTexture;
  105523. /**
  105524. * Returns an array of the actively used textures.
  105525. * @returns - Array of BaseTextures
  105526. */
  105527. getActiveTextures(): BaseTexture[];
  105528. /**
  105529. * Checks to see if a texture is used in the material.
  105530. * @param texture - Base texture to use.
  105531. * @returns - Boolean specifying if a texture is used in the material.
  105532. */
  105533. hasTexture(texture: BaseTexture): boolean;
  105534. /**
  105535. * Disposes the resources of the material.
  105536. * @param forceDisposeEffect - Forces the disposal of effects.
  105537. * @param forceDisposeTextures - Forces the disposal of all textures.
  105538. */
  105539. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  105540. }
  105541. }
  105542. declare module BABYLON {
  105543. /**
  105544. * The Physically based material of BJS.
  105545. *
  105546. * This offers the main features of a standard PBR material.
  105547. * For more information, please refer to the documentation :
  105548. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  105549. */
  105550. export class PBRMaterial extends PBRBaseMaterial {
  105551. /**
  105552. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  105553. */
  105554. static readonly PBRMATERIAL_OPAQUE: number;
  105555. /**
  105556. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  105557. */
  105558. static readonly PBRMATERIAL_ALPHATEST: number;
  105559. /**
  105560. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  105561. */
  105562. static readonly PBRMATERIAL_ALPHABLEND: number;
  105563. /**
  105564. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  105565. * They are also discarded below the alpha cutoff threshold to improve performances.
  105566. */
  105567. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  105568. /**
  105569. * Defines the default value of how much AO map is occluding the analytical lights
  105570. * (point spot...).
  105571. */
  105572. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  105573. /**
  105574. * Intensity of the direct lights e.g. the four lights available in your scene.
  105575. * This impacts both the direct diffuse and specular highlights.
  105576. */
  105577. directIntensity: number;
  105578. /**
  105579. * Intensity of the emissive part of the material.
  105580. * This helps controlling the emissive effect without modifying the emissive color.
  105581. */
  105582. emissiveIntensity: number;
  105583. /**
  105584. * Intensity of the environment e.g. how much the environment will light the object
  105585. * either through harmonics for rough material or through the refelction for shiny ones.
  105586. */
  105587. environmentIntensity: number;
  105588. /**
  105589. * This is a special control allowing the reduction of the specular highlights coming from the
  105590. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  105591. */
  105592. specularIntensity: number;
  105593. /**
  105594. * Debug Control allowing disabling the bump map on this material.
  105595. */
  105596. disableBumpMap: boolean;
  105597. /**
  105598. * AKA Diffuse Texture in standard nomenclature.
  105599. */
  105600. albedoTexture: BaseTexture;
  105601. /**
  105602. * AKA Occlusion Texture in other nomenclature.
  105603. */
  105604. ambientTexture: BaseTexture;
  105605. /**
  105606. * AKA Occlusion Texture Intensity in other nomenclature.
  105607. */
  105608. ambientTextureStrength: number;
  105609. /**
  105610. * Defines how much the AO map is occluding the analytical lights (point spot...).
  105611. * 1 means it completely occludes it
  105612. * 0 mean it has no impact
  105613. */
  105614. ambientTextureImpactOnAnalyticalLights: number;
  105615. /**
  105616. * Stores the alpha values in a texture.
  105617. */
  105618. opacityTexture: BaseTexture;
  105619. /**
  105620. * Stores the reflection values in a texture.
  105621. */
  105622. reflectionTexture: Nullable<BaseTexture>;
  105623. /**
  105624. * Stores the emissive values in a texture.
  105625. */
  105626. emissiveTexture: BaseTexture;
  105627. /**
  105628. * AKA Specular texture in other nomenclature.
  105629. */
  105630. reflectivityTexture: BaseTexture;
  105631. /**
  105632. * Used to switch from specular/glossiness to metallic/roughness workflow.
  105633. */
  105634. metallicTexture: BaseTexture;
  105635. /**
  105636. * Specifies the metallic scalar of the metallic/roughness workflow.
  105637. * Can also be used to scale the metalness values of the metallic texture.
  105638. */
  105639. metallic: Nullable<number>;
  105640. /**
  105641. * Specifies the roughness scalar of the metallic/roughness workflow.
  105642. * Can also be used to scale the roughness values of the metallic texture.
  105643. */
  105644. roughness: Nullable<number>;
  105645. /**
  105646. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  105647. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  105648. */
  105649. microSurfaceTexture: BaseTexture;
  105650. /**
  105651. * Stores surface normal data used to displace a mesh in a texture.
  105652. */
  105653. bumpTexture: BaseTexture;
  105654. /**
  105655. * Stores the pre-calculated light information of a mesh in a texture.
  105656. */
  105657. lightmapTexture: BaseTexture;
  105658. /**
  105659. * Stores the refracted light information in a texture.
  105660. */
  105661. refractionTexture: Nullable<BaseTexture>;
  105662. /**
  105663. * The color of a material in ambient lighting.
  105664. */
  105665. ambientColor: Color3;
  105666. /**
  105667. * AKA Diffuse Color in other nomenclature.
  105668. */
  105669. albedoColor: Color3;
  105670. /**
  105671. * AKA Specular Color in other nomenclature.
  105672. */
  105673. reflectivityColor: Color3;
  105674. /**
  105675. * The color reflected from the material.
  105676. */
  105677. reflectionColor: Color3;
  105678. /**
  105679. * The color emitted from the material.
  105680. */
  105681. emissiveColor: Color3;
  105682. /**
  105683. * AKA Glossiness in other nomenclature.
  105684. */
  105685. microSurface: number;
  105686. /**
  105687. * source material index of refraction (IOR)' / 'destination material IOR.
  105688. */
  105689. indexOfRefraction: number;
  105690. /**
  105691. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  105692. */
  105693. invertRefractionY: boolean;
  105694. /**
  105695. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  105696. * Materials half opaque for instance using refraction could benefit from this control.
  105697. */
  105698. linkRefractionWithTransparency: boolean;
  105699. /**
  105700. * If true, the light map contains occlusion information instead of lighting info.
  105701. */
  105702. useLightmapAsShadowmap: boolean;
  105703. /**
  105704. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  105705. */
  105706. useAlphaFromAlbedoTexture: boolean;
  105707. /**
  105708. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  105709. */
  105710. forceAlphaTest: boolean;
  105711. /**
  105712. * Defines the alpha limits in alpha test mode.
  105713. */
  105714. alphaCutOff: number;
  105715. /**
  105716. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  105717. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  105718. */
  105719. useSpecularOverAlpha: boolean;
  105720. /**
  105721. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  105722. */
  105723. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  105724. /**
  105725. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  105726. */
  105727. useRoughnessFromMetallicTextureAlpha: boolean;
  105728. /**
  105729. * Specifies if the metallic texture contains the roughness information in its green channel.
  105730. */
  105731. useRoughnessFromMetallicTextureGreen: boolean;
  105732. /**
  105733. * Specifies if the metallic texture contains the metallness information in its blue channel.
  105734. */
  105735. useMetallnessFromMetallicTextureBlue: boolean;
  105736. /**
  105737. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  105738. */
  105739. useAmbientOcclusionFromMetallicTextureRed: boolean;
  105740. /**
  105741. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  105742. */
  105743. useAmbientInGrayScale: boolean;
  105744. /**
  105745. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  105746. * The material will try to infer what glossiness each pixel should be.
  105747. */
  105748. useAutoMicroSurfaceFromReflectivityMap: boolean;
  105749. /**
  105750. * BJS is using an harcoded light falloff based on a manually sets up range.
  105751. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  105752. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  105753. */
  105754. /**
  105755. * BJS is using an harcoded light falloff based on a manually sets up range.
  105756. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  105757. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  105758. */
  105759. usePhysicalLightFalloff: boolean;
  105760. /**
  105761. * In order to support the falloff compatibility with gltf, a special mode has been added
  105762. * to reproduce the gltf light falloff.
  105763. */
  105764. /**
  105765. * In order to support the falloff compatibility with gltf, a special mode has been added
  105766. * to reproduce the gltf light falloff.
  105767. */
  105768. useGLTFLightFalloff: boolean;
  105769. /**
  105770. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  105771. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  105772. */
  105773. useRadianceOverAlpha: boolean;
  105774. /**
  105775. * Allows using an object space normal map (instead of tangent space).
  105776. */
  105777. useObjectSpaceNormalMap: boolean;
  105778. /**
  105779. * Allows using the bump map in parallax mode.
  105780. */
  105781. useParallax: boolean;
  105782. /**
  105783. * Allows using the bump map in parallax occlusion mode.
  105784. */
  105785. useParallaxOcclusion: boolean;
  105786. /**
  105787. * Controls the scale bias of the parallax mode.
  105788. */
  105789. parallaxScaleBias: number;
  105790. /**
  105791. * If sets to true, disables all the lights affecting the material.
  105792. */
  105793. disableLighting: boolean;
  105794. /**
  105795. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  105796. */
  105797. forceIrradianceInFragment: boolean;
  105798. /**
  105799. * Number of Simultaneous lights allowed on the material.
  105800. */
  105801. maxSimultaneousLights: number;
  105802. /**
  105803. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  105804. */
  105805. invertNormalMapX: boolean;
  105806. /**
  105807. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  105808. */
  105809. invertNormalMapY: boolean;
  105810. /**
  105811. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  105812. */
  105813. twoSidedLighting: boolean;
  105814. /**
  105815. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  105816. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  105817. */
  105818. useAlphaFresnel: boolean;
  105819. /**
  105820. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  105821. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  105822. */
  105823. useLinearAlphaFresnel: boolean;
  105824. /**
  105825. * Let user defines the brdf lookup texture used for IBL.
  105826. * A default 8bit version is embedded but you could point at :
  105827. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  105828. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  105829. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  105830. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  105831. */
  105832. environmentBRDFTexture: Nullable<BaseTexture>;
  105833. /**
  105834. * Force normal to face away from face.
  105835. */
  105836. forceNormalForward: boolean;
  105837. /**
  105838. * Enables specular anti aliasing in the PBR shader.
  105839. * It will both interacts on the Geometry for analytical and IBL lighting.
  105840. * It also prefilter the roughness map based on the bump values.
  105841. */
  105842. enableSpecularAntiAliasing: boolean;
  105843. /**
  105844. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  105845. * makes the reflect vector face the model (under horizon).
  105846. */
  105847. useHorizonOcclusion: boolean;
  105848. /**
  105849. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  105850. * too much the area relying on ambient texture to define their ambient occlusion.
  105851. */
  105852. useRadianceOcclusion: boolean;
  105853. /**
  105854. * If set to true, no lighting calculations will be applied.
  105855. */
  105856. unlit: boolean;
  105857. /**
  105858. * Gets the image processing configuration used either in this material.
  105859. */
  105860. /**
  105861. * Sets the Default image processing configuration used either in the this material.
  105862. *
  105863. * If sets to null, the scene one is in use.
  105864. */
  105865. imageProcessingConfiguration: ImageProcessingConfiguration;
  105866. /**
  105867. * Gets wether the color curves effect is enabled.
  105868. */
  105869. /**
  105870. * Sets wether the color curves effect is enabled.
  105871. */
  105872. cameraColorCurvesEnabled: boolean;
  105873. /**
  105874. * Gets wether the color grading effect is enabled.
  105875. */
  105876. /**
  105877. * Gets wether the color grading effect is enabled.
  105878. */
  105879. cameraColorGradingEnabled: boolean;
  105880. /**
  105881. * Gets wether tonemapping is enabled or not.
  105882. */
  105883. /**
  105884. * Sets wether tonemapping is enabled or not
  105885. */
  105886. cameraToneMappingEnabled: boolean;
  105887. /**
  105888. * The camera exposure used on this material.
  105889. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  105890. * This corresponds to a photographic exposure.
  105891. */
  105892. /**
  105893. * The camera exposure used on this material.
  105894. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  105895. * This corresponds to a photographic exposure.
  105896. */
  105897. cameraExposure: number;
  105898. /**
  105899. * Gets The camera contrast used on this material.
  105900. */
  105901. /**
  105902. * Sets The camera contrast used on this material.
  105903. */
  105904. cameraContrast: number;
  105905. /**
  105906. * Gets the Color Grading 2D Lookup Texture.
  105907. */
  105908. /**
  105909. * Sets the Color Grading 2D Lookup Texture.
  105910. */
  105911. cameraColorGradingTexture: Nullable<BaseTexture>;
  105912. /**
  105913. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  105914. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  105915. * 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;
  105916. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  105917. */
  105918. /**
  105919. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  105920. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  105921. * 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;
  105922. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  105923. */
  105924. cameraColorCurves: Nullable<ColorCurves>;
  105925. /**
  105926. * Instantiates a new PBRMaterial instance.
  105927. *
  105928. * @param name The material name
  105929. * @param scene The scene the material will be use in.
  105930. */
  105931. constructor(name: string, scene: Scene);
  105932. /**
  105933. * Returns the name of this material class.
  105934. */
  105935. getClassName(): string;
  105936. /**
  105937. * Makes a duplicate of the current material.
  105938. * @param name - name to use for the new material.
  105939. */
  105940. clone(name: string): PBRMaterial;
  105941. /**
  105942. * Serializes this PBR Material.
  105943. * @returns - An object with the serialized material.
  105944. */
  105945. serialize(): any;
  105946. /**
  105947. * Parses a PBR Material from a serialized object.
  105948. * @param source - Serialized object.
  105949. * @param scene - BJS scene instance.
  105950. * @param rootUrl - url for the scene object
  105951. * @returns - PBRMaterial
  105952. */
  105953. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  105954. }
  105955. }
  105956. declare module BABYLON {
  105957. /**
  105958. * Direct draw surface info
  105959. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  105960. */
  105961. export interface DDSInfo {
  105962. /**
  105963. * Width of the texture
  105964. */
  105965. width: number;
  105966. /**
  105967. * Width of the texture
  105968. */
  105969. height: number;
  105970. /**
  105971. * Number of Mipmaps for the texture
  105972. * @see https://en.wikipedia.org/wiki/Mipmap
  105973. */
  105974. mipmapCount: number;
  105975. /**
  105976. * If the textures format is a known fourCC format
  105977. * @see https://www.fourcc.org/
  105978. */
  105979. isFourCC: boolean;
  105980. /**
  105981. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  105982. */
  105983. isRGB: boolean;
  105984. /**
  105985. * If the texture is a lumincance format
  105986. */
  105987. isLuminance: boolean;
  105988. /**
  105989. * If this is a cube texture
  105990. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  105991. */
  105992. isCube: boolean;
  105993. /**
  105994. * If the texture is a compressed format eg. FOURCC_DXT1
  105995. */
  105996. isCompressed: boolean;
  105997. /**
  105998. * The dxgiFormat of the texture
  105999. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  106000. */
  106001. dxgiFormat: number;
  106002. /**
  106003. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  106004. */
  106005. textureType: number;
  106006. /**
  106007. * Sphericle polynomial created for the dds texture
  106008. */
  106009. sphericalPolynomial?: SphericalPolynomial;
  106010. }
  106011. /**
  106012. * Class used to provide DDS decompression tools
  106013. */
  106014. export class DDSTools {
  106015. /**
  106016. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  106017. */
  106018. static StoreLODInAlphaChannel: boolean;
  106019. /**
  106020. * Gets DDS information from an array buffer
  106021. * @param arrayBuffer defines the array buffer to read data from
  106022. * @returns the DDS information
  106023. */
  106024. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  106025. private static _FloatView;
  106026. private static _Int32View;
  106027. private static _ToHalfFloat;
  106028. private static _FromHalfFloat;
  106029. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  106030. private static _GetHalfFloatRGBAArrayBuffer;
  106031. private static _GetFloatRGBAArrayBuffer;
  106032. private static _GetFloatAsUIntRGBAArrayBuffer;
  106033. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  106034. private static _GetRGBAArrayBuffer;
  106035. private static _ExtractLongWordOrder;
  106036. private static _GetRGBArrayBuffer;
  106037. private static _GetLuminanceArrayBuffer;
  106038. /**
  106039. * Uploads DDS Levels to a Babylon Texture
  106040. * @hidden
  106041. */
  106042. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  106043. }
  106044. interface Engine {
  106045. /**
  106046. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  106047. * @param rootUrl defines the url where the file to load is located
  106048. * @param scene defines the current scene
  106049. * @param lodScale defines scale to apply to the mip map selection
  106050. * @param lodOffset defines offset to apply to the mip map selection
  106051. * @param onLoad defines an optional callback raised when the texture is loaded
  106052. * @param onError defines an optional callback raised if there is an issue to load the texture
  106053. * @param format defines the format of the data
  106054. * @param forcedExtension defines the extension to use to pick the right loader
  106055. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  106056. * @returns the cube texture as an InternalTexture
  106057. */
  106058. 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;
  106059. }
  106060. }
  106061. declare module BABYLON {
  106062. /**
  106063. * Implementation of the DDS Texture Loader.
  106064. * @hidden
  106065. */
  106066. export class _DDSTextureLoader implements IInternalTextureLoader {
  106067. /**
  106068. * Defines wether the loader supports cascade loading the different faces.
  106069. */
  106070. readonly supportCascades: boolean;
  106071. /**
  106072. * This returns if the loader support the current file information.
  106073. * @param extension defines the file extension of the file being loaded
  106074. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106075. * @param fallback defines the fallback internal texture if any
  106076. * @param isBase64 defines whether the texture is encoded as a base64
  106077. * @param isBuffer defines whether the texture data are stored as a buffer
  106078. * @returns true if the loader can load the specified file
  106079. */
  106080. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  106081. /**
  106082. * Transform the url before loading if required.
  106083. * @param rootUrl the url of the texture
  106084. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106085. * @returns the transformed texture
  106086. */
  106087. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  106088. /**
  106089. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  106090. * @param rootUrl the url of the texture
  106091. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106092. * @returns the fallback texture
  106093. */
  106094. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  106095. /**
  106096. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  106097. * @param data contains the texture data
  106098. * @param texture defines the BabylonJS internal texture
  106099. * @param createPolynomials will be true if polynomials have been requested
  106100. * @param onLoad defines the callback to trigger once the texture is ready
  106101. * @param onError defines the callback to trigger in case of error
  106102. */
  106103. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  106104. /**
  106105. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  106106. * @param data contains the texture data
  106107. * @param texture defines the BabylonJS internal texture
  106108. * @param callback defines the method to call once ready to upload
  106109. */
  106110. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  106111. }
  106112. }
  106113. declare module BABYLON {
  106114. /** @hidden */
  106115. export var rgbdEncodePixelShader: {
  106116. name: string;
  106117. shader: string;
  106118. };
  106119. }
  106120. declare module BABYLON {
  106121. /**
  106122. * Raw texture data and descriptor sufficient for WebGL texture upload
  106123. */
  106124. export interface EnvironmentTextureInfo {
  106125. /**
  106126. * Version of the environment map
  106127. */
  106128. version: number;
  106129. /**
  106130. * Width of image
  106131. */
  106132. width: number;
  106133. /**
  106134. * Irradiance information stored in the file.
  106135. */
  106136. irradiance: any;
  106137. /**
  106138. * Specular information stored in the file.
  106139. */
  106140. specular: any;
  106141. }
  106142. /**
  106143. * Sets of helpers addressing the serialization and deserialization of environment texture
  106144. * stored in a BabylonJS env file.
  106145. * Those files are usually stored as .env files.
  106146. */
  106147. export class EnvironmentTextureTools {
  106148. /**
  106149. * Magic number identifying the env file.
  106150. */
  106151. private static _MagicBytes;
  106152. /**
  106153. * Gets the environment info from an env file.
  106154. * @param data The array buffer containing the .env bytes.
  106155. * @returns the environment file info (the json header) if successfully parsed.
  106156. */
  106157. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  106158. /**
  106159. * Creates an environment texture from a loaded cube texture.
  106160. * @param texture defines the cube texture to convert in env file
  106161. * @return a promise containing the environment data if succesfull.
  106162. */
  106163. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  106164. /**
  106165. * Creates a JSON representation of the spherical data.
  106166. * @param texture defines the texture containing the polynomials
  106167. * @return the JSON representation of the spherical info
  106168. */
  106169. private static _CreateEnvTextureIrradiance;
  106170. /**
  106171. * Uploads the texture info contained in the env file to the GPU.
  106172. * @param texture defines the internal texture to upload to
  106173. * @param arrayBuffer defines the buffer cotaining the data to load
  106174. * @param info defines the texture info retrieved through the GetEnvInfo method
  106175. * @returns a promise
  106176. */
  106177. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  106178. /**
  106179. * Uploads the levels of image data to the GPU.
  106180. * @param texture defines the internal texture to upload to
  106181. * @param imageData defines the array buffer views of image data [mipmap][face]
  106182. * @returns a promise
  106183. */
  106184. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  106185. /**
  106186. * Uploads spherical polynomials information to the texture.
  106187. * @param texture defines the texture we are trying to upload the information to
  106188. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  106189. */
  106190. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  106191. /** @hidden */
  106192. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  106193. }
  106194. }
  106195. declare module BABYLON {
  106196. /**
  106197. * Implementation of the ENV Texture Loader.
  106198. * @hidden
  106199. */
  106200. export class _ENVTextureLoader implements IInternalTextureLoader {
  106201. /**
  106202. * Defines wether the loader supports cascade loading the different faces.
  106203. */
  106204. readonly supportCascades: boolean;
  106205. /**
  106206. * This returns if the loader support the current file information.
  106207. * @param extension defines the file extension of the file being loaded
  106208. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106209. * @param fallback defines the fallback internal texture if any
  106210. * @param isBase64 defines whether the texture is encoded as a base64
  106211. * @param isBuffer defines whether the texture data are stored as a buffer
  106212. * @returns true if the loader can load the specified file
  106213. */
  106214. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  106215. /**
  106216. * Transform the url before loading if required.
  106217. * @param rootUrl the url of the texture
  106218. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106219. * @returns the transformed texture
  106220. */
  106221. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  106222. /**
  106223. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  106224. * @param rootUrl the url of the texture
  106225. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106226. * @returns the fallback texture
  106227. */
  106228. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  106229. /**
  106230. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  106231. * @param data contains the texture data
  106232. * @param texture defines the BabylonJS internal texture
  106233. * @param createPolynomials will be true if polynomials have been requested
  106234. * @param onLoad defines the callback to trigger once the texture is ready
  106235. * @param onError defines the callback to trigger in case of error
  106236. */
  106237. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  106238. /**
  106239. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  106240. * @param data contains the texture data
  106241. * @param texture defines the BabylonJS internal texture
  106242. * @param callback defines the method to call once ready to upload
  106243. */
  106244. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  106245. }
  106246. }
  106247. declare module BABYLON {
  106248. /**
  106249. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  106250. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  106251. */
  106252. export class KhronosTextureContainer {
  106253. /** contents of the KTX container file */
  106254. arrayBuffer: any;
  106255. private static HEADER_LEN;
  106256. private static COMPRESSED_2D;
  106257. private static COMPRESSED_3D;
  106258. private static TEX_2D;
  106259. private static TEX_3D;
  106260. /**
  106261. * Gets the openGL type
  106262. */
  106263. glType: number;
  106264. /**
  106265. * Gets the openGL type size
  106266. */
  106267. glTypeSize: number;
  106268. /**
  106269. * Gets the openGL format
  106270. */
  106271. glFormat: number;
  106272. /**
  106273. * Gets the openGL internal format
  106274. */
  106275. glInternalFormat: number;
  106276. /**
  106277. * Gets the base internal format
  106278. */
  106279. glBaseInternalFormat: number;
  106280. /**
  106281. * Gets image width in pixel
  106282. */
  106283. pixelWidth: number;
  106284. /**
  106285. * Gets image height in pixel
  106286. */
  106287. pixelHeight: number;
  106288. /**
  106289. * Gets image depth in pixels
  106290. */
  106291. pixelDepth: number;
  106292. /**
  106293. * Gets the number of array elements
  106294. */
  106295. numberOfArrayElements: number;
  106296. /**
  106297. * Gets the number of faces
  106298. */
  106299. numberOfFaces: number;
  106300. /**
  106301. * Gets the number of mipmap levels
  106302. */
  106303. numberOfMipmapLevels: number;
  106304. /**
  106305. * Gets the bytes of key value data
  106306. */
  106307. bytesOfKeyValueData: number;
  106308. /**
  106309. * Gets the load type
  106310. */
  106311. loadType: number;
  106312. /**
  106313. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  106314. */
  106315. isInvalid: boolean;
  106316. /**
  106317. * Creates a new KhronosTextureContainer
  106318. * @param arrayBuffer contents of the KTX container file
  106319. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  106320. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  106321. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  106322. */
  106323. constructor(
  106324. /** contents of the KTX container file */
  106325. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  106326. /**
  106327. * Uploads KTX content to a Babylon Texture.
  106328. * It is assumed that the texture has already been created & is currently bound
  106329. * @hidden
  106330. */
  106331. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  106332. private _upload2DCompressedLevels;
  106333. }
  106334. }
  106335. declare module BABYLON {
  106336. /**
  106337. * Implementation of the KTX Texture Loader.
  106338. * @hidden
  106339. */
  106340. export class _KTXTextureLoader implements IInternalTextureLoader {
  106341. /**
  106342. * Defines wether the loader supports cascade loading the different faces.
  106343. */
  106344. readonly supportCascades: boolean;
  106345. /**
  106346. * This returns if the loader support the current file information.
  106347. * @param extension defines the file extension of the file being loaded
  106348. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106349. * @param fallback defines the fallback internal texture if any
  106350. * @param isBase64 defines whether the texture is encoded as a base64
  106351. * @param isBuffer defines whether the texture data are stored as a buffer
  106352. * @returns true if the loader can load the specified file
  106353. */
  106354. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  106355. /**
  106356. * Transform the url before loading if required.
  106357. * @param rootUrl the url of the texture
  106358. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106359. * @returns the transformed texture
  106360. */
  106361. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  106362. /**
  106363. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  106364. * @param rootUrl the url of the texture
  106365. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106366. * @returns the fallback texture
  106367. */
  106368. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  106369. /**
  106370. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  106371. * @param data contains the texture data
  106372. * @param texture defines the BabylonJS internal texture
  106373. * @param createPolynomials will be true if polynomials have been requested
  106374. * @param onLoad defines the callback to trigger once the texture is ready
  106375. * @param onError defines the callback to trigger in case of error
  106376. */
  106377. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  106378. /**
  106379. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  106380. * @param data contains the texture data
  106381. * @param texture defines the BabylonJS internal texture
  106382. * @param callback defines the method to call once ready to upload
  106383. */
  106384. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  106385. }
  106386. }
  106387. declare module BABYLON {
  106388. /** @hidden */
  106389. export var _forceSceneHelpersToBundle: boolean;
  106390. interface Scene {
  106391. /**
  106392. * Creates a default light for the scene.
  106393. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  106394. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  106395. */
  106396. createDefaultLight(replace?: boolean): void;
  106397. /**
  106398. * Creates a default camera for the scene.
  106399. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  106400. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  106401. * @param replace has default false, when true replaces the active camera in the scene
  106402. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  106403. */
  106404. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  106405. /**
  106406. * Creates a default camera and a default light.
  106407. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  106408. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  106409. * @param replace has the default false, when true replaces the active camera/light in the scene
  106410. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  106411. */
  106412. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  106413. /**
  106414. * Creates a new sky box
  106415. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  106416. * @param environmentTexture defines the texture to use as environment texture
  106417. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  106418. * @param scale defines the overall scale of the skybox
  106419. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  106420. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  106421. * @returns a new mesh holding the sky box
  106422. */
  106423. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  106424. /**
  106425. * Creates a new environment
  106426. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  106427. * @param options defines the options you can use to configure the environment
  106428. * @returns the new EnvironmentHelper
  106429. */
  106430. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  106431. /**
  106432. * Creates a new VREXperienceHelper
  106433. * @see http://doc.babylonjs.com/how_to/webvr_helper
  106434. * @param webVROptions defines the options used to create the new VREXperienceHelper
  106435. * @returns a new VREXperienceHelper
  106436. */
  106437. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  106438. /**
  106439. * Creates a new XREXperienceHelper
  106440. * @see http://doc.babylonjs.com/how_to/webxr
  106441. * @returns a promise for a new XREXperienceHelper
  106442. */
  106443. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  106444. }
  106445. }
  106446. declare module BABYLON {
  106447. /**
  106448. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  106449. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  106450. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  106451. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  106452. */
  106453. export class VideoDome extends TransformNode {
  106454. /**
  106455. * Define the video source as a Monoscopic panoramic 360 video.
  106456. */
  106457. static readonly MODE_MONOSCOPIC: number;
  106458. /**
  106459. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  106460. */
  106461. static readonly MODE_TOPBOTTOM: number;
  106462. /**
  106463. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  106464. */
  106465. static readonly MODE_SIDEBYSIDE: number;
  106466. private _useDirectMapping;
  106467. /**
  106468. * The video texture being displayed on the sphere
  106469. */
  106470. protected _videoTexture: VideoTexture;
  106471. /**
  106472. * Gets the video texture being displayed on the sphere
  106473. */
  106474. readonly videoTexture: VideoTexture;
  106475. /**
  106476. * The skybox material
  106477. */
  106478. protected _material: BackgroundMaterial;
  106479. /**
  106480. * The surface used for the skybox
  106481. */
  106482. protected _mesh: Mesh;
  106483. /**
  106484. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  106485. * Also see the options.resolution property.
  106486. */
  106487. fovMultiplier: number;
  106488. private _videoMode;
  106489. /**
  106490. * Gets or set the current video mode for the video. It can be:
  106491. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  106492. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  106493. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  106494. */
  106495. videoMode: number;
  106496. /**
  106497. * Oberserver used in Stereoscopic VR Mode.
  106498. */
  106499. private _onBeforeCameraRenderObserver;
  106500. /**
  106501. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  106502. * @param name Element's name, child elements will append suffixes for their own names.
  106503. * @param urlsOrVideo defines the url(s) or the video element to use
  106504. * @param options An object containing optional or exposed sub element properties
  106505. */
  106506. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  106507. resolution?: number;
  106508. clickToPlay?: boolean;
  106509. autoPlay?: boolean;
  106510. loop?: boolean;
  106511. size?: number;
  106512. poster?: string;
  106513. faceForward?: boolean;
  106514. useDirectMapping?: boolean;
  106515. }, scene: Scene);
  106516. private _changeVideoMode;
  106517. /**
  106518. * Releases resources associated with this node.
  106519. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  106520. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  106521. */
  106522. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  106523. }
  106524. }
  106525. declare module BABYLON {
  106526. /**
  106527. * This class can be used to get instrumentation data from a Babylon engine
  106528. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  106529. */
  106530. export class EngineInstrumentation implements IDisposable {
  106531. /**
  106532. * Define the instrumented engine.
  106533. */
  106534. engine: Engine;
  106535. private _captureGPUFrameTime;
  106536. private _gpuFrameTimeToken;
  106537. private _gpuFrameTime;
  106538. private _captureShaderCompilationTime;
  106539. private _shaderCompilationTime;
  106540. private _onBeginFrameObserver;
  106541. private _onEndFrameObserver;
  106542. private _onBeforeShaderCompilationObserver;
  106543. private _onAfterShaderCompilationObserver;
  106544. /**
  106545. * Gets the perf counter used for GPU frame time
  106546. */
  106547. readonly gpuFrameTimeCounter: PerfCounter;
  106548. /**
  106549. * Gets the GPU frame time capture status
  106550. */
  106551. /**
  106552. * Enable or disable the GPU frame time capture
  106553. */
  106554. captureGPUFrameTime: boolean;
  106555. /**
  106556. * Gets the perf counter used for shader compilation time
  106557. */
  106558. readonly shaderCompilationTimeCounter: PerfCounter;
  106559. /**
  106560. * Gets the shader compilation time capture status
  106561. */
  106562. /**
  106563. * Enable or disable the shader compilation time capture
  106564. */
  106565. captureShaderCompilationTime: boolean;
  106566. /**
  106567. * Instantiates a new engine instrumentation.
  106568. * This class can be used to get instrumentation data from a Babylon engine
  106569. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  106570. * @param engine Defines the engine to instrument
  106571. */
  106572. constructor(
  106573. /**
  106574. * Define the instrumented engine.
  106575. */
  106576. engine: Engine);
  106577. /**
  106578. * Dispose and release associated resources.
  106579. */
  106580. dispose(): void;
  106581. }
  106582. }
  106583. declare module BABYLON {
  106584. /**
  106585. * This class can be used to get instrumentation data from a Babylon engine
  106586. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  106587. */
  106588. export class SceneInstrumentation implements IDisposable {
  106589. /**
  106590. * Defines the scene to instrument
  106591. */
  106592. scene: Scene;
  106593. private _captureActiveMeshesEvaluationTime;
  106594. private _activeMeshesEvaluationTime;
  106595. private _captureRenderTargetsRenderTime;
  106596. private _renderTargetsRenderTime;
  106597. private _captureFrameTime;
  106598. private _frameTime;
  106599. private _captureRenderTime;
  106600. private _renderTime;
  106601. private _captureInterFrameTime;
  106602. private _interFrameTime;
  106603. private _captureParticlesRenderTime;
  106604. private _particlesRenderTime;
  106605. private _captureSpritesRenderTime;
  106606. private _spritesRenderTime;
  106607. private _capturePhysicsTime;
  106608. private _physicsTime;
  106609. private _captureAnimationsTime;
  106610. private _animationsTime;
  106611. private _captureCameraRenderTime;
  106612. private _cameraRenderTime;
  106613. private _onBeforeActiveMeshesEvaluationObserver;
  106614. private _onAfterActiveMeshesEvaluationObserver;
  106615. private _onBeforeRenderTargetsRenderObserver;
  106616. private _onAfterRenderTargetsRenderObserver;
  106617. private _onAfterRenderObserver;
  106618. private _onBeforeDrawPhaseObserver;
  106619. private _onAfterDrawPhaseObserver;
  106620. private _onBeforeAnimationsObserver;
  106621. private _onBeforeParticlesRenderingObserver;
  106622. private _onAfterParticlesRenderingObserver;
  106623. private _onBeforeSpritesRenderingObserver;
  106624. private _onAfterSpritesRenderingObserver;
  106625. private _onBeforePhysicsObserver;
  106626. private _onAfterPhysicsObserver;
  106627. private _onAfterAnimationsObserver;
  106628. private _onBeforeCameraRenderObserver;
  106629. private _onAfterCameraRenderObserver;
  106630. /**
  106631. * Gets the perf counter used for active meshes evaluation time
  106632. */
  106633. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  106634. /**
  106635. * Gets the active meshes evaluation time capture status
  106636. */
  106637. /**
  106638. * Enable or disable the active meshes evaluation time capture
  106639. */
  106640. captureActiveMeshesEvaluationTime: boolean;
  106641. /**
  106642. * Gets the perf counter used for render targets render time
  106643. */
  106644. readonly renderTargetsRenderTimeCounter: PerfCounter;
  106645. /**
  106646. * Gets the render targets render time capture status
  106647. */
  106648. /**
  106649. * Enable or disable the render targets render time capture
  106650. */
  106651. captureRenderTargetsRenderTime: boolean;
  106652. /**
  106653. * Gets the perf counter used for particles render time
  106654. */
  106655. readonly particlesRenderTimeCounter: PerfCounter;
  106656. /**
  106657. * Gets the particles render time capture status
  106658. */
  106659. /**
  106660. * Enable or disable the particles render time capture
  106661. */
  106662. captureParticlesRenderTime: boolean;
  106663. /**
  106664. * Gets the perf counter used for sprites render time
  106665. */
  106666. readonly spritesRenderTimeCounter: PerfCounter;
  106667. /**
  106668. * Gets the sprites render time capture status
  106669. */
  106670. /**
  106671. * Enable or disable the sprites render time capture
  106672. */
  106673. captureSpritesRenderTime: boolean;
  106674. /**
  106675. * Gets the perf counter used for physics time
  106676. */
  106677. readonly physicsTimeCounter: PerfCounter;
  106678. /**
  106679. * Gets the physics time capture status
  106680. */
  106681. /**
  106682. * Enable or disable the physics time capture
  106683. */
  106684. capturePhysicsTime: boolean;
  106685. /**
  106686. * Gets the perf counter used for animations time
  106687. */
  106688. readonly animationsTimeCounter: PerfCounter;
  106689. /**
  106690. * Gets the animations time capture status
  106691. */
  106692. /**
  106693. * Enable or disable the animations time capture
  106694. */
  106695. captureAnimationsTime: boolean;
  106696. /**
  106697. * Gets the perf counter used for frame time capture
  106698. */
  106699. readonly frameTimeCounter: PerfCounter;
  106700. /**
  106701. * Gets the frame time capture status
  106702. */
  106703. /**
  106704. * Enable or disable the frame time capture
  106705. */
  106706. captureFrameTime: boolean;
  106707. /**
  106708. * Gets the perf counter used for inter-frames time capture
  106709. */
  106710. readonly interFrameTimeCounter: PerfCounter;
  106711. /**
  106712. * Gets the inter-frames time capture status
  106713. */
  106714. /**
  106715. * Enable or disable the inter-frames time capture
  106716. */
  106717. captureInterFrameTime: boolean;
  106718. /**
  106719. * Gets the perf counter used for render time capture
  106720. */
  106721. readonly renderTimeCounter: PerfCounter;
  106722. /**
  106723. * Gets the render time capture status
  106724. */
  106725. /**
  106726. * Enable or disable the render time capture
  106727. */
  106728. captureRenderTime: boolean;
  106729. /**
  106730. * Gets the perf counter used for camera render time capture
  106731. */
  106732. readonly cameraRenderTimeCounter: PerfCounter;
  106733. /**
  106734. * Gets the camera render time capture status
  106735. */
  106736. /**
  106737. * Enable or disable the camera render time capture
  106738. */
  106739. captureCameraRenderTime: boolean;
  106740. /**
  106741. * Gets the perf counter used for draw calls
  106742. */
  106743. readonly drawCallsCounter: PerfCounter;
  106744. /**
  106745. * Instantiates a new scene instrumentation.
  106746. * This class can be used to get instrumentation data from a Babylon engine
  106747. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  106748. * @param scene Defines the scene to instrument
  106749. */
  106750. constructor(
  106751. /**
  106752. * Defines the scene to instrument
  106753. */
  106754. scene: Scene);
  106755. /**
  106756. * Dispose and release associated resources.
  106757. */
  106758. dispose(): void;
  106759. }
  106760. }
  106761. declare module BABYLON {
  106762. /** @hidden */
  106763. export var glowMapGenerationPixelShader: {
  106764. name: string;
  106765. shader: string;
  106766. };
  106767. }
  106768. declare module BABYLON {
  106769. /** @hidden */
  106770. export var glowMapGenerationVertexShader: {
  106771. name: string;
  106772. shader: string;
  106773. };
  106774. }
  106775. declare module BABYLON {
  106776. /**
  106777. * Effect layer options. This helps customizing the behaviour
  106778. * of the effect layer.
  106779. */
  106780. export interface IEffectLayerOptions {
  106781. /**
  106782. * Multiplication factor apply to the canvas size to compute the render target size
  106783. * used to generated the objects (the smaller the faster).
  106784. */
  106785. mainTextureRatio: number;
  106786. /**
  106787. * Enforces a fixed size texture to ensure effect stability across devices.
  106788. */
  106789. mainTextureFixedSize?: number;
  106790. /**
  106791. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  106792. */
  106793. alphaBlendingMode: number;
  106794. /**
  106795. * The camera attached to the layer.
  106796. */
  106797. camera: Nullable<Camera>;
  106798. /**
  106799. * The rendering group to draw the layer in.
  106800. */
  106801. renderingGroupId: number;
  106802. }
  106803. /**
  106804. * The effect layer Helps adding post process effect blended with the main pass.
  106805. *
  106806. * This can be for instance use to generate glow or higlight effects on the scene.
  106807. *
  106808. * The effect layer class can not be used directly and is intented to inherited from to be
  106809. * customized per effects.
  106810. */
  106811. export abstract class EffectLayer {
  106812. private _vertexBuffers;
  106813. private _indexBuffer;
  106814. private _cachedDefines;
  106815. private _effectLayerMapGenerationEffect;
  106816. private _effectLayerOptions;
  106817. private _mergeEffect;
  106818. protected _scene: Scene;
  106819. protected _engine: Engine;
  106820. protected _maxSize: number;
  106821. protected _mainTextureDesiredSize: ISize;
  106822. protected _mainTexture: RenderTargetTexture;
  106823. protected _shouldRender: boolean;
  106824. protected _postProcesses: PostProcess[];
  106825. protected _textures: BaseTexture[];
  106826. protected _emissiveTextureAndColor: {
  106827. texture: Nullable<BaseTexture>;
  106828. color: Color4;
  106829. };
  106830. /**
  106831. * The name of the layer
  106832. */
  106833. name: string;
  106834. /**
  106835. * The clear color of the texture used to generate the glow map.
  106836. */
  106837. neutralColor: Color4;
  106838. /**
  106839. * Specifies wether the highlight layer is enabled or not.
  106840. */
  106841. isEnabled: boolean;
  106842. /**
  106843. * Gets the camera attached to the layer.
  106844. */
  106845. readonly camera: Nullable<Camera>;
  106846. /**
  106847. * Gets the rendering group id the layer should render in.
  106848. */
  106849. readonly renderingGroupId: number;
  106850. /**
  106851. * An event triggered when the effect layer has been disposed.
  106852. */
  106853. onDisposeObservable: Observable<EffectLayer>;
  106854. /**
  106855. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  106856. */
  106857. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  106858. /**
  106859. * An event triggered when the generated texture is being merged in the scene.
  106860. */
  106861. onBeforeComposeObservable: Observable<EffectLayer>;
  106862. /**
  106863. * An event triggered when the generated texture has been merged in the scene.
  106864. */
  106865. onAfterComposeObservable: Observable<EffectLayer>;
  106866. /**
  106867. * An event triggered when the efffect layer changes its size.
  106868. */
  106869. onSizeChangedObservable: Observable<EffectLayer>;
  106870. /** @hidden */
  106871. static _SceneComponentInitialization: (scene: Scene) => void;
  106872. /**
  106873. * Instantiates a new effect Layer and references it in the scene.
  106874. * @param name The name of the layer
  106875. * @param scene The scene to use the layer in
  106876. */
  106877. constructor(
  106878. /** The Friendly of the effect in the scene */
  106879. name: string, scene: Scene);
  106880. /**
  106881. * Get the effect name of the layer.
  106882. * @return The effect name
  106883. */
  106884. abstract getEffectName(): string;
  106885. /**
  106886. * Checks for the readiness of the element composing the layer.
  106887. * @param subMesh the mesh to check for
  106888. * @param useInstances specify wether or not to use instances to render the mesh
  106889. * @return true if ready otherwise, false
  106890. */
  106891. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  106892. /**
  106893. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  106894. * @returns true if the effect requires stencil during the main canvas render pass.
  106895. */
  106896. abstract needStencil(): boolean;
  106897. /**
  106898. * Create the merge effect. This is the shader use to blit the information back
  106899. * to the main canvas at the end of the scene rendering.
  106900. * @returns The effect containing the shader used to merge the effect on the main canvas
  106901. */
  106902. protected abstract _createMergeEffect(): Effect;
  106903. /**
  106904. * Creates the render target textures and post processes used in the effect layer.
  106905. */
  106906. protected abstract _createTextureAndPostProcesses(): void;
  106907. /**
  106908. * Implementation specific of rendering the generating effect on the main canvas.
  106909. * @param effect The effect used to render through
  106910. */
  106911. protected abstract _internalRender(effect: Effect): void;
  106912. /**
  106913. * Sets the required values for both the emissive texture and and the main color.
  106914. */
  106915. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  106916. /**
  106917. * Free any resources and references associated to a mesh.
  106918. * Internal use
  106919. * @param mesh The mesh to free.
  106920. */
  106921. abstract _disposeMesh(mesh: Mesh): void;
  106922. /**
  106923. * Serializes this layer (Glow or Highlight for example)
  106924. * @returns a serialized layer object
  106925. */
  106926. abstract serialize?(): any;
  106927. /**
  106928. * Initializes the effect layer with the required options.
  106929. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  106930. */
  106931. protected _init(options: Partial<IEffectLayerOptions>): void;
  106932. /**
  106933. * Generates the index buffer of the full screen quad blending to the main canvas.
  106934. */
  106935. private _generateIndexBuffer;
  106936. /**
  106937. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  106938. */
  106939. private _generateVertexBuffer;
  106940. /**
  106941. * Sets the main texture desired size which is the closest power of two
  106942. * of the engine canvas size.
  106943. */
  106944. private _setMainTextureSize;
  106945. /**
  106946. * Creates the main texture for the effect layer.
  106947. */
  106948. protected _createMainTexture(): void;
  106949. /**
  106950. * Adds specific effects defines.
  106951. * @param defines The defines to add specifics to.
  106952. */
  106953. protected _addCustomEffectDefines(defines: string[]): void;
  106954. /**
  106955. * Checks for the readiness of the element composing the layer.
  106956. * @param subMesh the mesh to check for
  106957. * @param useInstances specify wether or not to use instances to render the mesh
  106958. * @param emissiveTexture the associated emissive texture used to generate the glow
  106959. * @return true if ready otherwise, false
  106960. */
  106961. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  106962. /**
  106963. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  106964. */
  106965. render(): void;
  106966. /**
  106967. * Determine if a given mesh will be used in the current effect.
  106968. * @param mesh mesh to test
  106969. * @returns true if the mesh will be used
  106970. */
  106971. hasMesh(mesh: AbstractMesh): boolean;
  106972. /**
  106973. * Returns true if the layer contains information to display, otherwise false.
  106974. * @returns true if the glow layer should be rendered
  106975. */
  106976. shouldRender(): boolean;
  106977. /**
  106978. * Returns true if the mesh should render, otherwise false.
  106979. * @param mesh The mesh to render
  106980. * @returns true if it should render otherwise false
  106981. */
  106982. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  106983. /**
  106984. * Returns true if the mesh can be rendered, otherwise false.
  106985. * @param mesh The mesh to render
  106986. * @param material The material used on the mesh
  106987. * @returns true if it can be rendered otherwise false
  106988. */
  106989. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  106990. /**
  106991. * Returns true if the mesh should render, otherwise false.
  106992. * @param mesh The mesh to render
  106993. * @returns true if it should render otherwise false
  106994. */
  106995. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  106996. /**
  106997. * Renders the submesh passed in parameter to the generation map.
  106998. */
  106999. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  107000. /**
  107001. * Rebuild the required buffers.
  107002. * @hidden Internal use only.
  107003. */
  107004. _rebuild(): void;
  107005. /**
  107006. * Dispose only the render target textures and post process.
  107007. */
  107008. private _disposeTextureAndPostProcesses;
  107009. /**
  107010. * Dispose the highlight layer and free resources.
  107011. */
  107012. dispose(): void;
  107013. /**
  107014. * Gets the class name of the effect layer
  107015. * @returns the string with the class name of the effect layer
  107016. */
  107017. getClassName(): string;
  107018. /**
  107019. * Creates an effect layer from parsed effect layer data
  107020. * @param parsedEffectLayer defines effect layer data
  107021. * @param scene defines the current scene
  107022. * @param rootUrl defines the root URL containing the effect layer information
  107023. * @returns a parsed effect Layer
  107024. */
  107025. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  107026. }
  107027. }
  107028. declare module BABYLON {
  107029. interface AbstractScene {
  107030. /**
  107031. * The list of effect layers (highlights/glow) added to the scene
  107032. * @see http://doc.babylonjs.com/how_to/highlight_layer
  107033. * @see http://doc.babylonjs.com/how_to/glow_layer
  107034. */
  107035. effectLayers: Array<EffectLayer>;
  107036. /**
  107037. * Removes the given effect layer from this scene.
  107038. * @param toRemove defines the effect layer to remove
  107039. * @returns the index of the removed effect layer
  107040. */
  107041. removeEffectLayer(toRemove: EffectLayer): number;
  107042. /**
  107043. * Adds the given effect layer to this scene
  107044. * @param newEffectLayer defines the effect layer to add
  107045. */
  107046. addEffectLayer(newEffectLayer: EffectLayer): void;
  107047. }
  107048. /**
  107049. * Defines the layer scene component responsible to manage any effect layers
  107050. * in a given scene.
  107051. */
  107052. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  107053. /**
  107054. * The component name helpfull to identify the component in the list of scene components.
  107055. */
  107056. readonly name: string;
  107057. /**
  107058. * The scene the component belongs to.
  107059. */
  107060. scene: Scene;
  107061. private _engine;
  107062. private _renderEffects;
  107063. private _needStencil;
  107064. private _previousStencilState;
  107065. /**
  107066. * Creates a new instance of the component for the given scene
  107067. * @param scene Defines the scene to register the component in
  107068. */
  107069. constructor(scene: Scene);
  107070. /**
  107071. * Registers the component in a given scene
  107072. */
  107073. register(): void;
  107074. /**
  107075. * Rebuilds the elements related to this component in case of
  107076. * context lost for instance.
  107077. */
  107078. rebuild(): void;
  107079. /**
  107080. * Serializes the component data to the specified json object
  107081. * @param serializationObject The object to serialize to
  107082. */
  107083. serialize(serializationObject: any): void;
  107084. /**
  107085. * Adds all the element from the container to the scene
  107086. * @param container the container holding the elements
  107087. */
  107088. addFromContainer(container: AbstractScene): void;
  107089. /**
  107090. * Removes all the elements in the container from the scene
  107091. * @param container contains the elements to remove
  107092. * @param dispose if the removed element should be disposed (default: false)
  107093. */
  107094. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  107095. /**
  107096. * Disposes the component and the associated ressources.
  107097. */
  107098. dispose(): void;
  107099. private _isReadyForMesh;
  107100. private _renderMainTexture;
  107101. private _setStencil;
  107102. private _setStencilBack;
  107103. private _draw;
  107104. private _drawCamera;
  107105. private _drawRenderingGroup;
  107106. }
  107107. }
  107108. declare module BABYLON {
  107109. /** @hidden */
  107110. export var glowMapMergePixelShader: {
  107111. name: string;
  107112. shader: string;
  107113. };
  107114. }
  107115. declare module BABYLON {
  107116. /** @hidden */
  107117. export var glowMapMergeVertexShader: {
  107118. name: string;
  107119. shader: string;
  107120. };
  107121. }
  107122. declare module BABYLON {
  107123. interface AbstractScene {
  107124. /**
  107125. * Return a the first highlight layer of the scene with a given name.
  107126. * @param name The name of the highlight layer to look for.
  107127. * @return The highlight layer if found otherwise null.
  107128. */
  107129. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  107130. }
  107131. /**
  107132. * Glow layer options. This helps customizing the behaviour
  107133. * of the glow layer.
  107134. */
  107135. export interface IGlowLayerOptions {
  107136. /**
  107137. * Multiplication factor apply to the canvas size to compute the render target size
  107138. * used to generated the glowing objects (the smaller the faster).
  107139. */
  107140. mainTextureRatio: number;
  107141. /**
  107142. * Enforces a fixed size texture to ensure resize independant blur.
  107143. */
  107144. mainTextureFixedSize?: number;
  107145. /**
  107146. * How big is the kernel of the blur texture.
  107147. */
  107148. blurKernelSize: number;
  107149. /**
  107150. * The camera attached to the layer.
  107151. */
  107152. camera: Nullable<Camera>;
  107153. /**
  107154. * Enable MSAA by chosing the number of samples.
  107155. */
  107156. mainTextureSamples?: number;
  107157. /**
  107158. * The rendering group to draw the layer in.
  107159. */
  107160. renderingGroupId: number;
  107161. }
  107162. /**
  107163. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  107164. *
  107165. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  107166. * glowy meshes to your scene.
  107167. *
  107168. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  107169. */
  107170. export class GlowLayer extends EffectLayer {
  107171. /**
  107172. * Effect Name of the layer.
  107173. */
  107174. static readonly EffectName: string;
  107175. /**
  107176. * The default blur kernel size used for the glow.
  107177. */
  107178. static DefaultBlurKernelSize: number;
  107179. /**
  107180. * The default texture size ratio used for the glow.
  107181. */
  107182. static DefaultTextureRatio: number;
  107183. /**
  107184. * Sets the kernel size of the blur.
  107185. */
  107186. /**
  107187. * Gets the kernel size of the blur.
  107188. */
  107189. blurKernelSize: number;
  107190. /**
  107191. * Sets the glow intensity.
  107192. */
  107193. /**
  107194. * Gets the glow intensity.
  107195. */
  107196. intensity: number;
  107197. private _options;
  107198. private _intensity;
  107199. private _horizontalBlurPostprocess1;
  107200. private _verticalBlurPostprocess1;
  107201. private _horizontalBlurPostprocess2;
  107202. private _verticalBlurPostprocess2;
  107203. private _blurTexture1;
  107204. private _blurTexture2;
  107205. private _postProcesses1;
  107206. private _postProcesses2;
  107207. private _includedOnlyMeshes;
  107208. private _excludedMeshes;
  107209. /**
  107210. * Callback used to let the user override the color selection on a per mesh basis
  107211. */
  107212. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  107213. /**
  107214. * Callback used to let the user override the texture selection on a per mesh basis
  107215. */
  107216. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  107217. /**
  107218. * Instantiates a new glow Layer and references it to the scene.
  107219. * @param name The name of the layer
  107220. * @param scene The scene to use the layer in
  107221. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  107222. */
  107223. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  107224. /**
  107225. * Get the effect name of the layer.
  107226. * @return The effect name
  107227. */
  107228. getEffectName(): string;
  107229. /**
  107230. * Create the merge effect. This is the shader use to blit the information back
  107231. * to the main canvas at the end of the scene rendering.
  107232. */
  107233. protected _createMergeEffect(): Effect;
  107234. /**
  107235. * Creates the render target textures and post processes used in the glow layer.
  107236. */
  107237. protected _createTextureAndPostProcesses(): void;
  107238. /**
  107239. * Checks for the readiness of the element composing the layer.
  107240. * @param subMesh the mesh to check for
  107241. * @param useInstances specify wether or not to use instances to render the mesh
  107242. * @param emissiveTexture the associated emissive texture used to generate the glow
  107243. * @return true if ready otherwise, false
  107244. */
  107245. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  107246. /**
  107247. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  107248. */
  107249. needStencil(): boolean;
  107250. /**
  107251. * Returns true if the mesh can be rendered, otherwise false.
  107252. * @param mesh The mesh to render
  107253. * @param material The material used on the mesh
  107254. * @returns true if it can be rendered otherwise false
  107255. */
  107256. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  107257. /**
  107258. * Implementation specific of rendering the generating effect on the main canvas.
  107259. * @param effect The effect used to render through
  107260. */
  107261. protected _internalRender(effect: Effect): void;
  107262. /**
  107263. * Sets the required values for both the emissive texture and and the main color.
  107264. */
  107265. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  107266. /**
  107267. * Returns true if the mesh should render, otherwise false.
  107268. * @param mesh The mesh to render
  107269. * @returns true if it should render otherwise false
  107270. */
  107271. protected _shouldRenderMesh(mesh: Mesh): boolean;
  107272. /**
  107273. * Adds specific effects defines.
  107274. * @param defines The defines to add specifics to.
  107275. */
  107276. protected _addCustomEffectDefines(defines: string[]): void;
  107277. /**
  107278. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  107279. * @param mesh The mesh to exclude from the glow layer
  107280. */
  107281. addExcludedMesh(mesh: Mesh): void;
  107282. /**
  107283. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  107284. * @param mesh The mesh to remove
  107285. */
  107286. removeExcludedMesh(mesh: Mesh): void;
  107287. /**
  107288. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  107289. * @param mesh The mesh to include in the glow layer
  107290. */
  107291. addIncludedOnlyMesh(mesh: Mesh): void;
  107292. /**
  107293. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  107294. * @param mesh The mesh to remove
  107295. */
  107296. removeIncludedOnlyMesh(mesh: Mesh): void;
  107297. /**
  107298. * Determine if a given mesh will be used in the glow layer
  107299. * @param mesh The mesh to test
  107300. * @returns true if the mesh will be highlighted by the current glow layer
  107301. */
  107302. hasMesh(mesh: AbstractMesh): boolean;
  107303. /**
  107304. * Free any resources and references associated to a mesh.
  107305. * Internal use
  107306. * @param mesh The mesh to free.
  107307. * @hidden
  107308. */
  107309. _disposeMesh(mesh: Mesh): void;
  107310. /**
  107311. * Gets the class name of the effect layer
  107312. * @returns the string with the class name of the effect layer
  107313. */
  107314. getClassName(): string;
  107315. /**
  107316. * Serializes this glow layer
  107317. * @returns a serialized glow layer object
  107318. */
  107319. serialize(): any;
  107320. /**
  107321. * Creates a Glow Layer from parsed glow layer data
  107322. * @param parsedGlowLayer defines glow layer data
  107323. * @param scene defines the current scene
  107324. * @param rootUrl defines the root URL containing the glow layer information
  107325. * @returns a parsed Glow Layer
  107326. */
  107327. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  107328. }
  107329. }
  107330. declare module BABYLON {
  107331. /** @hidden */
  107332. export var glowBlurPostProcessPixelShader: {
  107333. name: string;
  107334. shader: string;
  107335. };
  107336. }
  107337. declare module BABYLON {
  107338. interface AbstractScene {
  107339. /**
  107340. * Return a the first highlight layer of the scene with a given name.
  107341. * @param name The name of the highlight layer to look for.
  107342. * @return The highlight layer if found otherwise null.
  107343. */
  107344. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  107345. }
  107346. /**
  107347. * Highlight layer options. This helps customizing the behaviour
  107348. * of the highlight layer.
  107349. */
  107350. export interface IHighlightLayerOptions {
  107351. /**
  107352. * Multiplication factor apply to the canvas size to compute the render target size
  107353. * used to generated the glowing objects (the smaller the faster).
  107354. */
  107355. mainTextureRatio: number;
  107356. /**
  107357. * Enforces a fixed size texture to ensure resize independant blur.
  107358. */
  107359. mainTextureFixedSize?: number;
  107360. /**
  107361. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  107362. * of the picture to blur (the smaller the faster).
  107363. */
  107364. blurTextureSizeRatio: number;
  107365. /**
  107366. * How big in texel of the blur texture is the vertical blur.
  107367. */
  107368. blurVerticalSize: number;
  107369. /**
  107370. * How big in texel of the blur texture is the horizontal blur.
  107371. */
  107372. blurHorizontalSize: number;
  107373. /**
  107374. * Alpha blending mode used to apply the blur. Default is combine.
  107375. */
  107376. alphaBlendingMode: number;
  107377. /**
  107378. * The camera attached to the layer.
  107379. */
  107380. camera: Nullable<Camera>;
  107381. /**
  107382. * Should we display highlight as a solid stroke?
  107383. */
  107384. isStroke?: boolean;
  107385. /**
  107386. * The rendering group to draw the layer in.
  107387. */
  107388. renderingGroupId: number;
  107389. }
  107390. /**
  107391. * The highlight layer Helps adding a glow effect around a mesh.
  107392. *
  107393. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  107394. * glowy meshes to your scene.
  107395. *
  107396. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  107397. */
  107398. export class HighlightLayer extends EffectLayer {
  107399. name: string;
  107400. /**
  107401. * Effect Name of the highlight layer.
  107402. */
  107403. static readonly EffectName: string;
  107404. /**
  107405. * The neutral color used during the preparation of the glow effect.
  107406. * This is black by default as the blend operation is a blend operation.
  107407. */
  107408. static NeutralColor: Color4;
  107409. /**
  107410. * Stencil value used for glowing meshes.
  107411. */
  107412. static GlowingMeshStencilReference: number;
  107413. /**
  107414. * Stencil value used for the other meshes in the scene.
  107415. */
  107416. static NormalMeshStencilReference: number;
  107417. /**
  107418. * Specifies whether or not the inner glow is ACTIVE in the layer.
  107419. */
  107420. innerGlow: boolean;
  107421. /**
  107422. * Specifies whether or not the outer glow is ACTIVE in the layer.
  107423. */
  107424. outerGlow: boolean;
  107425. /**
  107426. * Specifies the horizontal size of the blur.
  107427. */
  107428. /**
  107429. * Gets the horizontal size of the blur.
  107430. */
  107431. blurHorizontalSize: number;
  107432. /**
  107433. * Specifies the vertical size of the blur.
  107434. */
  107435. /**
  107436. * Gets the vertical size of the blur.
  107437. */
  107438. blurVerticalSize: number;
  107439. /**
  107440. * An event triggered when the highlight layer is being blurred.
  107441. */
  107442. onBeforeBlurObservable: Observable<HighlightLayer>;
  107443. /**
  107444. * An event triggered when the highlight layer has been blurred.
  107445. */
  107446. onAfterBlurObservable: Observable<HighlightLayer>;
  107447. private _instanceGlowingMeshStencilReference;
  107448. private _options;
  107449. private _downSamplePostprocess;
  107450. private _horizontalBlurPostprocess;
  107451. private _verticalBlurPostprocess;
  107452. private _blurTexture;
  107453. private _meshes;
  107454. private _excludedMeshes;
  107455. /**
  107456. * Instantiates a new highlight Layer and references it to the scene..
  107457. * @param name The name of the layer
  107458. * @param scene The scene to use the layer in
  107459. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  107460. */
  107461. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  107462. /**
  107463. * Get the effect name of the layer.
  107464. * @return The effect name
  107465. */
  107466. getEffectName(): string;
  107467. /**
  107468. * Create the merge effect. This is the shader use to blit the information back
  107469. * to the main canvas at the end of the scene rendering.
  107470. */
  107471. protected _createMergeEffect(): Effect;
  107472. /**
  107473. * Creates the render target textures and post processes used in the highlight layer.
  107474. */
  107475. protected _createTextureAndPostProcesses(): void;
  107476. /**
  107477. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  107478. */
  107479. needStencil(): boolean;
  107480. /**
  107481. * Checks for the readiness of the element composing the layer.
  107482. * @param subMesh the mesh to check for
  107483. * @param useInstances specify wether or not to use instances to render the mesh
  107484. * @param emissiveTexture the associated emissive texture used to generate the glow
  107485. * @return true if ready otherwise, false
  107486. */
  107487. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  107488. /**
  107489. * Implementation specific of rendering the generating effect on the main canvas.
  107490. * @param effect The effect used to render through
  107491. */
  107492. protected _internalRender(effect: Effect): void;
  107493. /**
  107494. * Returns true if the layer contains information to display, otherwise false.
  107495. */
  107496. shouldRender(): boolean;
  107497. /**
  107498. * Returns true if the mesh should render, otherwise false.
  107499. * @param mesh The mesh to render
  107500. * @returns true if it should render otherwise false
  107501. */
  107502. protected _shouldRenderMesh(mesh: Mesh): boolean;
  107503. /**
  107504. * Sets the required values for both the emissive texture and and the main color.
  107505. */
  107506. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  107507. /**
  107508. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  107509. * @param mesh The mesh to exclude from the highlight layer
  107510. */
  107511. addExcludedMesh(mesh: Mesh): void;
  107512. /**
  107513. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  107514. * @param mesh The mesh to highlight
  107515. */
  107516. removeExcludedMesh(mesh: Mesh): void;
  107517. /**
  107518. * Determine if a given mesh will be highlighted by the current HighlightLayer
  107519. * @param mesh mesh to test
  107520. * @returns true if the mesh will be highlighted by the current HighlightLayer
  107521. */
  107522. hasMesh(mesh: AbstractMesh): boolean;
  107523. /**
  107524. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  107525. * @param mesh The mesh to highlight
  107526. * @param color The color of the highlight
  107527. * @param glowEmissiveOnly Extract the glow from the emissive texture
  107528. */
  107529. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  107530. /**
  107531. * Remove a mesh from the highlight layer in order to make it stop glowing.
  107532. * @param mesh The mesh to highlight
  107533. */
  107534. removeMesh(mesh: Mesh): void;
  107535. /**
  107536. * Force the stencil to the normal expected value for none glowing parts
  107537. */
  107538. private _defaultStencilReference;
  107539. /**
  107540. * Free any resources and references associated to a mesh.
  107541. * Internal use
  107542. * @param mesh The mesh to free.
  107543. * @hidden
  107544. */
  107545. _disposeMesh(mesh: Mesh): void;
  107546. /**
  107547. * Dispose the highlight layer and free resources.
  107548. */
  107549. dispose(): void;
  107550. /**
  107551. * Gets the class name of the effect layer
  107552. * @returns the string with the class name of the effect layer
  107553. */
  107554. getClassName(): string;
  107555. /**
  107556. * Serializes this Highlight layer
  107557. * @returns a serialized Highlight layer object
  107558. */
  107559. serialize(): any;
  107560. /**
  107561. * Creates a Highlight layer from parsed Highlight layer data
  107562. * @param parsedHightlightLayer defines the Highlight layer data
  107563. * @param scene defines the current scene
  107564. * @param rootUrl defines the root URL containing the Highlight layer information
  107565. * @returns a parsed Highlight layer
  107566. */
  107567. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  107568. }
  107569. }
  107570. declare module BABYLON {
  107571. /** @hidden */
  107572. export var lensFlarePixelShader: {
  107573. name: string;
  107574. shader: string;
  107575. };
  107576. }
  107577. declare module BABYLON {
  107578. /** @hidden */
  107579. export var lensFlareVertexShader: {
  107580. name: string;
  107581. shader: string;
  107582. };
  107583. }
  107584. declare module BABYLON {
  107585. /**
  107586. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  107587. * It is usually composed of several `lensFlare`.
  107588. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  107589. */
  107590. export class LensFlareSystem {
  107591. /**
  107592. * Define the name of the lens flare system
  107593. */
  107594. name: string;
  107595. /**
  107596. * List of lens flares used in this system.
  107597. */
  107598. lensFlares: LensFlare[];
  107599. /**
  107600. * Define a limit from the border the lens flare can be visible.
  107601. */
  107602. borderLimit: number;
  107603. /**
  107604. * Define a viewport border we do not want to see the lens flare in.
  107605. */
  107606. viewportBorder: number;
  107607. /**
  107608. * Define a predicate which could limit the list of meshes able to occlude the effect.
  107609. */
  107610. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  107611. /**
  107612. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  107613. */
  107614. layerMask: number;
  107615. /**
  107616. * Define the id of the lens flare system in the scene.
  107617. * (equal to name by default)
  107618. */
  107619. id: string;
  107620. private _scene;
  107621. private _emitter;
  107622. private _vertexBuffers;
  107623. private _indexBuffer;
  107624. private _effect;
  107625. private _positionX;
  107626. private _positionY;
  107627. private _isEnabled;
  107628. /** @hidden */
  107629. static _SceneComponentInitialization: (scene: Scene) => void;
  107630. /**
  107631. * Instantiates a lens flare system.
  107632. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  107633. * It is usually composed of several `lensFlare`.
  107634. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  107635. * @param name Define the name of the lens flare system in the scene
  107636. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  107637. * @param scene Define the scene the lens flare system belongs to
  107638. */
  107639. constructor(
  107640. /**
  107641. * Define the name of the lens flare system
  107642. */
  107643. name: string, emitter: any, scene: Scene);
  107644. /**
  107645. * Define if the lens flare system is enabled.
  107646. */
  107647. isEnabled: boolean;
  107648. /**
  107649. * Get the scene the effects belongs to.
  107650. * @returns the scene holding the lens flare system
  107651. */
  107652. getScene(): Scene;
  107653. /**
  107654. * Get the emitter of the lens flare system.
  107655. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  107656. * @returns the emitter of the lens flare system
  107657. */
  107658. getEmitter(): any;
  107659. /**
  107660. * Set the emitter of the lens flare system.
  107661. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  107662. * @param newEmitter Define the new emitter of the system
  107663. */
  107664. setEmitter(newEmitter: any): void;
  107665. /**
  107666. * Get the lens flare system emitter position.
  107667. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  107668. * @returns the position
  107669. */
  107670. getEmitterPosition(): Vector3;
  107671. /**
  107672. * @hidden
  107673. */
  107674. computeEffectivePosition(globalViewport: Viewport): boolean;
  107675. /** @hidden */
  107676. _isVisible(): boolean;
  107677. /**
  107678. * @hidden
  107679. */
  107680. render(): boolean;
  107681. /**
  107682. * Dispose and release the lens flare with its associated resources.
  107683. */
  107684. dispose(): void;
  107685. /**
  107686. * Parse a lens flare system from a JSON repressentation
  107687. * @param parsedLensFlareSystem Define the JSON to parse
  107688. * @param scene Define the scene the parsed system should be instantiated in
  107689. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  107690. * @returns the parsed system
  107691. */
  107692. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  107693. /**
  107694. * Serialize the current Lens Flare System into a JSON representation.
  107695. * @returns the serialized JSON
  107696. */
  107697. serialize(): any;
  107698. }
  107699. }
  107700. declare module BABYLON {
  107701. /**
  107702. * This represents one of the lens effect in a `lensFlareSystem`.
  107703. * It controls one of the indiviual texture used in the effect.
  107704. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  107705. */
  107706. export class LensFlare {
  107707. /**
  107708. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  107709. */
  107710. size: number;
  107711. /**
  107712. * 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.
  107713. */
  107714. position: number;
  107715. /**
  107716. * Define the lens color.
  107717. */
  107718. color: Color3;
  107719. /**
  107720. * Define the lens texture.
  107721. */
  107722. texture: Nullable<Texture>;
  107723. /**
  107724. * Define the alpha mode to render this particular lens.
  107725. */
  107726. alphaMode: number;
  107727. private _system;
  107728. /**
  107729. * Creates a new Lens Flare.
  107730. * This represents one of the lens effect in a `lensFlareSystem`.
  107731. * It controls one of the indiviual texture used in the effect.
  107732. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  107733. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  107734. * @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.
  107735. * @param color Define the lens color
  107736. * @param imgUrl Define the lens texture url
  107737. * @param system Define the `lensFlareSystem` this flare is part of
  107738. * @returns The newly created Lens Flare
  107739. */
  107740. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  107741. /**
  107742. * Instantiates a new Lens Flare.
  107743. * This represents one of the lens effect in a `lensFlareSystem`.
  107744. * It controls one of the indiviual texture used in the effect.
  107745. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  107746. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  107747. * @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.
  107748. * @param color Define the lens color
  107749. * @param imgUrl Define the lens texture url
  107750. * @param system Define the `lensFlareSystem` this flare is part of
  107751. */
  107752. constructor(
  107753. /**
  107754. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  107755. */
  107756. size: number,
  107757. /**
  107758. * 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.
  107759. */
  107760. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  107761. /**
  107762. * Dispose and release the lens flare with its associated resources.
  107763. */
  107764. dispose(): void;
  107765. }
  107766. }
  107767. declare module BABYLON {
  107768. interface AbstractScene {
  107769. /**
  107770. * The list of lens flare system added to the scene
  107771. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  107772. */
  107773. lensFlareSystems: Array<LensFlareSystem>;
  107774. /**
  107775. * Removes the given lens flare system from this scene.
  107776. * @param toRemove The lens flare system to remove
  107777. * @returns The index of the removed lens flare system
  107778. */
  107779. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  107780. /**
  107781. * Adds the given lens flare system to this scene
  107782. * @param newLensFlareSystem The lens flare system to add
  107783. */
  107784. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  107785. /**
  107786. * Gets a lens flare system using its name
  107787. * @param name defines the name to look for
  107788. * @returns the lens flare system or null if not found
  107789. */
  107790. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  107791. /**
  107792. * Gets a lens flare system using its id
  107793. * @param id defines the id to look for
  107794. * @returns the lens flare system or null if not found
  107795. */
  107796. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  107797. }
  107798. /**
  107799. * Defines the lens flare scene component responsible to manage any lens flares
  107800. * in a given scene.
  107801. */
  107802. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  107803. /**
  107804. * The component name helpfull to identify the component in the list of scene components.
  107805. */
  107806. readonly name: string;
  107807. /**
  107808. * The scene the component belongs to.
  107809. */
  107810. scene: Scene;
  107811. /**
  107812. * Creates a new instance of the component for the given scene
  107813. * @param scene Defines the scene to register the component in
  107814. */
  107815. constructor(scene: Scene);
  107816. /**
  107817. * Registers the component in a given scene
  107818. */
  107819. register(): void;
  107820. /**
  107821. * Rebuilds the elements related to this component in case of
  107822. * context lost for instance.
  107823. */
  107824. rebuild(): void;
  107825. /**
  107826. * Adds all the element from the container to the scene
  107827. * @param container the container holding the elements
  107828. */
  107829. addFromContainer(container: AbstractScene): void;
  107830. /**
  107831. * Removes all the elements in the container from the scene
  107832. * @param container contains the elements to remove
  107833. * @param dispose if the removed element should be disposed (default: false)
  107834. */
  107835. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  107836. /**
  107837. * Serializes the component data to the specified json object
  107838. * @param serializationObject The object to serialize to
  107839. */
  107840. serialize(serializationObject: any): void;
  107841. /**
  107842. * Disposes the component and the associated ressources.
  107843. */
  107844. dispose(): void;
  107845. private _draw;
  107846. }
  107847. }
  107848. declare module BABYLON {
  107849. /**
  107850. * Defines the shadow generator component responsible to manage any shadow generators
  107851. * in a given scene.
  107852. */
  107853. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  107854. /**
  107855. * The component name helpfull to identify the component in the list of scene components.
  107856. */
  107857. readonly name: string;
  107858. /**
  107859. * The scene the component belongs to.
  107860. */
  107861. scene: Scene;
  107862. /**
  107863. * Creates a new instance of the component for the given scene
  107864. * @param scene Defines the scene to register the component in
  107865. */
  107866. constructor(scene: Scene);
  107867. /**
  107868. * Registers the component in a given scene
  107869. */
  107870. register(): void;
  107871. /**
  107872. * Rebuilds the elements related to this component in case of
  107873. * context lost for instance.
  107874. */
  107875. rebuild(): void;
  107876. /**
  107877. * Serializes the component data to the specified json object
  107878. * @param serializationObject The object to serialize to
  107879. */
  107880. serialize(serializationObject: any): void;
  107881. /**
  107882. * Adds all the element from the container to the scene
  107883. * @param container the container holding the elements
  107884. */
  107885. addFromContainer(container: AbstractScene): void;
  107886. /**
  107887. * Removes all the elements in the container from the scene
  107888. * @param container contains the elements to remove
  107889. * @param dispose if the removed element should be disposed (default: false)
  107890. */
  107891. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  107892. /**
  107893. * Rebuilds the elements related to this component in case of
  107894. * context lost for instance.
  107895. */
  107896. dispose(): void;
  107897. private _gatherRenderTargets;
  107898. }
  107899. }
  107900. declare module BABYLON {
  107901. /**
  107902. * A point light is a light defined by an unique point in world space.
  107903. * The light is emitted in every direction from this point.
  107904. * A good example of a point light is a standard light bulb.
  107905. * Documentation: https://doc.babylonjs.com/babylon101/lights
  107906. */
  107907. export class PointLight extends ShadowLight {
  107908. private _shadowAngle;
  107909. /**
  107910. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  107911. * This specifies what angle the shadow will use to be created.
  107912. *
  107913. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  107914. */
  107915. /**
  107916. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  107917. * This specifies what angle the shadow will use to be created.
  107918. *
  107919. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  107920. */
  107921. shadowAngle: number;
  107922. /**
  107923. * Gets the direction if it has been set.
  107924. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  107925. */
  107926. /**
  107927. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  107928. */
  107929. direction: Vector3;
  107930. /**
  107931. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  107932. * A PointLight emits the light in every direction.
  107933. * It can cast shadows.
  107934. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  107935. * ```javascript
  107936. * var pointLight = new PointLight("pl", camera.position, scene);
  107937. * ```
  107938. * Documentation : https://doc.babylonjs.com/babylon101/lights
  107939. * @param name The light friendly name
  107940. * @param position The position of the point light in the scene
  107941. * @param scene The scene the lights belongs to
  107942. */
  107943. constructor(name: string, position: Vector3, scene: Scene);
  107944. /**
  107945. * Returns the string "PointLight"
  107946. * @returns the class name
  107947. */
  107948. getClassName(): string;
  107949. /**
  107950. * Returns the integer 0.
  107951. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  107952. */
  107953. getTypeID(): number;
  107954. /**
  107955. * Specifies wether or not the shadowmap should be a cube texture.
  107956. * @returns true if the shadowmap needs to be a cube texture.
  107957. */
  107958. needCube(): boolean;
  107959. /**
  107960. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  107961. * @param faceIndex The index of the face we are computed the direction to generate shadow
  107962. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  107963. */
  107964. getShadowDirection(faceIndex?: number): Vector3;
  107965. /**
  107966. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  107967. * - fov = PI / 2
  107968. * - aspect ratio : 1.0
  107969. * - z-near and far equal to the active camera minZ and maxZ.
  107970. * Returns the PointLight.
  107971. */
  107972. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  107973. protected _buildUniformLayout(): void;
  107974. /**
  107975. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  107976. * @param effect The effect to update
  107977. * @param lightIndex The index of the light in the effect to update
  107978. * @returns The point light
  107979. */
  107980. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  107981. /**
  107982. * Prepares the list of defines specific to the light type.
  107983. * @param defines the list of defines
  107984. * @param lightIndex defines the index of the light for the effect
  107985. */
  107986. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  107987. }
  107988. }
  107989. declare module BABYLON {
  107990. /**
  107991. * Header information of HDR texture files.
  107992. */
  107993. export interface HDRInfo {
  107994. /**
  107995. * The height of the texture in pixels.
  107996. */
  107997. height: number;
  107998. /**
  107999. * The width of the texture in pixels.
  108000. */
  108001. width: number;
  108002. /**
  108003. * The index of the beginning of the data in the binary file.
  108004. */
  108005. dataPosition: number;
  108006. }
  108007. /**
  108008. * This groups tools to convert HDR texture to native colors array.
  108009. */
  108010. export class HDRTools {
  108011. private static Ldexp;
  108012. private static Rgbe2float;
  108013. private static readStringLine;
  108014. /**
  108015. * Reads header information from an RGBE texture stored in a native array.
  108016. * More information on this format are available here:
  108017. * https://en.wikipedia.org/wiki/RGBE_image_format
  108018. *
  108019. * @param uint8array The binary file stored in native array.
  108020. * @return The header information.
  108021. */
  108022. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  108023. /**
  108024. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  108025. * This RGBE texture needs to store the information as a panorama.
  108026. *
  108027. * More information on this format are available here:
  108028. * https://en.wikipedia.org/wiki/RGBE_image_format
  108029. *
  108030. * @param buffer The binary file stored in an array buffer.
  108031. * @param size The expected size of the extracted cubemap.
  108032. * @return The Cube Map information.
  108033. */
  108034. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  108035. /**
  108036. * Returns the pixels data extracted from an RGBE texture.
  108037. * This pixels will be stored left to right up to down in the R G B order in one array.
  108038. *
  108039. * More information on this format are available here:
  108040. * https://en.wikipedia.org/wiki/RGBE_image_format
  108041. *
  108042. * @param uint8array The binary file stored in an array buffer.
  108043. * @param hdrInfo The header information of the file.
  108044. * @return The pixels data in RGB right to left up to down order.
  108045. */
  108046. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  108047. private static RGBE_ReadPixels_RLE;
  108048. }
  108049. }
  108050. declare module BABYLON {
  108051. /**
  108052. * This represents a texture coming from an HDR input.
  108053. *
  108054. * The only supported format is currently panorama picture stored in RGBE format.
  108055. * Example of such files can be found on HDRLib: http://hdrlib.com/
  108056. */
  108057. export class HDRCubeTexture extends BaseTexture {
  108058. private static _facesMapping;
  108059. private _generateHarmonics;
  108060. private _noMipmap;
  108061. private _textureMatrix;
  108062. private _size;
  108063. private _onLoad;
  108064. private _onError;
  108065. /**
  108066. * The texture URL.
  108067. */
  108068. url: string;
  108069. /**
  108070. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  108071. */
  108072. coordinatesMode: number;
  108073. protected _isBlocking: boolean;
  108074. /**
  108075. * Sets wether or not the texture is blocking during loading.
  108076. */
  108077. /**
  108078. * Gets wether or not the texture is blocking during loading.
  108079. */
  108080. isBlocking: boolean;
  108081. protected _rotationY: number;
  108082. /**
  108083. * Sets texture matrix rotation angle around Y axis in radians.
  108084. */
  108085. /**
  108086. * Gets texture matrix rotation angle around Y axis radians.
  108087. */
  108088. rotationY: number;
  108089. /**
  108090. * Gets or sets the center of the bounding box associated with the cube texture
  108091. * It must define where the camera used to render the texture was set
  108092. */
  108093. boundingBoxPosition: Vector3;
  108094. private _boundingBoxSize;
  108095. /**
  108096. * Gets or sets the size of the bounding box associated with the cube texture
  108097. * When defined, the cubemap will switch to local mode
  108098. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  108099. * @example https://www.babylonjs-playground.com/#RNASML
  108100. */
  108101. boundingBoxSize: Vector3;
  108102. /**
  108103. * Instantiates an HDRTexture from the following parameters.
  108104. *
  108105. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  108106. * @param scene The scene the texture will be used in
  108107. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  108108. * @param noMipmap Forces to not generate the mipmap if true
  108109. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  108110. * @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)
  108111. * @param reserved Reserved flag for internal use.
  108112. */
  108113. 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>);
  108114. /**
  108115. * Get the current class name of the texture useful for serialization or dynamic coding.
  108116. * @returns "HDRCubeTexture"
  108117. */
  108118. getClassName(): string;
  108119. /**
  108120. * Occurs when the file is raw .hdr file.
  108121. */
  108122. private loadTexture;
  108123. clone(): HDRCubeTexture;
  108124. delayLoad(): void;
  108125. /**
  108126. * Get the texture reflection matrix used to rotate/transform the reflection.
  108127. * @returns the reflection matrix
  108128. */
  108129. getReflectionTextureMatrix(): Matrix;
  108130. /**
  108131. * Set the texture reflection matrix used to rotate/transform the reflection.
  108132. * @param value Define the reflection matrix to set
  108133. */
  108134. setReflectionTextureMatrix(value: Matrix): void;
  108135. /**
  108136. * Parses a JSON representation of an HDR Texture in order to create the texture
  108137. * @param parsedTexture Define the JSON representation
  108138. * @param scene Define the scene the texture should be created in
  108139. * @param rootUrl Define the root url in case we need to load relative dependencies
  108140. * @returns the newly created texture after parsing
  108141. */
  108142. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  108143. serialize(): any;
  108144. }
  108145. }
  108146. declare module BABYLON {
  108147. /**
  108148. * Class used to control physics engine
  108149. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  108150. */
  108151. export class PhysicsEngine implements IPhysicsEngine {
  108152. private _physicsPlugin;
  108153. /**
  108154. * Global value used to control the smallest number supported by the simulation
  108155. */
  108156. static Epsilon: number;
  108157. private _impostors;
  108158. private _joints;
  108159. /**
  108160. * Gets the gravity vector used by the simulation
  108161. */
  108162. gravity: Vector3;
  108163. /**
  108164. * Factory used to create the default physics plugin.
  108165. * @returns The default physics plugin
  108166. */
  108167. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  108168. /**
  108169. * Creates a new Physics Engine
  108170. * @param gravity defines the gravity vector used by the simulation
  108171. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  108172. */
  108173. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  108174. /**
  108175. * Sets the gravity vector used by the simulation
  108176. * @param gravity defines the gravity vector to use
  108177. */
  108178. setGravity(gravity: Vector3): void;
  108179. /**
  108180. * Set the time step of the physics engine.
  108181. * Default is 1/60.
  108182. * To slow it down, enter 1/600 for example.
  108183. * To speed it up, 1/30
  108184. * @param newTimeStep defines the new timestep to apply to this world.
  108185. */
  108186. setTimeStep(newTimeStep?: number): void;
  108187. /**
  108188. * Get the time step of the physics engine.
  108189. * @returns the current time step
  108190. */
  108191. getTimeStep(): number;
  108192. /**
  108193. * Release all resources
  108194. */
  108195. dispose(): void;
  108196. /**
  108197. * Gets the name of the current physics plugin
  108198. * @returns the name of the plugin
  108199. */
  108200. getPhysicsPluginName(): string;
  108201. /**
  108202. * Adding a new impostor for the impostor tracking.
  108203. * This will be done by the impostor itself.
  108204. * @param impostor the impostor to add
  108205. */
  108206. addImpostor(impostor: PhysicsImpostor): void;
  108207. /**
  108208. * Remove an impostor from the engine.
  108209. * This impostor and its mesh will not longer be updated by the physics engine.
  108210. * @param impostor the impostor to remove
  108211. */
  108212. removeImpostor(impostor: PhysicsImpostor): void;
  108213. /**
  108214. * Add a joint to the physics engine
  108215. * @param mainImpostor defines the main impostor to which the joint is added.
  108216. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  108217. * @param joint defines the joint that will connect both impostors.
  108218. */
  108219. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  108220. /**
  108221. * Removes a joint from the simulation
  108222. * @param mainImpostor defines the impostor used with the joint
  108223. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  108224. * @param joint defines the joint to remove
  108225. */
  108226. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  108227. /**
  108228. * Called by the scene. No need to call it.
  108229. * @param delta defines the timespam between frames
  108230. */
  108231. _step(delta: number): void;
  108232. /**
  108233. * Gets the current plugin used to run the simulation
  108234. * @returns current plugin
  108235. */
  108236. getPhysicsPlugin(): IPhysicsEnginePlugin;
  108237. /**
  108238. * Gets the list of physic impostors
  108239. * @returns an array of PhysicsImpostor
  108240. */
  108241. getImpostors(): Array<PhysicsImpostor>;
  108242. /**
  108243. * Gets the impostor for a physics enabled object
  108244. * @param object defines the object impersonated by the impostor
  108245. * @returns the PhysicsImpostor or null if not found
  108246. */
  108247. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  108248. /**
  108249. * Gets the impostor for a physics body object
  108250. * @param body defines physics body used by the impostor
  108251. * @returns the PhysicsImpostor or null if not found
  108252. */
  108253. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  108254. /**
  108255. * Does a raycast in the physics world
  108256. * @param from when should the ray start?
  108257. * @param to when should the ray end?
  108258. * @returns PhysicsRaycastResult
  108259. */
  108260. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  108261. }
  108262. }
  108263. declare module BABYLON {
  108264. /** @hidden */
  108265. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  108266. private _useDeltaForWorldStep;
  108267. world: any;
  108268. name: string;
  108269. private _physicsMaterials;
  108270. private _fixedTimeStep;
  108271. private _cannonRaycastResult;
  108272. private _raycastResult;
  108273. private _removeAfterStep;
  108274. BJSCANNON: any;
  108275. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  108276. setGravity(gravity: Vector3): void;
  108277. setTimeStep(timeStep: number): void;
  108278. getTimeStep(): number;
  108279. executeStep(delta: number): void;
  108280. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  108281. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  108282. generatePhysicsBody(impostor: PhysicsImpostor): void;
  108283. private _processChildMeshes;
  108284. removePhysicsBody(impostor: PhysicsImpostor): void;
  108285. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  108286. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  108287. private _addMaterial;
  108288. private _checkWithEpsilon;
  108289. private _createShape;
  108290. private _createHeightmap;
  108291. private _minus90X;
  108292. private _plus90X;
  108293. private _tmpPosition;
  108294. private _tmpDeltaPosition;
  108295. private _tmpUnityRotation;
  108296. private _updatePhysicsBodyTransformation;
  108297. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  108298. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  108299. isSupported(): boolean;
  108300. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  108301. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  108302. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  108303. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  108304. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  108305. getBodyMass(impostor: PhysicsImpostor): number;
  108306. getBodyFriction(impostor: PhysicsImpostor): number;
  108307. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  108308. getBodyRestitution(impostor: PhysicsImpostor): number;
  108309. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  108310. sleepBody(impostor: PhysicsImpostor): void;
  108311. wakeUpBody(impostor: PhysicsImpostor): void;
  108312. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  108313. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  108314. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  108315. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  108316. getRadius(impostor: PhysicsImpostor): number;
  108317. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  108318. dispose(): void;
  108319. private _extendNamespace;
  108320. /**
  108321. * Does a raycast in the physics world
  108322. * @param from when should the ray start?
  108323. * @param to when should the ray end?
  108324. * @returns PhysicsRaycastResult
  108325. */
  108326. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  108327. }
  108328. }
  108329. declare module BABYLON {
  108330. /** @hidden */
  108331. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  108332. world: any;
  108333. name: string;
  108334. BJSOIMO: any;
  108335. private _raycastResult;
  108336. constructor(iterations?: number, oimoInjection?: any);
  108337. setGravity(gravity: Vector3): void;
  108338. setTimeStep(timeStep: number): void;
  108339. getTimeStep(): number;
  108340. private _tmpImpostorsArray;
  108341. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  108342. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  108343. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  108344. generatePhysicsBody(impostor: PhysicsImpostor): void;
  108345. private _tmpPositionVector;
  108346. removePhysicsBody(impostor: PhysicsImpostor): void;
  108347. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  108348. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  108349. isSupported(): boolean;
  108350. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  108351. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  108352. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  108353. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  108354. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  108355. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  108356. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  108357. getBodyMass(impostor: PhysicsImpostor): number;
  108358. getBodyFriction(impostor: PhysicsImpostor): number;
  108359. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  108360. getBodyRestitution(impostor: PhysicsImpostor): number;
  108361. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  108362. sleepBody(impostor: PhysicsImpostor): void;
  108363. wakeUpBody(impostor: PhysicsImpostor): void;
  108364. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  108365. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  108366. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  108367. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  108368. getRadius(impostor: PhysicsImpostor): number;
  108369. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  108370. dispose(): void;
  108371. /**
  108372. * Does a raycast in the physics world
  108373. * @param from when should the ray start?
  108374. * @param to when should the ray end?
  108375. * @returns PhysicsRaycastResult
  108376. */
  108377. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  108378. }
  108379. }
  108380. declare module BABYLON {
  108381. /**
  108382. * Class containing static functions to help procedurally build meshes
  108383. */
  108384. export class RibbonBuilder {
  108385. /**
  108386. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  108387. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  108388. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  108389. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  108390. * * 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
  108391. * * 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
  108392. * * 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
  108393. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108394. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108395. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  108396. * * 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
  108397. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  108398. * * 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
  108399. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  108400. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108401. * @param name defines the name of the mesh
  108402. * @param options defines the options used to create the mesh
  108403. * @param scene defines the hosting scene
  108404. * @returns the ribbon mesh
  108405. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  108406. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  108407. */
  108408. static CreateRibbon(name: string, options: {
  108409. pathArray: Vector3[][];
  108410. closeArray?: boolean;
  108411. closePath?: boolean;
  108412. offset?: number;
  108413. updatable?: boolean;
  108414. sideOrientation?: number;
  108415. frontUVs?: Vector4;
  108416. backUVs?: Vector4;
  108417. instance?: Mesh;
  108418. invertUV?: boolean;
  108419. uvs?: Vector2[];
  108420. colors?: Color4[];
  108421. }, scene?: Nullable<Scene>): Mesh;
  108422. }
  108423. }
  108424. declare module BABYLON {
  108425. /**
  108426. * Class containing static functions to help procedurally build meshes
  108427. */
  108428. export class ShapeBuilder {
  108429. /**
  108430. * 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.
  108431. * * 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.
  108432. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  108433. * * 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.
  108434. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  108435. * * 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
  108436. * * 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
  108437. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  108438. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108439. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108440. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  108441. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  108442. * @param name defines the name of the mesh
  108443. * @param options defines the options used to create the mesh
  108444. * @param scene defines the hosting scene
  108445. * @returns the extruded shape mesh
  108446. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  108447. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  108448. */
  108449. static ExtrudeShape(name: string, options: {
  108450. shape: Vector3[];
  108451. path: Vector3[];
  108452. scale?: number;
  108453. rotation?: number;
  108454. cap?: number;
  108455. updatable?: boolean;
  108456. sideOrientation?: number;
  108457. frontUVs?: Vector4;
  108458. backUVs?: Vector4;
  108459. instance?: Mesh;
  108460. invertUV?: boolean;
  108461. }, scene?: Nullable<Scene>): Mesh;
  108462. /**
  108463. * Creates an custom extruded shape mesh.
  108464. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  108465. * * 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.
  108466. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  108467. * * 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
  108468. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  108469. * * 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
  108470. * * It must returns a float value that will be the scale value applied to the shape on each path point
  108471. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  108472. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  108473. * * 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
  108474. * * 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
  108475. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  108476. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108477. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108478. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  108479. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108480. * @param name defines the name of the mesh
  108481. * @param options defines the options used to create the mesh
  108482. * @param scene defines the hosting scene
  108483. * @returns the custom extruded shape mesh
  108484. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  108485. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  108486. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  108487. */
  108488. static ExtrudeShapeCustom(name: string, options: {
  108489. shape: Vector3[];
  108490. path: Vector3[];
  108491. scaleFunction?: any;
  108492. rotationFunction?: any;
  108493. ribbonCloseArray?: boolean;
  108494. ribbonClosePath?: boolean;
  108495. cap?: number;
  108496. updatable?: boolean;
  108497. sideOrientation?: number;
  108498. frontUVs?: Vector4;
  108499. backUVs?: Vector4;
  108500. instance?: Mesh;
  108501. invertUV?: boolean;
  108502. }, scene?: Nullable<Scene>): Mesh;
  108503. private static _ExtrudeShapeGeneric;
  108504. }
  108505. }
  108506. declare module BABYLON {
  108507. /**
  108508. * AmmoJS Physics plugin
  108509. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  108510. * @see https://github.com/kripken/ammo.js/
  108511. */
  108512. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  108513. private _useDeltaForWorldStep;
  108514. /**
  108515. * Reference to the Ammo library
  108516. */
  108517. bjsAMMO: any;
  108518. /**
  108519. * Created ammoJS world which physics bodies are added to
  108520. */
  108521. world: any;
  108522. /**
  108523. * Name of the plugin
  108524. */
  108525. name: string;
  108526. private _timeStep;
  108527. private _fixedTimeStep;
  108528. private _maxSteps;
  108529. private _tmpQuaternion;
  108530. private _tmpAmmoTransform;
  108531. private _tmpAmmoQuaternion;
  108532. private _tmpAmmoConcreteContactResultCallback;
  108533. private _collisionConfiguration;
  108534. private _dispatcher;
  108535. private _overlappingPairCache;
  108536. private _solver;
  108537. private _softBodySolver;
  108538. private _tmpAmmoVectorA;
  108539. private _tmpAmmoVectorB;
  108540. private _tmpAmmoVectorC;
  108541. private _tmpAmmoVectorD;
  108542. private _tmpContactCallbackResult;
  108543. private _tmpAmmoVectorRCA;
  108544. private _tmpAmmoVectorRCB;
  108545. private _raycastResult;
  108546. private static readonly DISABLE_COLLISION_FLAG;
  108547. private static readonly KINEMATIC_FLAG;
  108548. private static readonly DISABLE_DEACTIVATION_FLAG;
  108549. /**
  108550. * Initializes the ammoJS plugin
  108551. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  108552. * @param ammoInjection can be used to inject your own ammo reference
  108553. */
  108554. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  108555. /**
  108556. * Sets the gravity of the physics world (m/(s^2))
  108557. * @param gravity Gravity to set
  108558. */
  108559. setGravity(gravity: Vector3): void;
  108560. /**
  108561. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  108562. * @param timeStep timestep to use in seconds
  108563. */
  108564. setTimeStep(timeStep: number): void;
  108565. /**
  108566. * 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)
  108567. * @param fixedTimeStep fixedTimeStep to use in seconds
  108568. */
  108569. setFixedTimeStep(fixedTimeStep: number): void;
  108570. /**
  108571. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  108572. * @param maxSteps the maximum number of steps by the physics engine per frame
  108573. */
  108574. setMaxSteps(maxSteps: number): void;
  108575. /**
  108576. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  108577. * @returns the current timestep in seconds
  108578. */
  108579. getTimeStep(): number;
  108580. private _isImpostorInContact;
  108581. private _isImpostorPairInContact;
  108582. private _stepSimulation;
  108583. /**
  108584. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  108585. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  108586. * After the step the babylon meshes are set to the position of the physics imposters
  108587. * @param delta amount of time to step forward
  108588. * @param impostors array of imposters to update before/after the step
  108589. */
  108590. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  108591. /**
  108592. * Update babylon mesh to match physics world object
  108593. * @param impostor imposter to match
  108594. */
  108595. private _afterSoftStep;
  108596. /**
  108597. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  108598. * @param impostor imposter to match
  108599. */
  108600. private _ropeStep;
  108601. /**
  108602. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  108603. * @param impostor imposter to match
  108604. */
  108605. private _softbodyOrClothStep;
  108606. private _tmpVector;
  108607. private _tmpMatrix;
  108608. /**
  108609. * Applies an impulse on the imposter
  108610. * @param impostor imposter to apply impulse to
  108611. * @param force amount of force to be applied to the imposter
  108612. * @param contactPoint the location to apply the impulse on the imposter
  108613. */
  108614. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  108615. /**
  108616. * Applies a force on the imposter
  108617. * @param impostor imposter to apply force
  108618. * @param force amount of force to be applied to the imposter
  108619. * @param contactPoint the location to apply the force on the imposter
  108620. */
  108621. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  108622. /**
  108623. * Creates a physics body using the plugin
  108624. * @param impostor the imposter to create the physics body on
  108625. */
  108626. generatePhysicsBody(impostor: PhysicsImpostor): void;
  108627. /**
  108628. * Removes the physics body from the imposter and disposes of the body's memory
  108629. * @param impostor imposter to remove the physics body from
  108630. */
  108631. removePhysicsBody(impostor: PhysicsImpostor): void;
  108632. /**
  108633. * Generates a joint
  108634. * @param impostorJoint the imposter joint to create the joint with
  108635. */
  108636. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  108637. /**
  108638. * Removes a joint
  108639. * @param impostorJoint the imposter joint to remove the joint from
  108640. */
  108641. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  108642. private _addMeshVerts;
  108643. /**
  108644. * Initialise the soft body vertices to match its object's (mesh) vertices
  108645. * Softbody vertices (nodes) are in world space and to match this
  108646. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  108647. * @param impostor to create the softbody for
  108648. */
  108649. private _softVertexData;
  108650. /**
  108651. * Create an impostor's soft body
  108652. * @param impostor to create the softbody for
  108653. */
  108654. private _createSoftbody;
  108655. /**
  108656. * Create cloth for an impostor
  108657. * @param impostor to create the softbody for
  108658. */
  108659. private _createCloth;
  108660. /**
  108661. * Create rope for an impostor
  108662. * @param impostor to create the softbody for
  108663. */
  108664. private _createRope;
  108665. private _addHullVerts;
  108666. private _createShape;
  108667. /**
  108668. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  108669. * @param impostor imposter containing the physics body and babylon object
  108670. */
  108671. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  108672. /**
  108673. * Sets the babylon object's position/rotation from the physics body's position/rotation
  108674. * @param impostor imposter containing the physics body and babylon object
  108675. * @param newPosition new position
  108676. * @param newRotation new rotation
  108677. */
  108678. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  108679. /**
  108680. * If this plugin is supported
  108681. * @returns true if its supported
  108682. */
  108683. isSupported(): boolean;
  108684. /**
  108685. * Sets the linear velocity of the physics body
  108686. * @param impostor imposter to set the velocity on
  108687. * @param velocity velocity to set
  108688. */
  108689. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  108690. /**
  108691. * Sets the angular velocity of the physics body
  108692. * @param impostor imposter to set the velocity on
  108693. * @param velocity velocity to set
  108694. */
  108695. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  108696. /**
  108697. * gets the linear velocity
  108698. * @param impostor imposter to get linear velocity from
  108699. * @returns linear velocity
  108700. */
  108701. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  108702. /**
  108703. * gets the angular velocity
  108704. * @param impostor imposter to get angular velocity from
  108705. * @returns angular velocity
  108706. */
  108707. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  108708. /**
  108709. * Sets the mass of physics body
  108710. * @param impostor imposter to set the mass on
  108711. * @param mass mass to set
  108712. */
  108713. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  108714. /**
  108715. * Gets the mass of the physics body
  108716. * @param impostor imposter to get the mass from
  108717. * @returns mass
  108718. */
  108719. getBodyMass(impostor: PhysicsImpostor): number;
  108720. /**
  108721. * Gets friction of the impostor
  108722. * @param impostor impostor to get friction from
  108723. * @returns friction value
  108724. */
  108725. getBodyFriction(impostor: PhysicsImpostor): number;
  108726. /**
  108727. * Sets friction of the impostor
  108728. * @param impostor impostor to set friction on
  108729. * @param friction friction value
  108730. */
  108731. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  108732. /**
  108733. * Gets restitution of the impostor
  108734. * @param impostor impostor to get restitution from
  108735. * @returns restitution value
  108736. */
  108737. getBodyRestitution(impostor: PhysicsImpostor): number;
  108738. /**
  108739. * Sets resitution of the impostor
  108740. * @param impostor impostor to set resitution on
  108741. * @param restitution resitution value
  108742. */
  108743. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  108744. /**
  108745. * Gets pressure inside the impostor
  108746. * @param impostor impostor to get pressure from
  108747. * @returns pressure value
  108748. */
  108749. getBodyPressure(impostor: PhysicsImpostor): number;
  108750. /**
  108751. * Sets pressure inside a soft body impostor
  108752. * Cloth and rope must remain 0 pressure
  108753. * @param impostor impostor to set pressure on
  108754. * @param pressure pressure value
  108755. */
  108756. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  108757. /**
  108758. * Gets stiffness of the impostor
  108759. * @param impostor impostor to get stiffness from
  108760. * @returns pressure value
  108761. */
  108762. getBodyStiffness(impostor: PhysicsImpostor): number;
  108763. /**
  108764. * Sets stiffness of the impostor
  108765. * @param impostor impostor to set stiffness on
  108766. * @param stiffness stiffness value from 0 to 1
  108767. */
  108768. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  108769. /**
  108770. * Gets velocityIterations of the impostor
  108771. * @param impostor impostor to get velocity iterations from
  108772. * @returns velocityIterations value
  108773. */
  108774. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  108775. /**
  108776. * Sets velocityIterations of the impostor
  108777. * @param impostor impostor to set velocity iterations on
  108778. * @param velocityIterations velocityIterations value
  108779. */
  108780. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  108781. /**
  108782. * Gets positionIterations of the impostor
  108783. * @param impostor impostor to get position iterations from
  108784. * @returns positionIterations value
  108785. */
  108786. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  108787. /**
  108788. * Sets positionIterations of the impostor
  108789. * @param impostor impostor to set position on
  108790. * @param positionIterations positionIterations value
  108791. */
  108792. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  108793. /**
  108794. * Append an anchor to a cloth object
  108795. * @param impostor is the cloth impostor to add anchor to
  108796. * @param otherImpostor is the rigid impostor to anchor to
  108797. * @param width ratio across width from 0 to 1
  108798. * @param height ratio up height from 0 to 1
  108799. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  108800. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  108801. */
  108802. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  108803. /**
  108804. * Append an hook to a rope object
  108805. * @param impostor is the rope impostor to add hook to
  108806. * @param otherImpostor is the rigid impostor to hook to
  108807. * @param length ratio along the rope from 0 to 1
  108808. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  108809. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  108810. */
  108811. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  108812. /**
  108813. * Sleeps the physics body and stops it from being active
  108814. * @param impostor impostor to sleep
  108815. */
  108816. sleepBody(impostor: PhysicsImpostor): void;
  108817. /**
  108818. * Activates the physics body
  108819. * @param impostor impostor to activate
  108820. */
  108821. wakeUpBody(impostor: PhysicsImpostor): void;
  108822. /**
  108823. * Updates the distance parameters of the joint
  108824. * @param joint joint to update
  108825. * @param maxDistance maximum distance of the joint
  108826. * @param minDistance minimum distance of the joint
  108827. */
  108828. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  108829. /**
  108830. * Sets a motor on the joint
  108831. * @param joint joint to set motor on
  108832. * @param speed speed of the motor
  108833. * @param maxForce maximum force of the motor
  108834. * @param motorIndex index of the motor
  108835. */
  108836. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  108837. /**
  108838. * Sets the motors limit
  108839. * @param joint joint to set limit on
  108840. * @param upperLimit upper limit
  108841. * @param lowerLimit lower limit
  108842. */
  108843. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  108844. /**
  108845. * Syncs the position and rotation of a mesh with the impostor
  108846. * @param mesh mesh to sync
  108847. * @param impostor impostor to update the mesh with
  108848. */
  108849. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  108850. /**
  108851. * Gets the radius of the impostor
  108852. * @param impostor impostor to get radius from
  108853. * @returns the radius
  108854. */
  108855. getRadius(impostor: PhysicsImpostor): number;
  108856. /**
  108857. * Gets the box size of the impostor
  108858. * @param impostor impostor to get box size from
  108859. * @param result the resulting box size
  108860. */
  108861. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  108862. /**
  108863. * Disposes of the impostor
  108864. */
  108865. dispose(): void;
  108866. /**
  108867. * Does a raycast in the physics world
  108868. * @param from when should the ray start?
  108869. * @param to when should the ray end?
  108870. * @returns PhysicsRaycastResult
  108871. */
  108872. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  108873. }
  108874. }
  108875. declare module BABYLON {
  108876. interface AbstractScene {
  108877. /**
  108878. * The list of reflection probes added to the scene
  108879. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  108880. */
  108881. reflectionProbes: Array<ReflectionProbe>;
  108882. /**
  108883. * Removes the given reflection probe from this scene.
  108884. * @param toRemove The reflection probe to remove
  108885. * @returns The index of the removed reflection probe
  108886. */
  108887. removeReflectionProbe(toRemove: ReflectionProbe): number;
  108888. /**
  108889. * Adds the given reflection probe to this scene.
  108890. * @param newReflectionProbe The reflection probe to add
  108891. */
  108892. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  108893. }
  108894. /**
  108895. * Class used to generate realtime reflection / refraction cube textures
  108896. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  108897. */
  108898. export class ReflectionProbe {
  108899. /** defines the name of the probe */
  108900. name: string;
  108901. private _scene;
  108902. private _renderTargetTexture;
  108903. private _projectionMatrix;
  108904. private _viewMatrix;
  108905. private _target;
  108906. private _add;
  108907. private _attachedMesh;
  108908. private _invertYAxis;
  108909. /** Gets or sets probe position (center of the cube map) */
  108910. position: Vector3;
  108911. /**
  108912. * Creates a new reflection probe
  108913. * @param name defines the name of the probe
  108914. * @param size defines the texture resolution (for each face)
  108915. * @param scene defines the hosting scene
  108916. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  108917. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  108918. */
  108919. constructor(
  108920. /** defines the name of the probe */
  108921. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  108922. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  108923. samples: number;
  108924. /** Gets or sets the refresh rate to use (on every frame by default) */
  108925. refreshRate: number;
  108926. /**
  108927. * Gets the hosting scene
  108928. * @returns a Scene
  108929. */
  108930. getScene(): Scene;
  108931. /** Gets the internal CubeTexture used to render to */
  108932. readonly cubeTexture: RenderTargetTexture;
  108933. /** Gets the list of meshes to render */
  108934. readonly renderList: Nullable<AbstractMesh[]>;
  108935. /**
  108936. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  108937. * @param mesh defines the mesh to attach to
  108938. */
  108939. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  108940. /**
  108941. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  108942. * @param renderingGroupId The rendering group id corresponding to its index
  108943. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  108944. */
  108945. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  108946. /**
  108947. * Clean all associated resources
  108948. */
  108949. dispose(): void;
  108950. /**
  108951. * Converts the reflection probe information to a readable string for debug purpose.
  108952. * @param fullDetails Supports for multiple levels of logging within scene loading
  108953. * @returns the human readable reflection probe info
  108954. */
  108955. toString(fullDetails?: boolean): string;
  108956. /**
  108957. * Get the class name of the relfection probe.
  108958. * @returns "ReflectionProbe"
  108959. */
  108960. getClassName(): string;
  108961. /**
  108962. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  108963. * @returns The JSON representation of the texture
  108964. */
  108965. serialize(): any;
  108966. /**
  108967. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  108968. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  108969. * @param scene Define the scene the parsed reflection probe should be instantiated in
  108970. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  108971. * @returns The parsed reflection probe if successful
  108972. */
  108973. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  108974. }
  108975. }
  108976. declare module BABYLON {
  108977. /** @hidden */
  108978. export var _BabylonLoaderRegistered: boolean;
  108979. }
  108980. declare module BABYLON {
  108981. /**
  108982. * The Physically based simple base material of BJS.
  108983. *
  108984. * This enables better naming and convention enforcements on top of the pbrMaterial.
  108985. * It is used as the base class for both the specGloss and metalRough conventions.
  108986. */
  108987. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  108988. /**
  108989. * Number of Simultaneous lights allowed on the material.
  108990. */
  108991. maxSimultaneousLights: number;
  108992. /**
  108993. * If sets to true, disables all the lights affecting the material.
  108994. */
  108995. disableLighting: boolean;
  108996. /**
  108997. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  108998. */
  108999. environmentTexture: BaseTexture;
  109000. /**
  109001. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  109002. */
  109003. invertNormalMapX: boolean;
  109004. /**
  109005. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  109006. */
  109007. invertNormalMapY: boolean;
  109008. /**
  109009. * Normal map used in the model.
  109010. */
  109011. normalTexture: BaseTexture;
  109012. /**
  109013. * Emissivie color used to self-illuminate the model.
  109014. */
  109015. emissiveColor: Color3;
  109016. /**
  109017. * Emissivie texture used to self-illuminate the model.
  109018. */
  109019. emissiveTexture: BaseTexture;
  109020. /**
  109021. * Occlusion Channel Strenght.
  109022. */
  109023. occlusionStrength: number;
  109024. /**
  109025. * Occlusion Texture of the material (adding extra occlusion effects).
  109026. */
  109027. occlusionTexture: BaseTexture;
  109028. /**
  109029. * Defines the alpha limits in alpha test mode.
  109030. */
  109031. alphaCutOff: number;
  109032. /**
  109033. * Gets the current double sided mode.
  109034. */
  109035. /**
  109036. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  109037. */
  109038. doubleSided: boolean;
  109039. /**
  109040. * Stores the pre-calculated light information of a mesh in a texture.
  109041. */
  109042. lightmapTexture: BaseTexture;
  109043. /**
  109044. * If true, the light map contains occlusion information instead of lighting info.
  109045. */
  109046. useLightmapAsShadowmap: boolean;
  109047. /**
  109048. * Instantiates a new PBRMaterial instance.
  109049. *
  109050. * @param name The material name
  109051. * @param scene The scene the material will be use in.
  109052. */
  109053. constructor(name: string, scene: Scene);
  109054. getClassName(): string;
  109055. }
  109056. }
  109057. declare module BABYLON {
  109058. /**
  109059. * The PBR material of BJS following the metal roughness convention.
  109060. *
  109061. * This fits to the PBR convention in the GLTF definition:
  109062. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  109063. */
  109064. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  109065. /**
  109066. * The base color has two different interpretations depending on the value of metalness.
  109067. * When the material is a metal, the base color is the specific measured reflectance value
  109068. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  109069. * of the material.
  109070. */
  109071. baseColor: Color3;
  109072. /**
  109073. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  109074. * well as opacity information in the alpha channel.
  109075. */
  109076. baseTexture: BaseTexture;
  109077. /**
  109078. * Specifies the metallic scalar value of the material.
  109079. * Can also be used to scale the metalness values of the metallic texture.
  109080. */
  109081. metallic: number;
  109082. /**
  109083. * Specifies the roughness scalar value of the material.
  109084. * Can also be used to scale the roughness values of the metallic texture.
  109085. */
  109086. roughness: number;
  109087. /**
  109088. * Texture containing both the metallic value in the B channel and the
  109089. * roughness value in the G channel to keep better precision.
  109090. */
  109091. metallicRoughnessTexture: BaseTexture;
  109092. /**
  109093. * Instantiates a new PBRMetalRoughnessMaterial instance.
  109094. *
  109095. * @param name The material name
  109096. * @param scene The scene the material will be use in.
  109097. */
  109098. constructor(name: string, scene: Scene);
  109099. /**
  109100. * Return the currrent class name of the material.
  109101. */
  109102. getClassName(): string;
  109103. /**
  109104. * Makes a duplicate of the current material.
  109105. * @param name - name to use for the new material.
  109106. */
  109107. clone(name: string): PBRMetallicRoughnessMaterial;
  109108. /**
  109109. * Serialize the material to a parsable JSON object.
  109110. */
  109111. serialize(): any;
  109112. /**
  109113. * Parses a JSON object correponding to the serialize function.
  109114. */
  109115. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  109116. }
  109117. }
  109118. declare module BABYLON {
  109119. /**
  109120. * The PBR material of BJS following the specular glossiness convention.
  109121. *
  109122. * This fits to the PBR convention in the GLTF definition:
  109123. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  109124. */
  109125. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  109126. /**
  109127. * Specifies the diffuse color of the material.
  109128. */
  109129. diffuseColor: Color3;
  109130. /**
  109131. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  109132. * channel.
  109133. */
  109134. diffuseTexture: BaseTexture;
  109135. /**
  109136. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  109137. */
  109138. specularColor: Color3;
  109139. /**
  109140. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  109141. */
  109142. glossiness: number;
  109143. /**
  109144. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  109145. */
  109146. specularGlossinessTexture: BaseTexture;
  109147. /**
  109148. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  109149. *
  109150. * @param name The material name
  109151. * @param scene The scene the material will be use in.
  109152. */
  109153. constructor(name: string, scene: Scene);
  109154. /**
  109155. * Return the currrent class name of the material.
  109156. */
  109157. getClassName(): string;
  109158. /**
  109159. * Makes a duplicate of the current material.
  109160. * @param name - name to use for the new material.
  109161. */
  109162. clone(name: string): PBRSpecularGlossinessMaterial;
  109163. /**
  109164. * Serialize the material to a parsable JSON object.
  109165. */
  109166. serialize(): any;
  109167. /**
  109168. * Parses a JSON object correponding to the serialize function.
  109169. */
  109170. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  109171. }
  109172. }
  109173. declare module BABYLON {
  109174. /**
  109175. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  109176. * It can help converting any input color in a desired output one. This can then be used to create effects
  109177. * from sepia, black and white to sixties or futuristic rendering...
  109178. *
  109179. * The only supported format is currently 3dl.
  109180. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  109181. */
  109182. export class ColorGradingTexture extends BaseTexture {
  109183. /**
  109184. * The current texture matrix. (will always be identity in color grading texture)
  109185. */
  109186. private _textureMatrix;
  109187. /**
  109188. * The texture URL.
  109189. */
  109190. url: string;
  109191. /**
  109192. * Empty line regex stored for GC.
  109193. */
  109194. private static _noneEmptyLineRegex;
  109195. private _engine;
  109196. /**
  109197. * Instantiates a ColorGradingTexture from the following parameters.
  109198. *
  109199. * @param url The location of the color gradind data (currently only supporting 3dl)
  109200. * @param scene The scene the texture will be used in
  109201. */
  109202. constructor(url: string, scene: Scene);
  109203. /**
  109204. * Returns the texture matrix used in most of the material.
  109205. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  109206. */
  109207. getTextureMatrix(): Matrix;
  109208. /**
  109209. * Occurs when the file being loaded is a .3dl LUT file.
  109210. */
  109211. private load3dlTexture;
  109212. /**
  109213. * Starts the loading process of the texture.
  109214. */
  109215. private loadTexture;
  109216. /**
  109217. * Clones the color gradind texture.
  109218. */
  109219. clone(): ColorGradingTexture;
  109220. /**
  109221. * Called during delayed load for textures.
  109222. */
  109223. delayLoad(): void;
  109224. /**
  109225. * Parses a color grading texture serialized by Babylon.
  109226. * @param parsedTexture The texture information being parsedTexture
  109227. * @param scene The scene to load the texture in
  109228. * @param rootUrl The root url of the data assets to load
  109229. * @return A color gradind texture
  109230. */
  109231. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  109232. /**
  109233. * Serializes the LUT texture to json format.
  109234. */
  109235. serialize(): any;
  109236. }
  109237. }
  109238. declare module BABYLON {
  109239. /**
  109240. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  109241. */
  109242. export class EquiRectangularCubeTexture extends BaseTexture {
  109243. /** The six faces of the cube. */
  109244. private static _FacesMapping;
  109245. private _noMipmap;
  109246. private _onLoad;
  109247. private _onError;
  109248. /** The size of the cubemap. */
  109249. private _size;
  109250. /** The buffer of the image. */
  109251. private _buffer;
  109252. /** The width of the input image. */
  109253. private _width;
  109254. /** The height of the input image. */
  109255. private _height;
  109256. /** The URL to the image. */
  109257. url: string;
  109258. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  109259. coordinatesMode: number;
  109260. /**
  109261. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  109262. * @param url The location of the image
  109263. * @param scene The scene the texture will be used in
  109264. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  109265. * @param noMipmap Forces to not generate the mipmap if true
  109266. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  109267. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  109268. * @param onLoad — defines a callback called when texture is loaded
  109269. * @param onError — defines a callback called if there is an error
  109270. */
  109271. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  109272. /**
  109273. * Load the image data, by putting the image on a canvas and extracting its buffer.
  109274. */
  109275. private loadImage;
  109276. /**
  109277. * Convert the image buffer into a cubemap and create a CubeTexture.
  109278. */
  109279. private loadTexture;
  109280. /**
  109281. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  109282. * @param buffer The ArrayBuffer that should be converted.
  109283. * @returns The buffer as Float32Array.
  109284. */
  109285. private getFloat32ArrayFromArrayBuffer;
  109286. /**
  109287. * Get the current class name of the texture useful for serialization or dynamic coding.
  109288. * @returns "EquiRectangularCubeTexture"
  109289. */
  109290. getClassName(): string;
  109291. /**
  109292. * Create a clone of the current EquiRectangularCubeTexture and return it.
  109293. * @returns A clone of the current EquiRectangularCubeTexture.
  109294. */
  109295. clone(): EquiRectangularCubeTexture;
  109296. }
  109297. }
  109298. declare module BABYLON {
  109299. /**
  109300. * Based on jsTGALoader - Javascript loader for TGA file
  109301. * By Vincent Thibault
  109302. * @see http://blog.robrowser.com/javascript-tga-loader.html
  109303. */
  109304. export class TGATools {
  109305. private static _TYPE_INDEXED;
  109306. private static _TYPE_RGB;
  109307. private static _TYPE_GREY;
  109308. private static _TYPE_RLE_INDEXED;
  109309. private static _TYPE_RLE_RGB;
  109310. private static _TYPE_RLE_GREY;
  109311. private static _ORIGIN_MASK;
  109312. private static _ORIGIN_SHIFT;
  109313. private static _ORIGIN_BL;
  109314. private static _ORIGIN_BR;
  109315. private static _ORIGIN_UL;
  109316. private static _ORIGIN_UR;
  109317. /**
  109318. * Gets the header of a TGA file
  109319. * @param data defines the TGA data
  109320. * @returns the header
  109321. */
  109322. static GetTGAHeader(data: Uint8Array): any;
  109323. /**
  109324. * Uploads TGA content to a Babylon Texture
  109325. * @hidden
  109326. */
  109327. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  109328. /** @hidden */
  109329. 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;
  109330. /** @hidden */
  109331. 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;
  109332. /** @hidden */
  109333. 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;
  109334. /** @hidden */
  109335. 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;
  109336. /** @hidden */
  109337. 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;
  109338. /** @hidden */
  109339. 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;
  109340. }
  109341. }
  109342. declare module BABYLON {
  109343. /**
  109344. * Implementation of the TGA Texture Loader.
  109345. * @hidden
  109346. */
  109347. export class _TGATextureLoader implements IInternalTextureLoader {
  109348. /**
  109349. * Defines wether the loader supports cascade loading the different faces.
  109350. */
  109351. readonly supportCascades: boolean;
  109352. /**
  109353. * This returns if the loader support the current file information.
  109354. * @param extension defines the file extension of the file being loaded
  109355. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109356. * @param fallback defines the fallback internal texture if any
  109357. * @param isBase64 defines whether the texture is encoded as a base64
  109358. * @param isBuffer defines whether the texture data are stored as a buffer
  109359. * @returns true if the loader can load the specified file
  109360. */
  109361. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  109362. /**
  109363. * Transform the url before loading if required.
  109364. * @param rootUrl the url of the texture
  109365. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109366. * @returns the transformed texture
  109367. */
  109368. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  109369. /**
  109370. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  109371. * @param rootUrl the url of the texture
  109372. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109373. * @returns the fallback texture
  109374. */
  109375. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  109376. /**
  109377. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  109378. * @param data contains the texture data
  109379. * @param texture defines the BabylonJS internal texture
  109380. * @param createPolynomials will be true if polynomials have been requested
  109381. * @param onLoad defines the callback to trigger once the texture is ready
  109382. * @param onError defines the callback to trigger in case of error
  109383. */
  109384. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  109385. /**
  109386. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  109387. * @param data contains the texture data
  109388. * @param texture defines the BabylonJS internal texture
  109389. * @param callback defines the method to call once ready to upload
  109390. */
  109391. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  109392. }
  109393. }
  109394. declare module BABYLON {
  109395. /**
  109396. * 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.
  109397. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  109398. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  109399. */
  109400. export class CustomProceduralTexture extends ProceduralTexture {
  109401. private _animate;
  109402. private _time;
  109403. private _config;
  109404. private _texturePath;
  109405. /**
  109406. * Instantiates a new Custom Procedural Texture.
  109407. * 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.
  109408. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  109409. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  109410. * @param name Define the name of the texture
  109411. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  109412. * @param size Define the size of the texture to create
  109413. * @param scene Define the scene the texture belongs to
  109414. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  109415. * @param generateMipMaps Define if the texture should creates mip maps or not
  109416. */
  109417. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  109418. private _loadJson;
  109419. /**
  109420. * Is the texture ready to be used ? (rendered at least once)
  109421. * @returns true if ready, otherwise, false.
  109422. */
  109423. isReady(): boolean;
  109424. /**
  109425. * Render the texture to its associated render target.
  109426. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  109427. */
  109428. render(useCameraPostProcess?: boolean): void;
  109429. /**
  109430. * Update the list of dependant textures samplers in the shader.
  109431. */
  109432. updateTextures(): void;
  109433. /**
  109434. * Update the uniform values of the procedural texture in the shader.
  109435. */
  109436. updateShaderUniforms(): void;
  109437. /**
  109438. * Define if the texture animates or not.
  109439. */
  109440. animate: boolean;
  109441. }
  109442. }
  109443. declare module BABYLON {
  109444. /** @hidden */
  109445. export var noisePixelShader: {
  109446. name: string;
  109447. shader: string;
  109448. };
  109449. }
  109450. declare module BABYLON {
  109451. /**
  109452. * Class used to generate noise procedural textures
  109453. */
  109454. export class NoiseProceduralTexture extends ProceduralTexture {
  109455. private _time;
  109456. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  109457. brightness: number;
  109458. /** Defines the number of octaves to process */
  109459. octaves: number;
  109460. /** Defines the level of persistence (0.8 by default) */
  109461. persistence: number;
  109462. /** Gets or sets animation speed factor (default is 1) */
  109463. animationSpeedFactor: number;
  109464. /**
  109465. * Creates a new NoiseProceduralTexture
  109466. * @param name defines the name fo the texture
  109467. * @param size defines the size of the texture (default is 256)
  109468. * @param scene defines the hosting scene
  109469. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  109470. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  109471. */
  109472. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  109473. private _updateShaderUniforms;
  109474. protected _getDefines(): string;
  109475. /** Generate the current state of the procedural texture */
  109476. render(useCameraPostProcess?: boolean): void;
  109477. /**
  109478. * Serializes this noise procedural texture
  109479. * @returns a serialized noise procedural texture object
  109480. */
  109481. serialize(): any;
  109482. /**
  109483. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  109484. * @param parsedTexture defines parsed texture data
  109485. * @param scene defines the current scene
  109486. * @param rootUrl defines the root URL containing noise procedural texture information
  109487. * @returns a parsed NoiseProceduralTexture
  109488. */
  109489. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  109490. }
  109491. }
  109492. declare module BABYLON {
  109493. /**
  109494. * Raw cube texture where the raw buffers are passed in
  109495. */
  109496. export class RawCubeTexture extends CubeTexture {
  109497. /**
  109498. * Creates a cube texture where the raw buffers are passed in.
  109499. * @param scene defines the scene the texture is attached to
  109500. * @param data defines the array of data to use to create each face
  109501. * @param size defines the size of the textures
  109502. * @param format defines the format of the data
  109503. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  109504. * @param generateMipMaps defines if the engine should generate the mip levels
  109505. * @param invertY defines if data must be stored with Y axis inverted
  109506. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  109507. * @param compression defines the compression used (null by default)
  109508. */
  109509. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  109510. /**
  109511. * Updates the raw cube texture.
  109512. * @param data defines the data to store
  109513. * @param format defines the data format
  109514. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  109515. * @param invertY defines if data must be stored with Y axis inverted
  109516. * @param compression defines the compression used (null by default)
  109517. * @param level defines which level of the texture to update
  109518. */
  109519. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  109520. /**
  109521. * Updates a raw cube texture with RGBD encoded data.
  109522. * @param data defines the array of data [mipmap][face] to use to create each face
  109523. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  109524. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  109525. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  109526. * @returns a promsie that resolves when the operation is complete
  109527. */
  109528. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  109529. /**
  109530. * Clones the raw cube texture.
  109531. * @return a new cube texture
  109532. */
  109533. clone(): CubeTexture;
  109534. /** @hidden */
  109535. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  109536. }
  109537. }
  109538. declare module BABYLON {
  109539. /**
  109540. * Class used to store 3D textures containing user data
  109541. */
  109542. export class RawTexture3D extends Texture {
  109543. /** Gets or sets the texture format to use */
  109544. format: number;
  109545. private _engine;
  109546. /**
  109547. * Create a new RawTexture3D
  109548. * @param data defines the data of the texture
  109549. * @param width defines the width of the texture
  109550. * @param height defines the height of the texture
  109551. * @param depth defines the depth of the texture
  109552. * @param format defines the texture format to use
  109553. * @param scene defines the hosting scene
  109554. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  109555. * @param invertY defines if texture must be stored with Y axis inverted
  109556. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  109557. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  109558. */
  109559. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  109560. /** Gets or sets the texture format to use */
  109561. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  109562. /**
  109563. * Update the texture with new data
  109564. * @param data defines the data to store in the texture
  109565. */
  109566. update(data: ArrayBufferView): void;
  109567. }
  109568. }
  109569. declare module BABYLON {
  109570. /**
  109571. * Creates a refraction texture used by refraction channel of the standard material.
  109572. * It is like a mirror but to see through a material.
  109573. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  109574. */
  109575. export class RefractionTexture extends RenderTargetTexture {
  109576. /**
  109577. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  109578. * 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.
  109579. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  109580. */
  109581. refractionPlane: Plane;
  109582. /**
  109583. * Define how deep under the surface we should see.
  109584. */
  109585. depth: number;
  109586. /**
  109587. * Creates a refraction texture used by refraction channel of the standard material.
  109588. * It is like a mirror but to see through a material.
  109589. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  109590. * @param name Define the texture name
  109591. * @param size Define the size of the underlying texture
  109592. * @param scene Define the scene the refraction belongs to
  109593. * @param generateMipMaps Define if we need to generate mips level for the refraction
  109594. */
  109595. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  109596. /**
  109597. * Clone the refraction texture.
  109598. * @returns the cloned texture
  109599. */
  109600. clone(): RefractionTexture;
  109601. /**
  109602. * Serialize the texture to a JSON representation you could use in Parse later on
  109603. * @returns the serialized JSON representation
  109604. */
  109605. serialize(): any;
  109606. }
  109607. }
  109608. declare module BABYLON {
  109609. /**
  109610. * Defines the options related to the creation of an HtmlElementTexture
  109611. */
  109612. export interface IHtmlElementTextureOptions {
  109613. /**
  109614. * Defines wether mip maps should be created or not.
  109615. */
  109616. generateMipMaps?: boolean;
  109617. /**
  109618. * Defines the sampling mode of the texture.
  109619. */
  109620. samplingMode?: number;
  109621. /**
  109622. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  109623. */
  109624. engine: Nullable<Engine>;
  109625. /**
  109626. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  109627. */
  109628. scene: Nullable<Scene>;
  109629. }
  109630. /**
  109631. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  109632. * To be as efficient as possible depending on your constraints nothing aside the first upload
  109633. * is automatically managed.
  109634. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  109635. * in your application.
  109636. *
  109637. * As the update is not automatic, you need to call them manually.
  109638. */
  109639. export class HtmlElementTexture extends BaseTexture {
  109640. /**
  109641. * The texture URL.
  109642. */
  109643. element: HTMLVideoElement | HTMLCanvasElement;
  109644. private static readonly DefaultOptions;
  109645. private _textureMatrix;
  109646. private _engine;
  109647. private _isVideo;
  109648. private _generateMipMaps;
  109649. private _samplingMode;
  109650. /**
  109651. * Instantiates a HtmlElementTexture from the following parameters.
  109652. *
  109653. * @param name Defines the name of the texture
  109654. * @param element Defines the video or canvas the texture is filled with
  109655. * @param options Defines the other none mandatory texture creation options
  109656. */
  109657. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  109658. private _createInternalTexture;
  109659. /**
  109660. * Returns the texture matrix used in most of the material.
  109661. */
  109662. getTextureMatrix(): Matrix;
  109663. /**
  109664. * Updates the content of the texture.
  109665. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  109666. */
  109667. update(invertY?: Nullable<boolean>): void;
  109668. }
  109669. }
  109670. declare module BABYLON {
  109671. /**
  109672. * Helper class to push actions to a pool of workers.
  109673. */
  109674. export class WorkerPool implements IDisposable {
  109675. private _workerInfos;
  109676. private _pendingActions;
  109677. /**
  109678. * Constructor
  109679. * @param workers Array of workers to use for actions
  109680. */
  109681. constructor(workers: Array<Worker>);
  109682. /**
  109683. * Terminates all workers and clears any pending actions.
  109684. */
  109685. dispose(): void;
  109686. /**
  109687. * Pushes an action to the worker pool. If all the workers are active, the action will be
  109688. * pended until a worker has completed its action.
  109689. * @param action The action to perform. Call onComplete when the action is complete.
  109690. */
  109691. push(action: (worker: Worker, onComplete: () => void) => void): void;
  109692. private _execute;
  109693. }
  109694. }
  109695. declare module BABYLON {
  109696. /**
  109697. * Configuration for Draco compression
  109698. */
  109699. export interface IDracoCompressionConfiguration {
  109700. /**
  109701. * Configuration for the decoder.
  109702. */
  109703. decoder: {
  109704. /**
  109705. * The url to the WebAssembly module.
  109706. */
  109707. wasmUrl?: string;
  109708. /**
  109709. * The url to the WebAssembly binary.
  109710. */
  109711. wasmBinaryUrl?: string;
  109712. /**
  109713. * The url to the fallback JavaScript module.
  109714. */
  109715. fallbackUrl?: string;
  109716. };
  109717. }
  109718. /**
  109719. * Draco compression (https://google.github.io/draco/)
  109720. *
  109721. * This class wraps the Draco module.
  109722. *
  109723. * **Encoder**
  109724. *
  109725. * The encoder is not currently implemented.
  109726. *
  109727. * **Decoder**
  109728. *
  109729. * 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.
  109730. *
  109731. * To update the configuration, use the following code:
  109732. * ```javascript
  109733. * DracoCompression.Configuration = {
  109734. * decoder: {
  109735. * wasmUrl: "<url to the WebAssembly library>",
  109736. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  109737. * fallbackUrl: "<url to the fallback JavaScript library>",
  109738. * }
  109739. * };
  109740. * ```
  109741. *
  109742. * 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.
  109743. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  109744. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  109745. *
  109746. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  109747. * ```javascript
  109748. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  109749. * ```
  109750. *
  109751. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  109752. */
  109753. export class DracoCompression implements IDisposable {
  109754. private _workerPoolPromise?;
  109755. private _decoderModulePromise?;
  109756. /**
  109757. * The configuration. Defaults to the following urls:
  109758. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  109759. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  109760. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  109761. */
  109762. static Configuration: IDracoCompressionConfiguration;
  109763. /**
  109764. * Returns true if the decoder configuration is available.
  109765. */
  109766. static readonly DecoderAvailable: boolean;
  109767. /**
  109768. * Default number of workers to create when creating the draco compression object.
  109769. */
  109770. static DefaultNumWorkers: number;
  109771. private static GetDefaultNumWorkers;
  109772. private static _Default;
  109773. /**
  109774. * Default instance for the draco compression object.
  109775. */
  109776. static readonly Default: DracoCompression;
  109777. /**
  109778. * Constructor
  109779. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  109780. */
  109781. constructor(numWorkers?: number);
  109782. /**
  109783. * Stop all async operations and release resources.
  109784. */
  109785. dispose(): void;
  109786. /**
  109787. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  109788. * @returns a promise that resolves when ready
  109789. */
  109790. whenReadyAsync(): Promise<void>;
  109791. /**
  109792. * Decode Draco compressed mesh data to vertex data.
  109793. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  109794. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  109795. * @returns A promise that resolves with the decoded vertex data
  109796. */
  109797. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  109798. [kind: string]: number;
  109799. }): Promise<VertexData>;
  109800. }
  109801. }
  109802. declare module BABYLON {
  109803. /**
  109804. * Class for building Constructive Solid Geometry
  109805. */
  109806. export class CSG {
  109807. private polygons;
  109808. /**
  109809. * The world matrix
  109810. */
  109811. matrix: Matrix;
  109812. /**
  109813. * Stores the position
  109814. */
  109815. position: Vector3;
  109816. /**
  109817. * Stores the rotation
  109818. */
  109819. rotation: Vector3;
  109820. /**
  109821. * Stores the rotation quaternion
  109822. */
  109823. rotationQuaternion: Nullable<Quaternion>;
  109824. /**
  109825. * Stores the scaling vector
  109826. */
  109827. scaling: Vector3;
  109828. /**
  109829. * Convert the Mesh to CSG
  109830. * @param mesh The Mesh to convert to CSG
  109831. * @returns A new CSG from the Mesh
  109832. */
  109833. static FromMesh(mesh: Mesh): CSG;
  109834. /**
  109835. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  109836. * @param polygons Polygons used to construct a CSG solid
  109837. */
  109838. private static FromPolygons;
  109839. /**
  109840. * Clones, or makes a deep copy, of the CSG
  109841. * @returns A new CSG
  109842. */
  109843. clone(): CSG;
  109844. /**
  109845. * Unions this CSG with another CSG
  109846. * @param csg The CSG to union against this CSG
  109847. * @returns The unioned CSG
  109848. */
  109849. union(csg: CSG): CSG;
  109850. /**
  109851. * Unions this CSG with another CSG in place
  109852. * @param csg The CSG to union against this CSG
  109853. */
  109854. unionInPlace(csg: CSG): void;
  109855. /**
  109856. * Subtracts this CSG with another CSG
  109857. * @param csg The CSG to subtract against this CSG
  109858. * @returns A new CSG
  109859. */
  109860. subtract(csg: CSG): CSG;
  109861. /**
  109862. * Subtracts this CSG with another CSG in place
  109863. * @param csg The CSG to subtact against this CSG
  109864. */
  109865. subtractInPlace(csg: CSG): void;
  109866. /**
  109867. * Intersect this CSG with another CSG
  109868. * @param csg The CSG to intersect against this CSG
  109869. * @returns A new CSG
  109870. */
  109871. intersect(csg: CSG): CSG;
  109872. /**
  109873. * Intersects this CSG with another CSG in place
  109874. * @param csg The CSG to intersect against this CSG
  109875. */
  109876. intersectInPlace(csg: CSG): void;
  109877. /**
  109878. * Return a new CSG solid with solid and empty space switched. This solid is
  109879. * not modified.
  109880. * @returns A new CSG solid with solid and empty space switched
  109881. */
  109882. inverse(): CSG;
  109883. /**
  109884. * Inverses the CSG in place
  109885. */
  109886. inverseInPlace(): void;
  109887. /**
  109888. * This is used to keep meshes transformations so they can be restored
  109889. * when we build back a Babylon Mesh
  109890. * NB : All CSG operations are performed in world coordinates
  109891. * @param csg The CSG to copy the transform attributes from
  109892. * @returns This CSG
  109893. */
  109894. copyTransformAttributes(csg: CSG): CSG;
  109895. /**
  109896. * Build Raw mesh from CSG
  109897. * Coordinates here are in world space
  109898. * @param name The name of the mesh geometry
  109899. * @param scene The Scene
  109900. * @param keepSubMeshes Specifies if the submeshes should be kept
  109901. * @returns A new Mesh
  109902. */
  109903. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  109904. /**
  109905. * Build Mesh from CSG taking material and transforms into account
  109906. * @param name The name of the Mesh
  109907. * @param material The material of the Mesh
  109908. * @param scene The Scene
  109909. * @param keepSubMeshes Specifies if submeshes should be kept
  109910. * @returns The new Mesh
  109911. */
  109912. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  109913. }
  109914. }
  109915. declare module BABYLON {
  109916. /**
  109917. * Class used to create a trail following a mesh
  109918. */
  109919. export class TrailMesh extends Mesh {
  109920. private _generator;
  109921. private _autoStart;
  109922. private _running;
  109923. private _diameter;
  109924. private _length;
  109925. private _sectionPolygonPointsCount;
  109926. private _sectionVectors;
  109927. private _sectionNormalVectors;
  109928. private _beforeRenderObserver;
  109929. /**
  109930. * @constructor
  109931. * @param name The value used by scene.getMeshByName() to do a lookup.
  109932. * @param generator The mesh to generate a trail.
  109933. * @param scene The scene to add this mesh to.
  109934. * @param diameter Diameter of trailing mesh. Default is 1.
  109935. * @param length Length of trailing mesh. Default is 60.
  109936. * @param autoStart Automatically start trailing mesh. Default true.
  109937. */
  109938. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  109939. /**
  109940. * "TrailMesh"
  109941. * @returns "TrailMesh"
  109942. */
  109943. getClassName(): string;
  109944. private _createMesh;
  109945. /**
  109946. * Start trailing mesh.
  109947. */
  109948. start(): void;
  109949. /**
  109950. * Stop trailing mesh.
  109951. */
  109952. stop(): void;
  109953. /**
  109954. * Update trailing mesh geometry.
  109955. */
  109956. update(): void;
  109957. /**
  109958. * Returns a new TrailMesh object.
  109959. * @param name is a string, the name given to the new mesh
  109960. * @param newGenerator use new generator object for cloned trail mesh
  109961. * @returns a new mesh
  109962. */
  109963. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  109964. /**
  109965. * Serializes this trail mesh
  109966. * @param serializationObject object to write serialization to
  109967. */
  109968. serialize(serializationObject: any): void;
  109969. /**
  109970. * Parses a serialized trail mesh
  109971. * @param parsedMesh the serialized mesh
  109972. * @param scene the scene to create the trail mesh in
  109973. * @returns the created trail mesh
  109974. */
  109975. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  109976. }
  109977. }
  109978. declare module BABYLON {
  109979. /**
  109980. * Class containing static functions to help procedurally build meshes
  109981. */
  109982. export class TorusKnotBuilder {
  109983. /**
  109984. * Creates a torus knot mesh
  109985. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  109986. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  109987. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  109988. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  109989. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109990. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109991. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109992. * @param name defines the name of the mesh
  109993. * @param options defines the options used to create the mesh
  109994. * @param scene defines the hosting scene
  109995. * @returns the torus knot mesh
  109996. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  109997. */
  109998. static CreateTorusKnot(name: string, options: {
  109999. radius?: number;
  110000. tube?: number;
  110001. radialSegments?: number;
  110002. tubularSegments?: number;
  110003. p?: number;
  110004. q?: number;
  110005. updatable?: boolean;
  110006. sideOrientation?: number;
  110007. frontUVs?: Vector4;
  110008. backUVs?: Vector4;
  110009. }, scene: any): Mesh;
  110010. }
  110011. }
  110012. declare module BABYLON {
  110013. /**
  110014. * Polygon
  110015. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  110016. */
  110017. export class Polygon {
  110018. /**
  110019. * Creates a rectangle
  110020. * @param xmin bottom X coord
  110021. * @param ymin bottom Y coord
  110022. * @param xmax top X coord
  110023. * @param ymax top Y coord
  110024. * @returns points that make the resulting rectation
  110025. */
  110026. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  110027. /**
  110028. * Creates a circle
  110029. * @param radius radius of circle
  110030. * @param cx scale in x
  110031. * @param cy scale in y
  110032. * @param numberOfSides number of sides that make up the circle
  110033. * @returns points that make the resulting circle
  110034. */
  110035. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  110036. /**
  110037. * Creates a polygon from input string
  110038. * @param input Input polygon data
  110039. * @returns the parsed points
  110040. */
  110041. static Parse(input: string): Vector2[];
  110042. /**
  110043. * Starts building a polygon from x and y coordinates
  110044. * @param x x coordinate
  110045. * @param y y coordinate
  110046. * @returns the started path2
  110047. */
  110048. static StartingAt(x: number, y: number): Path2;
  110049. }
  110050. /**
  110051. * Builds a polygon
  110052. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  110053. */
  110054. export class PolygonMeshBuilder {
  110055. private _points;
  110056. private _outlinepoints;
  110057. private _holes;
  110058. private _name;
  110059. private _scene;
  110060. private _epoints;
  110061. private _eholes;
  110062. private _addToepoint;
  110063. /**
  110064. * Babylon reference to the earcut plugin.
  110065. */
  110066. bjsEarcut: any;
  110067. /**
  110068. * Creates a PolygonMeshBuilder
  110069. * @param name name of the builder
  110070. * @param contours Path of the polygon
  110071. * @param scene scene to add to when creating the mesh
  110072. * @param earcutInjection can be used to inject your own earcut reference
  110073. */
  110074. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  110075. /**
  110076. * Adds a whole within the polygon
  110077. * @param hole Array of points defining the hole
  110078. * @returns this
  110079. */
  110080. addHole(hole: Vector2[]): PolygonMeshBuilder;
  110081. /**
  110082. * Creates the polygon
  110083. * @param updatable If the mesh should be updatable
  110084. * @param depth The depth of the mesh created
  110085. * @returns the created mesh
  110086. */
  110087. build(updatable?: boolean, depth?: number): Mesh;
  110088. /**
  110089. * Creates the polygon
  110090. * @param depth The depth of the mesh created
  110091. * @returns the created VertexData
  110092. */
  110093. buildVertexData(depth?: number): VertexData;
  110094. /**
  110095. * Adds a side to the polygon
  110096. * @param positions points that make the polygon
  110097. * @param normals normals of the polygon
  110098. * @param uvs uvs of the polygon
  110099. * @param indices indices of the polygon
  110100. * @param bounds bounds of the polygon
  110101. * @param points points of the polygon
  110102. * @param depth depth of the polygon
  110103. * @param flip flip of the polygon
  110104. */
  110105. private addSide;
  110106. }
  110107. }
  110108. declare module BABYLON {
  110109. /**
  110110. * Class containing static functions to help procedurally build meshes
  110111. */
  110112. export class PolygonBuilder {
  110113. /**
  110114. * Creates a polygon mesh
  110115. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  110116. * * 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
  110117. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  110118. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110119. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  110120. * * Remember you can only change the shape positions, not their number when updating a polygon
  110121. * @param name defines the name of the mesh
  110122. * @param options defines the options used to create the mesh
  110123. * @param scene defines the hosting scene
  110124. * @param earcutInjection can be used to inject your own earcut reference
  110125. * @returns the polygon mesh
  110126. */
  110127. static CreatePolygon(name: string, options: {
  110128. shape: Vector3[];
  110129. holes?: Vector3[][];
  110130. depth?: number;
  110131. faceUV?: Vector4[];
  110132. faceColors?: Color4[];
  110133. updatable?: boolean;
  110134. sideOrientation?: number;
  110135. frontUVs?: Vector4;
  110136. backUVs?: Vector4;
  110137. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  110138. /**
  110139. * Creates an extruded polygon mesh, with depth in the Y direction.
  110140. * * 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)
  110141. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  110142. * @param name defines the name of the mesh
  110143. * @param options defines the options used to create the mesh
  110144. * @param scene defines the hosting scene
  110145. * @param earcutInjection can be used to inject your own earcut reference
  110146. * @returns the polygon mesh
  110147. */
  110148. static ExtrudePolygon(name: string, options: {
  110149. shape: Vector3[];
  110150. holes?: Vector3[][];
  110151. depth?: number;
  110152. faceUV?: Vector4[];
  110153. faceColors?: Color4[];
  110154. updatable?: boolean;
  110155. sideOrientation?: number;
  110156. frontUVs?: Vector4;
  110157. backUVs?: Vector4;
  110158. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  110159. }
  110160. }
  110161. declare module BABYLON {
  110162. /**
  110163. * Class containing static functions to help procedurally build meshes
  110164. */
  110165. export class LatheBuilder {
  110166. /**
  110167. * Creates lathe mesh.
  110168. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  110169. * * 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
  110170. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  110171. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  110172. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  110173. * * 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
  110174. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  110175. * * 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
  110176. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110177. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110178. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  110179. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110180. * @param name defines the name of the mesh
  110181. * @param options defines the options used to create the mesh
  110182. * @param scene defines the hosting scene
  110183. * @returns the lathe mesh
  110184. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  110185. */
  110186. static CreateLathe(name: string, options: {
  110187. shape: Vector3[];
  110188. radius?: number;
  110189. tessellation?: number;
  110190. clip?: number;
  110191. arc?: number;
  110192. closed?: boolean;
  110193. updatable?: boolean;
  110194. sideOrientation?: number;
  110195. frontUVs?: Vector4;
  110196. backUVs?: Vector4;
  110197. cap?: number;
  110198. invertUV?: boolean;
  110199. }, scene?: Nullable<Scene>): Mesh;
  110200. }
  110201. }
  110202. declare module BABYLON {
  110203. /**
  110204. * Class containing static functions to help procedurally build meshes
  110205. */
  110206. export class TubeBuilder {
  110207. /**
  110208. * Creates a tube mesh.
  110209. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  110210. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  110211. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  110212. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  110213. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  110214. * * 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)
  110215. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  110216. * * 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
  110217. * * 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
  110218. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110219. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110220. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  110221. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110222. * @param name defines the name of the mesh
  110223. * @param options defines the options used to create the mesh
  110224. * @param scene defines the hosting scene
  110225. * @returns the tube mesh
  110226. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  110227. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  110228. */
  110229. static CreateTube(name: string, options: {
  110230. path: Vector3[];
  110231. radius?: number;
  110232. tessellation?: number;
  110233. radiusFunction?: {
  110234. (i: number, distance: number): number;
  110235. };
  110236. cap?: number;
  110237. arc?: number;
  110238. updatable?: boolean;
  110239. sideOrientation?: number;
  110240. frontUVs?: Vector4;
  110241. backUVs?: Vector4;
  110242. instance?: Mesh;
  110243. invertUV?: boolean;
  110244. }, scene?: Nullable<Scene>): Mesh;
  110245. }
  110246. }
  110247. declare module BABYLON {
  110248. /**
  110249. * Class containing static functions to help procedurally build meshes
  110250. */
  110251. export class IcoSphereBuilder {
  110252. /**
  110253. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  110254. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  110255. * * 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`)
  110256. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  110257. * * 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
  110258. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110259. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110260. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110261. * @param name defines the name of the mesh
  110262. * @param options defines the options used to create the mesh
  110263. * @param scene defines the hosting scene
  110264. * @returns the icosahedron mesh
  110265. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  110266. */
  110267. static CreateIcoSphere(name: string, options: {
  110268. radius?: number;
  110269. radiusX?: number;
  110270. radiusY?: number;
  110271. radiusZ?: number;
  110272. flat?: boolean;
  110273. subdivisions?: number;
  110274. sideOrientation?: number;
  110275. frontUVs?: Vector4;
  110276. backUVs?: Vector4;
  110277. updatable?: boolean;
  110278. }, scene?: Nullable<Scene>): Mesh;
  110279. }
  110280. }
  110281. declare module BABYLON {
  110282. /**
  110283. * Class containing static functions to help procedurally build meshes
  110284. */
  110285. export class DecalBuilder {
  110286. /**
  110287. * Creates a decal mesh.
  110288. * 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
  110289. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  110290. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  110291. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  110292. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  110293. * @param name defines the name of the mesh
  110294. * @param sourceMesh defines the mesh where the decal must be applied
  110295. * @param options defines the options used to create the mesh
  110296. * @param scene defines the hosting scene
  110297. * @returns the decal mesh
  110298. * @see https://doc.babylonjs.com/how_to/decals
  110299. */
  110300. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  110301. position?: Vector3;
  110302. normal?: Vector3;
  110303. size?: Vector3;
  110304. angle?: number;
  110305. }): Mesh;
  110306. }
  110307. }
  110308. declare module BABYLON {
  110309. /**
  110310. * Class containing static functions to help procedurally build meshes
  110311. */
  110312. export class MeshBuilder {
  110313. /**
  110314. * Creates a box mesh
  110315. * * The parameter `size` sets the size (float) of each box side (default 1)
  110316. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  110317. * * 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)
  110318. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  110319. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110320. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110321. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110322. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  110323. * @param name defines the name of the mesh
  110324. * @param options defines the options used to create the mesh
  110325. * @param scene defines the hosting scene
  110326. * @returns the box mesh
  110327. */
  110328. static CreateBox(name: string, options: {
  110329. size?: number;
  110330. width?: number;
  110331. height?: number;
  110332. depth?: number;
  110333. faceUV?: Vector4[];
  110334. faceColors?: Color4[];
  110335. sideOrientation?: number;
  110336. frontUVs?: Vector4;
  110337. backUVs?: Vector4;
  110338. updatable?: boolean;
  110339. }, scene?: Nullable<Scene>): Mesh;
  110340. /**
  110341. * Creates a sphere mesh
  110342. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  110343. * * 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`)
  110344. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  110345. * * 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
  110346. * * 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)
  110347. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110348. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110349. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110350. * @param name defines the name of the mesh
  110351. * @param options defines the options used to create the mesh
  110352. * @param scene defines the hosting scene
  110353. * @returns the sphere mesh
  110354. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  110355. */
  110356. static CreateSphere(name: string, options: {
  110357. segments?: number;
  110358. diameter?: number;
  110359. diameterX?: number;
  110360. diameterY?: number;
  110361. diameterZ?: number;
  110362. arc?: number;
  110363. slice?: number;
  110364. sideOrientation?: number;
  110365. frontUVs?: Vector4;
  110366. backUVs?: Vector4;
  110367. updatable?: boolean;
  110368. }, scene?: Nullable<Scene>): Mesh;
  110369. /**
  110370. * Creates a plane polygonal mesh. By default, this is a disc
  110371. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  110372. * * 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
  110373. * * 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
  110374. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110375. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110376. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110377. * @param name defines the name of the mesh
  110378. * @param options defines the options used to create the mesh
  110379. * @param scene defines the hosting scene
  110380. * @returns the plane polygonal mesh
  110381. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  110382. */
  110383. static CreateDisc(name: string, options: {
  110384. radius?: number;
  110385. tessellation?: number;
  110386. arc?: number;
  110387. updatable?: boolean;
  110388. sideOrientation?: number;
  110389. frontUVs?: Vector4;
  110390. backUVs?: Vector4;
  110391. }, scene?: Nullable<Scene>): Mesh;
  110392. /**
  110393. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  110394. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  110395. * * 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`)
  110396. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  110397. * * 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
  110398. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110399. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110400. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110401. * @param name defines the name of the mesh
  110402. * @param options defines the options used to create the mesh
  110403. * @param scene defines the hosting scene
  110404. * @returns the icosahedron mesh
  110405. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  110406. */
  110407. static CreateIcoSphere(name: string, options: {
  110408. radius?: number;
  110409. radiusX?: number;
  110410. radiusY?: number;
  110411. radiusZ?: number;
  110412. flat?: boolean;
  110413. subdivisions?: number;
  110414. sideOrientation?: number;
  110415. frontUVs?: Vector4;
  110416. backUVs?: Vector4;
  110417. updatable?: boolean;
  110418. }, scene?: Nullable<Scene>): Mesh;
  110419. /**
  110420. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  110421. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  110422. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  110423. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  110424. * * 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
  110425. * * 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
  110426. * * 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
  110427. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110428. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110429. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  110430. * * 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
  110431. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  110432. * * 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
  110433. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  110434. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110435. * @param name defines the name of the mesh
  110436. * @param options defines the options used to create the mesh
  110437. * @param scene defines the hosting scene
  110438. * @returns the ribbon mesh
  110439. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  110440. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  110441. */
  110442. static CreateRibbon(name: string, options: {
  110443. pathArray: Vector3[][];
  110444. closeArray?: boolean;
  110445. closePath?: boolean;
  110446. offset?: number;
  110447. updatable?: boolean;
  110448. sideOrientation?: number;
  110449. frontUVs?: Vector4;
  110450. backUVs?: Vector4;
  110451. instance?: Mesh;
  110452. invertUV?: boolean;
  110453. uvs?: Vector2[];
  110454. colors?: Color4[];
  110455. }, scene?: Nullable<Scene>): Mesh;
  110456. /**
  110457. * Creates a cylinder or a cone mesh
  110458. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  110459. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  110460. * * 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.
  110461. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  110462. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  110463. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  110464. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  110465. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  110466. * * 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).
  110467. * * 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
  110468. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  110469. * * 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
  110470. * * 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.
  110471. * * If `enclose` is false, a ring surface is one element.
  110472. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  110473. * * 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
  110474. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110475. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110476. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  110477. * @param name defines the name of the mesh
  110478. * @param options defines the options used to create the mesh
  110479. * @param scene defines the hosting scene
  110480. * @returns the cylinder mesh
  110481. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  110482. */
  110483. static CreateCylinder(name: string, options: {
  110484. height?: number;
  110485. diameterTop?: number;
  110486. diameterBottom?: number;
  110487. diameter?: number;
  110488. tessellation?: number;
  110489. subdivisions?: number;
  110490. arc?: number;
  110491. faceColors?: Color4[];
  110492. faceUV?: Vector4[];
  110493. updatable?: boolean;
  110494. hasRings?: boolean;
  110495. enclose?: boolean;
  110496. sideOrientation?: number;
  110497. frontUVs?: Vector4;
  110498. backUVs?: Vector4;
  110499. }, scene?: Nullable<Scene>): Mesh;
  110500. /**
  110501. * Creates a torus mesh
  110502. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  110503. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  110504. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  110505. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110506. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110507. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  110508. * @param name defines the name of the mesh
  110509. * @param options defines the options used to create the mesh
  110510. * @param scene defines the hosting scene
  110511. * @returns the torus mesh
  110512. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  110513. */
  110514. static CreateTorus(name: string, options: {
  110515. diameter?: number;
  110516. thickness?: number;
  110517. tessellation?: number;
  110518. updatable?: boolean;
  110519. sideOrientation?: number;
  110520. frontUVs?: Vector4;
  110521. backUVs?: Vector4;
  110522. }, scene?: Nullable<Scene>): Mesh;
  110523. /**
  110524. * Creates a torus knot mesh
  110525. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  110526. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  110527. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  110528. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  110529. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110530. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110531. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  110532. * @param name defines the name of the mesh
  110533. * @param options defines the options used to create the mesh
  110534. * @param scene defines the hosting scene
  110535. * @returns the torus knot mesh
  110536. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  110537. */
  110538. static CreateTorusKnot(name: string, options: {
  110539. radius?: number;
  110540. tube?: number;
  110541. radialSegments?: number;
  110542. tubularSegments?: number;
  110543. p?: number;
  110544. q?: number;
  110545. updatable?: boolean;
  110546. sideOrientation?: number;
  110547. frontUVs?: Vector4;
  110548. backUVs?: Vector4;
  110549. }, scene?: Nullable<Scene>): Mesh;
  110550. /**
  110551. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  110552. * * 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
  110553. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  110554. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  110555. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  110556. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  110557. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  110558. * * 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
  110559. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  110560. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110561. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  110562. * @param name defines the name of the new line system
  110563. * @param options defines the options used to create the line system
  110564. * @param scene defines the hosting scene
  110565. * @returns a new line system mesh
  110566. */
  110567. static CreateLineSystem(name: string, options: {
  110568. lines: Vector3[][];
  110569. updatable?: boolean;
  110570. instance?: Nullable<LinesMesh>;
  110571. colors?: Nullable<Color4[][]>;
  110572. useVertexAlpha?: boolean;
  110573. }, scene: Nullable<Scene>): LinesMesh;
  110574. /**
  110575. * Creates a line mesh
  110576. * 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
  110577. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  110578. * * The parameter `points` is an array successive Vector3
  110579. * * 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
  110580. * * The optional parameter `colors` is an array of successive Color4, one per line point
  110581. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  110582. * * When updating an instance, remember that only point positions can change, not the number of points
  110583. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110584. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  110585. * @param name defines the name of the new line system
  110586. * @param options defines the options used to create the line system
  110587. * @param scene defines the hosting scene
  110588. * @returns a new line mesh
  110589. */
  110590. static CreateLines(name: string, options: {
  110591. points: Vector3[];
  110592. updatable?: boolean;
  110593. instance?: Nullable<LinesMesh>;
  110594. colors?: Color4[];
  110595. useVertexAlpha?: boolean;
  110596. }, scene?: Nullable<Scene>): LinesMesh;
  110597. /**
  110598. * Creates a dashed line mesh
  110599. * * 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
  110600. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  110601. * * The parameter `points` is an array successive Vector3
  110602. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  110603. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  110604. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  110605. * * 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
  110606. * * When updating an instance, remember that only point positions can change, not the number of points
  110607. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110608. * @param name defines the name of the mesh
  110609. * @param options defines the options used to create the mesh
  110610. * @param scene defines the hosting scene
  110611. * @returns the dashed line mesh
  110612. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  110613. */
  110614. static CreateDashedLines(name: string, options: {
  110615. points: Vector3[];
  110616. dashSize?: number;
  110617. gapSize?: number;
  110618. dashNb?: number;
  110619. updatable?: boolean;
  110620. instance?: LinesMesh;
  110621. }, scene?: Nullable<Scene>): LinesMesh;
  110622. /**
  110623. * 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.
  110624. * * 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.
  110625. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  110626. * * 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.
  110627. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  110628. * * 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
  110629. * * 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
  110630. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  110631. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110632. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110633. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  110634. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  110635. * @param name defines the name of the mesh
  110636. * @param options defines the options used to create the mesh
  110637. * @param scene defines the hosting scene
  110638. * @returns the extruded shape mesh
  110639. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  110640. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  110641. */
  110642. static ExtrudeShape(name: string, options: {
  110643. shape: Vector3[];
  110644. path: Vector3[];
  110645. scale?: number;
  110646. rotation?: number;
  110647. cap?: number;
  110648. updatable?: boolean;
  110649. sideOrientation?: number;
  110650. frontUVs?: Vector4;
  110651. backUVs?: Vector4;
  110652. instance?: Mesh;
  110653. invertUV?: boolean;
  110654. }, scene?: Nullable<Scene>): Mesh;
  110655. /**
  110656. * Creates an custom extruded shape mesh.
  110657. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  110658. * * 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.
  110659. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  110660. * * 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
  110661. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  110662. * * 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
  110663. * * It must returns a float value that will be the scale value applied to the shape on each path point
  110664. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  110665. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  110666. * * 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
  110667. * * 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
  110668. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  110669. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110670. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110671. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  110672. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110673. * @param name defines the name of the mesh
  110674. * @param options defines the options used to create the mesh
  110675. * @param scene defines the hosting scene
  110676. * @returns the custom extruded shape mesh
  110677. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  110678. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  110679. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  110680. */
  110681. static ExtrudeShapeCustom(name: string, options: {
  110682. shape: Vector3[];
  110683. path: Vector3[];
  110684. scaleFunction?: any;
  110685. rotationFunction?: any;
  110686. ribbonCloseArray?: boolean;
  110687. ribbonClosePath?: boolean;
  110688. cap?: number;
  110689. updatable?: boolean;
  110690. sideOrientation?: number;
  110691. frontUVs?: Vector4;
  110692. backUVs?: Vector4;
  110693. instance?: Mesh;
  110694. invertUV?: boolean;
  110695. }, scene?: Nullable<Scene>): Mesh;
  110696. /**
  110697. * Creates lathe mesh.
  110698. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  110699. * * 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
  110700. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  110701. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  110702. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  110703. * * 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
  110704. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  110705. * * 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
  110706. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110707. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110708. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  110709. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110710. * @param name defines the name of the mesh
  110711. * @param options defines the options used to create the mesh
  110712. * @param scene defines the hosting scene
  110713. * @returns the lathe mesh
  110714. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  110715. */
  110716. static CreateLathe(name: string, options: {
  110717. shape: Vector3[];
  110718. radius?: number;
  110719. tessellation?: number;
  110720. clip?: number;
  110721. arc?: number;
  110722. closed?: boolean;
  110723. updatable?: boolean;
  110724. sideOrientation?: number;
  110725. frontUVs?: Vector4;
  110726. backUVs?: Vector4;
  110727. cap?: number;
  110728. invertUV?: boolean;
  110729. }, scene?: Nullable<Scene>): Mesh;
  110730. /**
  110731. * Creates a plane mesh
  110732. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  110733. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  110734. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  110735. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110736. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110737. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110738. * @param name defines the name of the mesh
  110739. * @param options defines the options used to create the mesh
  110740. * @param scene defines the hosting scene
  110741. * @returns the plane mesh
  110742. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  110743. */
  110744. static CreatePlane(name: string, options: {
  110745. size?: number;
  110746. width?: number;
  110747. height?: number;
  110748. sideOrientation?: number;
  110749. frontUVs?: Vector4;
  110750. backUVs?: Vector4;
  110751. updatable?: boolean;
  110752. sourcePlane?: Plane;
  110753. }, scene?: Nullable<Scene>): Mesh;
  110754. /**
  110755. * Creates a ground mesh
  110756. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  110757. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  110758. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110759. * @param name defines the name of the mesh
  110760. * @param options defines the options used to create the mesh
  110761. * @param scene defines the hosting scene
  110762. * @returns the ground mesh
  110763. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  110764. */
  110765. static CreateGround(name: string, options: {
  110766. width?: number;
  110767. height?: number;
  110768. subdivisions?: number;
  110769. subdivisionsX?: number;
  110770. subdivisionsY?: number;
  110771. updatable?: boolean;
  110772. }, scene?: Nullable<Scene>): Mesh;
  110773. /**
  110774. * Creates a tiled ground mesh
  110775. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  110776. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  110777. * * 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
  110778. * * 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
  110779. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  110780. * @param name defines the name of the mesh
  110781. * @param options defines the options used to create the mesh
  110782. * @param scene defines the hosting scene
  110783. * @returns the tiled ground mesh
  110784. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  110785. */
  110786. static CreateTiledGround(name: string, options: {
  110787. xmin: number;
  110788. zmin: number;
  110789. xmax: number;
  110790. zmax: number;
  110791. subdivisions?: {
  110792. w: number;
  110793. h: number;
  110794. };
  110795. precision?: {
  110796. w: number;
  110797. h: number;
  110798. };
  110799. updatable?: boolean;
  110800. }, scene?: Nullable<Scene>): Mesh;
  110801. /**
  110802. * Creates a ground mesh from a height map
  110803. * * The parameter `url` sets the URL of the height map image resource.
  110804. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  110805. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  110806. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  110807. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  110808. * * 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.
  110809. * * 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).
  110810. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  110811. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  110812. * @param name defines the name of the mesh
  110813. * @param url defines the url to the height map
  110814. * @param options defines the options used to create the mesh
  110815. * @param scene defines the hosting scene
  110816. * @returns the ground mesh
  110817. * @see https://doc.babylonjs.com/babylon101/height_map
  110818. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  110819. */
  110820. static CreateGroundFromHeightMap(name: string, url: string, options: {
  110821. width?: number;
  110822. height?: number;
  110823. subdivisions?: number;
  110824. minHeight?: number;
  110825. maxHeight?: number;
  110826. colorFilter?: Color3;
  110827. alphaFilter?: number;
  110828. updatable?: boolean;
  110829. onReady?: (mesh: GroundMesh) => void;
  110830. }, scene?: Nullable<Scene>): GroundMesh;
  110831. /**
  110832. * Creates a polygon mesh
  110833. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  110834. * * 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
  110835. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  110836. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110837. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  110838. * * Remember you can only change the shape positions, not their number when updating a polygon
  110839. * @param name defines the name of the mesh
  110840. * @param options defines the options used to create the mesh
  110841. * @param scene defines the hosting scene
  110842. * @param earcutInjection can be used to inject your own earcut reference
  110843. * @returns the polygon mesh
  110844. */
  110845. static CreatePolygon(name: string, options: {
  110846. shape: Vector3[];
  110847. holes?: Vector3[][];
  110848. depth?: number;
  110849. faceUV?: Vector4[];
  110850. faceColors?: Color4[];
  110851. updatable?: boolean;
  110852. sideOrientation?: number;
  110853. frontUVs?: Vector4;
  110854. backUVs?: Vector4;
  110855. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  110856. /**
  110857. * Creates an extruded polygon mesh, with depth in the Y direction.
  110858. * * 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)
  110859. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  110860. * @param name defines the name of the mesh
  110861. * @param options defines the options used to create the mesh
  110862. * @param scene defines the hosting scene
  110863. * @param earcutInjection can be used to inject your own earcut reference
  110864. * @returns the polygon mesh
  110865. */
  110866. static ExtrudePolygon(name: string, options: {
  110867. shape: Vector3[];
  110868. holes?: Vector3[][];
  110869. depth?: number;
  110870. faceUV?: Vector4[];
  110871. faceColors?: Color4[];
  110872. updatable?: boolean;
  110873. sideOrientation?: number;
  110874. frontUVs?: Vector4;
  110875. backUVs?: Vector4;
  110876. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  110877. /**
  110878. * Creates a tube mesh.
  110879. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  110880. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  110881. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  110882. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  110883. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  110884. * * 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)
  110885. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  110886. * * 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
  110887. * * 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
  110888. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110889. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110890. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  110891. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110892. * @param name defines the name of the mesh
  110893. * @param options defines the options used to create the mesh
  110894. * @param scene defines the hosting scene
  110895. * @returns the tube mesh
  110896. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  110897. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  110898. */
  110899. static CreateTube(name: string, options: {
  110900. path: Vector3[];
  110901. radius?: number;
  110902. tessellation?: number;
  110903. radiusFunction?: {
  110904. (i: number, distance: number): number;
  110905. };
  110906. cap?: number;
  110907. arc?: number;
  110908. updatable?: boolean;
  110909. sideOrientation?: number;
  110910. frontUVs?: Vector4;
  110911. backUVs?: Vector4;
  110912. instance?: Mesh;
  110913. invertUV?: boolean;
  110914. }, scene?: Nullable<Scene>): Mesh;
  110915. /**
  110916. * Creates a polyhedron mesh
  110917. * * 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
  110918. * * The parameter `size` (positive float, default 1) sets the polygon size
  110919. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  110920. * * 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`
  110921. * * 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
  110922. * * 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)`)
  110923. * * 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
  110924. * * 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
  110925. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110926. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110927. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110928. * @param name defines the name of the mesh
  110929. * @param options defines the options used to create the mesh
  110930. * @param scene defines the hosting scene
  110931. * @returns the polyhedron mesh
  110932. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  110933. */
  110934. static CreatePolyhedron(name: string, options: {
  110935. type?: number;
  110936. size?: number;
  110937. sizeX?: number;
  110938. sizeY?: number;
  110939. sizeZ?: number;
  110940. custom?: any;
  110941. faceUV?: Vector4[];
  110942. faceColors?: Color4[];
  110943. flat?: boolean;
  110944. updatable?: boolean;
  110945. sideOrientation?: number;
  110946. frontUVs?: Vector4;
  110947. backUVs?: Vector4;
  110948. }, scene?: Nullable<Scene>): Mesh;
  110949. /**
  110950. * Creates a decal mesh.
  110951. * 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
  110952. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  110953. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  110954. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  110955. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  110956. * @param name defines the name of the mesh
  110957. * @param sourceMesh defines the mesh where the decal must be applied
  110958. * @param options defines the options used to create the mesh
  110959. * @param scene defines the hosting scene
  110960. * @returns the decal mesh
  110961. * @see https://doc.babylonjs.com/how_to/decals
  110962. */
  110963. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  110964. position?: Vector3;
  110965. normal?: Vector3;
  110966. size?: Vector3;
  110967. angle?: number;
  110968. }): Mesh;
  110969. }
  110970. }
  110971. declare module BABYLON {
  110972. /**
  110973. * A simplifier interface for future simplification implementations
  110974. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  110975. */
  110976. export interface ISimplifier {
  110977. /**
  110978. * Simplification of a given mesh according to the given settings.
  110979. * Since this requires computation, it is assumed that the function runs async.
  110980. * @param settings The settings of the simplification, including quality and distance
  110981. * @param successCallback A callback that will be called after the mesh was simplified.
  110982. * @param errorCallback in case of an error, this callback will be called. optional.
  110983. */
  110984. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  110985. }
  110986. /**
  110987. * Expected simplification settings.
  110988. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  110989. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  110990. */
  110991. export interface ISimplificationSettings {
  110992. /**
  110993. * Gets or sets the expected quality
  110994. */
  110995. quality: number;
  110996. /**
  110997. * Gets or sets the distance when this optimized version should be used
  110998. */
  110999. distance: number;
  111000. /**
  111001. * Gets an already optimized mesh
  111002. */
  111003. optimizeMesh?: boolean;
  111004. }
  111005. /**
  111006. * Class used to specify simplification options
  111007. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  111008. */
  111009. export class SimplificationSettings implements ISimplificationSettings {
  111010. /** expected quality */
  111011. quality: number;
  111012. /** distance when this optimized version should be used */
  111013. distance: number;
  111014. /** already optimized mesh */
  111015. optimizeMesh?: boolean | undefined;
  111016. /**
  111017. * Creates a SimplificationSettings
  111018. * @param quality expected quality
  111019. * @param distance distance when this optimized version should be used
  111020. * @param optimizeMesh already optimized mesh
  111021. */
  111022. constructor(
  111023. /** expected quality */
  111024. quality: number,
  111025. /** distance when this optimized version should be used */
  111026. distance: number,
  111027. /** already optimized mesh */
  111028. optimizeMesh?: boolean | undefined);
  111029. }
  111030. /**
  111031. * Interface used to define a simplification task
  111032. */
  111033. export interface ISimplificationTask {
  111034. /**
  111035. * Array of settings
  111036. */
  111037. settings: Array<ISimplificationSettings>;
  111038. /**
  111039. * Simplification type
  111040. */
  111041. simplificationType: SimplificationType;
  111042. /**
  111043. * Mesh to simplify
  111044. */
  111045. mesh: Mesh;
  111046. /**
  111047. * Callback called on success
  111048. */
  111049. successCallback?: () => void;
  111050. /**
  111051. * Defines if parallel processing can be used
  111052. */
  111053. parallelProcessing: boolean;
  111054. }
  111055. /**
  111056. * Queue used to order the simplification tasks
  111057. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  111058. */
  111059. export class SimplificationQueue {
  111060. private _simplificationArray;
  111061. /**
  111062. * Gets a boolean indicating that the process is still running
  111063. */
  111064. running: boolean;
  111065. /**
  111066. * Creates a new queue
  111067. */
  111068. constructor();
  111069. /**
  111070. * Adds a new simplification task
  111071. * @param task defines a task to add
  111072. */
  111073. addTask(task: ISimplificationTask): void;
  111074. /**
  111075. * Execute next task
  111076. */
  111077. executeNext(): void;
  111078. /**
  111079. * Execute a simplification task
  111080. * @param task defines the task to run
  111081. */
  111082. runSimplification(task: ISimplificationTask): void;
  111083. private getSimplifier;
  111084. }
  111085. /**
  111086. * The implemented types of simplification
  111087. * At the moment only Quadratic Error Decimation is implemented
  111088. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  111089. */
  111090. export enum SimplificationType {
  111091. /** Quadratic error decimation */
  111092. QUADRATIC = 0
  111093. }
  111094. }
  111095. declare module BABYLON {
  111096. interface Scene {
  111097. /** @hidden (Backing field) */
  111098. _simplificationQueue: SimplificationQueue;
  111099. /**
  111100. * Gets or sets the simplification queue attached to the scene
  111101. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  111102. */
  111103. simplificationQueue: SimplificationQueue;
  111104. }
  111105. interface Mesh {
  111106. /**
  111107. * Simplify the mesh according to the given array of settings.
  111108. * Function will return immediately and will simplify async
  111109. * @param settings a collection of simplification settings
  111110. * @param parallelProcessing should all levels calculate parallel or one after the other
  111111. * @param simplificationType the type of simplification to run
  111112. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  111113. * @returns the current mesh
  111114. */
  111115. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  111116. }
  111117. /**
  111118. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  111119. * created in a scene
  111120. */
  111121. export class SimplicationQueueSceneComponent implements ISceneComponent {
  111122. /**
  111123. * The component name helpfull to identify the component in the list of scene components.
  111124. */
  111125. readonly name: string;
  111126. /**
  111127. * The scene the component belongs to.
  111128. */
  111129. scene: Scene;
  111130. /**
  111131. * Creates a new instance of the component for the given scene
  111132. * @param scene Defines the scene to register the component in
  111133. */
  111134. constructor(scene: Scene);
  111135. /**
  111136. * Registers the component in a given scene
  111137. */
  111138. register(): void;
  111139. /**
  111140. * Rebuilds the elements related to this component in case of
  111141. * context lost for instance.
  111142. */
  111143. rebuild(): void;
  111144. /**
  111145. * Disposes the component and the associated ressources
  111146. */
  111147. dispose(): void;
  111148. private _beforeCameraUpdate;
  111149. }
  111150. }
  111151. declare module BABYLON {
  111152. /**
  111153. * Class used to enable access to IndexedDB
  111154. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  111155. */
  111156. export class Database implements IOfflineProvider {
  111157. private _callbackManifestChecked;
  111158. private _currentSceneUrl;
  111159. private _db;
  111160. private _enableSceneOffline;
  111161. private _enableTexturesOffline;
  111162. private _manifestVersionFound;
  111163. private _mustUpdateRessources;
  111164. private _hasReachedQuota;
  111165. private _isSupported;
  111166. private _idbFactory;
  111167. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  111168. private static IsUASupportingBlobStorage;
  111169. /**
  111170. * Gets a boolean indicating if Database storate is enabled (off by default)
  111171. */
  111172. static IDBStorageEnabled: boolean;
  111173. /**
  111174. * Gets a boolean indicating if scene must be saved in the database
  111175. */
  111176. readonly enableSceneOffline: boolean;
  111177. /**
  111178. * Gets a boolean indicating if textures must be saved in the database
  111179. */
  111180. readonly enableTexturesOffline: boolean;
  111181. /**
  111182. * Creates a new Database
  111183. * @param urlToScene defines the url to load the scene
  111184. * @param callbackManifestChecked defines the callback to use when manifest is checked
  111185. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  111186. */
  111187. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  111188. private static _ParseURL;
  111189. private static _ReturnFullUrlLocation;
  111190. private _checkManifestFile;
  111191. /**
  111192. * Open the database and make it available
  111193. * @param successCallback defines the callback to call on success
  111194. * @param errorCallback defines the callback to call on error
  111195. */
  111196. open(successCallback: () => void, errorCallback: () => void): void;
  111197. /**
  111198. * Loads an image from the database
  111199. * @param url defines the url to load from
  111200. * @param image defines the target DOM image
  111201. */
  111202. loadImage(url: string, image: HTMLImageElement): void;
  111203. private _loadImageFromDBAsync;
  111204. private _saveImageIntoDBAsync;
  111205. private _checkVersionFromDB;
  111206. private _loadVersionFromDBAsync;
  111207. private _saveVersionIntoDBAsync;
  111208. /**
  111209. * Loads a file from database
  111210. * @param url defines the URL to load from
  111211. * @param sceneLoaded defines a callback to call on success
  111212. * @param progressCallBack defines a callback to call when progress changed
  111213. * @param errorCallback defines a callback to call on error
  111214. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  111215. */
  111216. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  111217. private _loadFileAsync;
  111218. private _saveFileAsync;
  111219. /**
  111220. * Validates if xhr data is correct
  111221. * @param xhr defines the request to validate
  111222. * @param dataType defines the expected data type
  111223. * @returns true if data is correct
  111224. */
  111225. private static _ValidateXHRData;
  111226. }
  111227. }
  111228. declare module BABYLON {
  111229. /** @hidden */
  111230. export var gpuUpdateParticlesPixelShader: {
  111231. name: string;
  111232. shader: string;
  111233. };
  111234. }
  111235. declare module BABYLON {
  111236. /** @hidden */
  111237. export var gpuUpdateParticlesVertexShader: {
  111238. name: string;
  111239. shader: string;
  111240. };
  111241. }
  111242. declare module BABYLON {
  111243. /** @hidden */
  111244. export var clipPlaneFragmentDeclaration2: {
  111245. name: string;
  111246. shader: string;
  111247. };
  111248. }
  111249. declare module BABYLON {
  111250. /** @hidden */
  111251. export var gpuRenderParticlesPixelShader: {
  111252. name: string;
  111253. shader: string;
  111254. };
  111255. }
  111256. declare module BABYLON {
  111257. /** @hidden */
  111258. export var clipPlaneVertexDeclaration2: {
  111259. name: string;
  111260. shader: string;
  111261. };
  111262. }
  111263. declare module BABYLON {
  111264. /** @hidden */
  111265. export var gpuRenderParticlesVertexShader: {
  111266. name: string;
  111267. shader: string;
  111268. };
  111269. }
  111270. declare module BABYLON {
  111271. /**
  111272. * This represents a GPU particle system in Babylon
  111273. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  111274. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  111275. */
  111276. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  111277. /**
  111278. * The layer mask we are rendering the particles through.
  111279. */
  111280. layerMask: number;
  111281. private _capacity;
  111282. private _activeCount;
  111283. private _currentActiveCount;
  111284. private _accumulatedCount;
  111285. private _renderEffect;
  111286. private _updateEffect;
  111287. private _buffer0;
  111288. private _buffer1;
  111289. private _spriteBuffer;
  111290. private _updateVAO;
  111291. private _renderVAO;
  111292. private _targetIndex;
  111293. private _sourceBuffer;
  111294. private _targetBuffer;
  111295. private _engine;
  111296. private _currentRenderId;
  111297. private _started;
  111298. private _stopped;
  111299. private _timeDelta;
  111300. private _randomTexture;
  111301. private _randomTexture2;
  111302. private _attributesStrideSize;
  111303. private _updateEffectOptions;
  111304. private _randomTextureSize;
  111305. private _actualFrame;
  111306. private readonly _rawTextureWidth;
  111307. /**
  111308. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  111309. */
  111310. static readonly IsSupported: boolean;
  111311. /**
  111312. * An event triggered when the system is disposed.
  111313. */
  111314. onDisposeObservable: Observable<GPUParticleSystem>;
  111315. /**
  111316. * Gets the maximum number of particles active at the same time.
  111317. * @returns The max number of active particles.
  111318. */
  111319. getCapacity(): number;
  111320. /**
  111321. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  111322. * to override the particles.
  111323. */
  111324. forceDepthWrite: boolean;
  111325. /**
  111326. * Gets or set the number of active particles
  111327. */
  111328. activeParticleCount: number;
  111329. private _preWarmDone;
  111330. /**
  111331. * Is this system ready to be used/rendered
  111332. * @return true if the system is ready
  111333. */
  111334. isReady(): boolean;
  111335. /**
  111336. * Gets if the system has been started. (Note: this will still be true after stop is called)
  111337. * @returns True if it has been started, otherwise false.
  111338. */
  111339. isStarted(): boolean;
  111340. /**
  111341. * Starts the particle system and begins to emit
  111342. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  111343. */
  111344. start(delay?: number): void;
  111345. /**
  111346. * Stops the particle system.
  111347. */
  111348. stop(): void;
  111349. /**
  111350. * Remove all active particles
  111351. */
  111352. reset(): void;
  111353. /**
  111354. * Returns the string "GPUParticleSystem"
  111355. * @returns a string containing the class name
  111356. */
  111357. getClassName(): string;
  111358. private _colorGradientsTexture;
  111359. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  111360. /**
  111361. * Adds a new color gradient
  111362. * @param gradient defines the gradient to use (between 0 and 1)
  111363. * @param color1 defines the color to affect to the specified gradient
  111364. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  111365. * @returns the current particle system
  111366. */
  111367. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  111368. /**
  111369. * Remove a specific color gradient
  111370. * @param gradient defines the gradient to remove
  111371. * @returns the current particle system
  111372. */
  111373. removeColorGradient(gradient: number): GPUParticleSystem;
  111374. private _angularSpeedGradientsTexture;
  111375. private _sizeGradientsTexture;
  111376. private _velocityGradientsTexture;
  111377. private _limitVelocityGradientsTexture;
  111378. private _dragGradientsTexture;
  111379. private _addFactorGradient;
  111380. /**
  111381. * Adds a new size gradient
  111382. * @param gradient defines the gradient to use (between 0 and 1)
  111383. * @param factor defines the size factor to affect to the specified gradient
  111384. * @returns the current particle system
  111385. */
  111386. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  111387. /**
  111388. * Remove a specific size gradient
  111389. * @param gradient defines the gradient to remove
  111390. * @returns the current particle system
  111391. */
  111392. removeSizeGradient(gradient: number): GPUParticleSystem;
  111393. /**
  111394. * Adds a new angular speed gradient
  111395. * @param gradient defines the gradient to use (between 0 and 1)
  111396. * @param factor defines the angular speed to affect to the specified gradient
  111397. * @returns the current particle system
  111398. */
  111399. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  111400. /**
  111401. * Remove a specific angular speed gradient
  111402. * @param gradient defines the gradient to remove
  111403. * @returns the current particle system
  111404. */
  111405. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  111406. /**
  111407. * Adds a new velocity gradient
  111408. * @param gradient defines the gradient to use (between 0 and 1)
  111409. * @param factor defines the velocity to affect to the specified gradient
  111410. * @returns the current particle system
  111411. */
  111412. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  111413. /**
  111414. * Remove a specific velocity gradient
  111415. * @param gradient defines the gradient to remove
  111416. * @returns the current particle system
  111417. */
  111418. removeVelocityGradient(gradient: number): GPUParticleSystem;
  111419. /**
  111420. * Adds a new limit velocity gradient
  111421. * @param gradient defines the gradient to use (between 0 and 1)
  111422. * @param factor defines the limit velocity value to affect to the specified gradient
  111423. * @returns the current particle system
  111424. */
  111425. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  111426. /**
  111427. * Remove a specific limit velocity gradient
  111428. * @param gradient defines the gradient to remove
  111429. * @returns the current particle system
  111430. */
  111431. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  111432. /**
  111433. * Adds a new drag gradient
  111434. * @param gradient defines the gradient to use (between 0 and 1)
  111435. * @param factor defines the drag value to affect to the specified gradient
  111436. * @returns the current particle system
  111437. */
  111438. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  111439. /**
  111440. * Remove a specific drag gradient
  111441. * @param gradient defines the gradient to remove
  111442. * @returns the current particle system
  111443. */
  111444. removeDragGradient(gradient: number): GPUParticleSystem;
  111445. /**
  111446. * Not supported by GPUParticleSystem
  111447. * @param gradient defines the gradient to use (between 0 and 1)
  111448. * @param factor defines the emit rate value to affect to the specified gradient
  111449. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  111450. * @returns the current particle system
  111451. */
  111452. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  111453. /**
  111454. * Not supported by GPUParticleSystem
  111455. * @param gradient defines the gradient to remove
  111456. * @returns the current particle system
  111457. */
  111458. removeEmitRateGradient(gradient: number): IParticleSystem;
  111459. /**
  111460. * Not supported by GPUParticleSystem
  111461. * @param gradient defines the gradient to use (between 0 and 1)
  111462. * @param factor defines the start size value to affect to the specified gradient
  111463. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  111464. * @returns the current particle system
  111465. */
  111466. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  111467. /**
  111468. * Not supported by GPUParticleSystem
  111469. * @param gradient defines the gradient to remove
  111470. * @returns the current particle system
  111471. */
  111472. removeStartSizeGradient(gradient: number): IParticleSystem;
  111473. /**
  111474. * Not supported by GPUParticleSystem
  111475. * @param gradient defines the gradient to use (between 0 and 1)
  111476. * @param min defines the color remap minimal range
  111477. * @param max defines the color remap maximal range
  111478. * @returns the current particle system
  111479. */
  111480. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  111481. /**
  111482. * Not supported by GPUParticleSystem
  111483. * @param gradient defines the gradient to remove
  111484. * @returns the current particle system
  111485. */
  111486. removeColorRemapGradient(): IParticleSystem;
  111487. /**
  111488. * Not supported by GPUParticleSystem
  111489. * @param gradient defines the gradient to use (between 0 and 1)
  111490. * @param min defines the alpha remap minimal range
  111491. * @param max defines the alpha remap maximal range
  111492. * @returns the current particle system
  111493. */
  111494. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  111495. /**
  111496. * Not supported by GPUParticleSystem
  111497. * @param gradient defines the gradient to remove
  111498. * @returns the current particle system
  111499. */
  111500. removeAlphaRemapGradient(): IParticleSystem;
  111501. /**
  111502. * Not supported by GPUParticleSystem
  111503. * @param gradient defines the gradient to use (between 0 and 1)
  111504. * @param color defines the color to affect to the specified gradient
  111505. * @returns the current particle system
  111506. */
  111507. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  111508. /**
  111509. * Not supported by GPUParticleSystem
  111510. * @param gradient defines the gradient to remove
  111511. * @returns the current particle system
  111512. */
  111513. removeRampGradient(): IParticleSystem;
  111514. /**
  111515. * Not supported by GPUParticleSystem
  111516. * @returns the list of ramp gradients
  111517. */
  111518. getRampGradients(): Nullable<Array<Color3Gradient>>;
  111519. /**
  111520. * Not supported by GPUParticleSystem
  111521. * Gets or sets a boolean indicating that ramp gradients must be used
  111522. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  111523. */
  111524. useRampGradients: boolean;
  111525. /**
  111526. * Not supported by GPUParticleSystem
  111527. * @param gradient defines the gradient to use (between 0 and 1)
  111528. * @param factor defines the life time factor to affect to the specified gradient
  111529. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  111530. * @returns the current particle system
  111531. */
  111532. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  111533. /**
  111534. * Not supported by GPUParticleSystem
  111535. * @param gradient defines the gradient to remove
  111536. * @returns the current particle system
  111537. */
  111538. removeLifeTimeGradient(gradient: number): IParticleSystem;
  111539. /**
  111540. * Instantiates a GPU particle system.
  111541. * 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.
  111542. * @param name The name of the particle system
  111543. * @param options The options used to create the system
  111544. * @param scene The scene the particle system belongs to
  111545. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  111546. */
  111547. constructor(name: string, options: Partial<{
  111548. capacity: number;
  111549. randomTextureSize: number;
  111550. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  111551. protected _reset(): void;
  111552. private _createUpdateVAO;
  111553. private _createRenderVAO;
  111554. private _initialize;
  111555. /** @hidden */
  111556. _recreateUpdateEffect(): void;
  111557. /** @hidden */
  111558. _recreateRenderEffect(): void;
  111559. /**
  111560. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  111561. * @param preWarm defines if we are in the pre-warmimg phase
  111562. */
  111563. animate(preWarm?: boolean): void;
  111564. private _createFactorGradientTexture;
  111565. private _createSizeGradientTexture;
  111566. private _createAngularSpeedGradientTexture;
  111567. private _createVelocityGradientTexture;
  111568. private _createLimitVelocityGradientTexture;
  111569. private _createDragGradientTexture;
  111570. private _createColorGradientTexture;
  111571. /**
  111572. * Renders the particle system in its current state
  111573. * @param preWarm defines if the system should only update the particles but not render them
  111574. * @returns the current number of particles
  111575. */
  111576. render(preWarm?: boolean): number;
  111577. /**
  111578. * Rebuilds the particle system
  111579. */
  111580. rebuild(): void;
  111581. private _releaseBuffers;
  111582. private _releaseVAOs;
  111583. /**
  111584. * Disposes the particle system and free the associated resources
  111585. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  111586. */
  111587. dispose(disposeTexture?: boolean): void;
  111588. /**
  111589. * Clones the particle system.
  111590. * @param name The name of the cloned object
  111591. * @param newEmitter The new emitter to use
  111592. * @returns the cloned particle system
  111593. */
  111594. clone(name: string, newEmitter: any): GPUParticleSystem;
  111595. /**
  111596. * Serializes the particle system to a JSON object.
  111597. * @returns the JSON object
  111598. */
  111599. serialize(): any;
  111600. /**
  111601. * Parses a JSON object to create a GPU particle system.
  111602. * @param parsedParticleSystem The JSON object to parse
  111603. * @param scene The scene to create the particle system in
  111604. * @param rootUrl The root url to use to load external dependencies like texture
  111605. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  111606. * @returns the parsed GPU particle system
  111607. */
  111608. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  111609. }
  111610. }
  111611. declare module BABYLON {
  111612. /**
  111613. * Represents a set of particle systems working together to create a specific effect
  111614. */
  111615. export class ParticleSystemSet implements IDisposable {
  111616. private _emitterCreationOptions;
  111617. private _emitterNode;
  111618. /**
  111619. * Gets the particle system list
  111620. */
  111621. systems: IParticleSystem[];
  111622. /**
  111623. * Gets the emitter node used with this set
  111624. */
  111625. readonly emitterNode: Nullable<TransformNode>;
  111626. /**
  111627. * Creates a new emitter mesh as a sphere
  111628. * @param options defines the options used to create the sphere
  111629. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  111630. * @param scene defines the hosting scene
  111631. */
  111632. setEmitterAsSphere(options: {
  111633. diameter: number;
  111634. segments: number;
  111635. color: Color3;
  111636. }, renderingGroupId: number, scene: Scene): void;
  111637. /**
  111638. * Starts all particle systems of the set
  111639. * @param emitter defines an optional mesh to use as emitter for the particle systems
  111640. */
  111641. start(emitter?: AbstractMesh): void;
  111642. /**
  111643. * Release all associated resources
  111644. */
  111645. dispose(): void;
  111646. /**
  111647. * Serialize the set into a JSON compatible object
  111648. * @returns a JSON compatible representation of the set
  111649. */
  111650. serialize(): any;
  111651. /**
  111652. * Parse a new ParticleSystemSet from a serialized source
  111653. * @param data defines a JSON compatible representation of the set
  111654. * @param scene defines the hosting scene
  111655. * @param gpu defines if we want GPU particles or CPU particles
  111656. * @returns a new ParticleSystemSet
  111657. */
  111658. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  111659. }
  111660. }
  111661. declare module BABYLON {
  111662. /**
  111663. * This class is made for on one-liner static method to help creating particle system set.
  111664. */
  111665. export class ParticleHelper {
  111666. /**
  111667. * Gets or sets base Assets URL
  111668. */
  111669. static BaseAssetsUrl: string;
  111670. /**
  111671. * Create a default particle system that you can tweak
  111672. * @param emitter defines the emitter to use
  111673. * @param capacity defines the system capacity (default is 500 particles)
  111674. * @param scene defines the hosting scene
  111675. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  111676. * @returns the new Particle system
  111677. */
  111678. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  111679. /**
  111680. * This is the main static method (one-liner) of this helper to create different particle systems
  111681. * @param type This string represents the type to the particle system to create
  111682. * @param scene The scene where the particle system should live
  111683. * @param gpu If the system will use gpu
  111684. * @returns the ParticleSystemSet created
  111685. */
  111686. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  111687. /**
  111688. * Static function used to export a particle system to a ParticleSystemSet variable.
  111689. * Please note that the emitter shape is not exported
  111690. * @param systems defines the particle systems to export
  111691. * @returns the created particle system set
  111692. */
  111693. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  111694. }
  111695. }
  111696. declare module BABYLON {
  111697. interface Engine {
  111698. /**
  111699. * Create an effect to use with particle systems.
  111700. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  111701. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  111702. * @param uniformsNames defines a list of attribute names
  111703. * @param samplers defines an array of string used to represent textures
  111704. * @param defines defines the string containing the defines to use to compile the shaders
  111705. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  111706. * @param onCompiled defines a function to call when the effect creation is successful
  111707. * @param onError defines a function to call when the effect creation has failed
  111708. * @returns the new Effect
  111709. */
  111710. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  111711. }
  111712. interface Mesh {
  111713. /**
  111714. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  111715. * @returns an array of IParticleSystem
  111716. */
  111717. getEmittedParticleSystems(): IParticleSystem[];
  111718. /**
  111719. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  111720. * @returns an array of IParticleSystem
  111721. */
  111722. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  111723. }
  111724. /**
  111725. * @hidden
  111726. */
  111727. export var _IDoNeedToBeInTheBuild: number;
  111728. }
  111729. declare module BABYLON {
  111730. interface Scene {
  111731. /** @hidden (Backing field) */
  111732. _physicsEngine: Nullable<IPhysicsEngine>;
  111733. /**
  111734. * Gets the current physics engine
  111735. * @returns a IPhysicsEngine or null if none attached
  111736. */
  111737. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  111738. /**
  111739. * Enables physics to the current scene
  111740. * @param gravity defines the scene's gravity for the physics engine
  111741. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  111742. * @return a boolean indicating if the physics engine was initialized
  111743. */
  111744. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  111745. /**
  111746. * Disables and disposes the physics engine associated with the scene
  111747. */
  111748. disablePhysicsEngine(): void;
  111749. /**
  111750. * Gets a boolean indicating if there is an active physics engine
  111751. * @returns a boolean indicating if there is an active physics engine
  111752. */
  111753. isPhysicsEnabled(): boolean;
  111754. /**
  111755. * Deletes a physics compound impostor
  111756. * @param compound defines the compound to delete
  111757. */
  111758. deleteCompoundImpostor(compound: any): void;
  111759. /**
  111760. * An event triggered when physic simulation is about to be run
  111761. */
  111762. onBeforePhysicsObservable: Observable<Scene>;
  111763. /**
  111764. * An event triggered when physic simulation has been done
  111765. */
  111766. onAfterPhysicsObservable: Observable<Scene>;
  111767. }
  111768. interface AbstractMesh {
  111769. /** @hidden */
  111770. _physicsImpostor: Nullable<PhysicsImpostor>;
  111771. /**
  111772. * Gets or sets impostor used for physic simulation
  111773. * @see http://doc.babylonjs.com/features/physics_engine
  111774. */
  111775. physicsImpostor: Nullable<PhysicsImpostor>;
  111776. /**
  111777. * Gets the current physics impostor
  111778. * @see http://doc.babylonjs.com/features/physics_engine
  111779. * @returns a physics impostor or null
  111780. */
  111781. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  111782. /** Apply a physic impulse to the mesh
  111783. * @param force defines the force to apply
  111784. * @param contactPoint defines where to apply the force
  111785. * @returns the current mesh
  111786. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  111787. */
  111788. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  111789. /**
  111790. * Creates a physic joint between two meshes
  111791. * @param otherMesh defines the other mesh to use
  111792. * @param pivot1 defines the pivot to use on this mesh
  111793. * @param pivot2 defines the pivot to use on the other mesh
  111794. * @param options defines additional options (can be plugin dependent)
  111795. * @returns the current mesh
  111796. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  111797. */
  111798. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  111799. /** @hidden */
  111800. _disposePhysicsObserver: Nullable<Observer<Node>>;
  111801. }
  111802. /**
  111803. * Defines the physics engine scene component responsible to manage a physics engine
  111804. */
  111805. export class PhysicsEngineSceneComponent implements ISceneComponent {
  111806. /**
  111807. * The component name helpful to identify the component in the list of scene components.
  111808. */
  111809. readonly name: string;
  111810. /**
  111811. * The scene the component belongs to.
  111812. */
  111813. scene: Scene;
  111814. /**
  111815. * Creates a new instance of the component for the given scene
  111816. * @param scene Defines the scene to register the component in
  111817. */
  111818. constructor(scene: Scene);
  111819. /**
  111820. * Registers the component in a given scene
  111821. */
  111822. register(): void;
  111823. /**
  111824. * Rebuilds the elements related to this component in case of
  111825. * context lost for instance.
  111826. */
  111827. rebuild(): void;
  111828. /**
  111829. * Disposes the component and the associated ressources
  111830. */
  111831. dispose(): void;
  111832. }
  111833. }
  111834. declare module BABYLON {
  111835. /**
  111836. * A helper for physics simulations
  111837. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111838. */
  111839. export class PhysicsHelper {
  111840. private _scene;
  111841. private _physicsEngine;
  111842. /**
  111843. * Initializes the Physics helper
  111844. * @param scene Babylon.js scene
  111845. */
  111846. constructor(scene: Scene);
  111847. /**
  111848. * Applies a radial explosion impulse
  111849. * @param origin the origin of the explosion
  111850. * @param radiusOrEventOptions the radius or the options of radial explosion
  111851. * @param strength the explosion strength
  111852. * @param falloff possible options: Constant & Linear. Defaults to Constant
  111853. * @returns A physics radial explosion event, or null
  111854. */
  111855. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  111856. /**
  111857. * Applies a radial explosion force
  111858. * @param origin the origin of the explosion
  111859. * @param radiusOrEventOptions the radius or the options of radial explosion
  111860. * @param strength the explosion strength
  111861. * @param falloff possible options: Constant & Linear. Defaults to Constant
  111862. * @returns A physics radial explosion event, or null
  111863. */
  111864. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  111865. /**
  111866. * Creates a gravitational field
  111867. * @param origin the origin of the explosion
  111868. * @param radiusOrEventOptions the radius or the options of radial explosion
  111869. * @param strength the explosion strength
  111870. * @param falloff possible options: Constant & Linear. Defaults to Constant
  111871. * @returns A physics gravitational field event, or null
  111872. */
  111873. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  111874. /**
  111875. * Creates a physics updraft event
  111876. * @param origin the origin of the updraft
  111877. * @param radiusOrEventOptions the radius or the options of the updraft
  111878. * @param strength the strength of the updraft
  111879. * @param height the height of the updraft
  111880. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  111881. * @returns A physics updraft event, or null
  111882. */
  111883. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  111884. /**
  111885. * Creates a physics vortex event
  111886. * @param origin the of the vortex
  111887. * @param radiusOrEventOptions the radius or the options of the vortex
  111888. * @param strength the strength of the vortex
  111889. * @param height the height of the vortex
  111890. * @returns a Physics vortex event, or null
  111891. * A physics vortex event or null
  111892. */
  111893. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  111894. }
  111895. /**
  111896. * Represents a physics radial explosion event
  111897. */
  111898. class PhysicsRadialExplosionEvent {
  111899. private _scene;
  111900. private _options;
  111901. private _sphere;
  111902. private _dataFetched;
  111903. /**
  111904. * Initializes a radial explosioin event
  111905. * @param _scene BabylonJS scene
  111906. * @param _options The options for the vortex event
  111907. */
  111908. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  111909. /**
  111910. * Returns the data related to the radial explosion event (sphere).
  111911. * @returns The radial explosion event data
  111912. */
  111913. getData(): PhysicsRadialExplosionEventData;
  111914. /**
  111915. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  111916. * @param impostor A physics imposter
  111917. * @param origin the origin of the explosion
  111918. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  111919. */
  111920. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  111921. /**
  111922. * Triggers affecterd impostors callbacks
  111923. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  111924. */
  111925. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  111926. /**
  111927. * Disposes the sphere.
  111928. * @param force Specifies if the sphere should be disposed by force
  111929. */
  111930. dispose(force?: boolean): void;
  111931. /*** Helpers ***/
  111932. private _prepareSphere;
  111933. private _intersectsWithSphere;
  111934. }
  111935. /**
  111936. * Represents a gravitational field event
  111937. */
  111938. class PhysicsGravitationalFieldEvent {
  111939. private _physicsHelper;
  111940. private _scene;
  111941. private _origin;
  111942. private _options;
  111943. private _tickCallback;
  111944. private _sphere;
  111945. private _dataFetched;
  111946. /**
  111947. * Initializes the physics gravitational field event
  111948. * @param _physicsHelper A physics helper
  111949. * @param _scene BabylonJS scene
  111950. * @param _origin The origin position of the gravitational field event
  111951. * @param _options The options for the vortex event
  111952. */
  111953. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  111954. /**
  111955. * Returns the data related to the gravitational field event (sphere).
  111956. * @returns A gravitational field event
  111957. */
  111958. getData(): PhysicsGravitationalFieldEventData;
  111959. /**
  111960. * Enables the gravitational field.
  111961. */
  111962. enable(): void;
  111963. /**
  111964. * Disables the gravitational field.
  111965. */
  111966. disable(): void;
  111967. /**
  111968. * Disposes the sphere.
  111969. * @param force The force to dispose from the gravitational field event
  111970. */
  111971. dispose(force?: boolean): void;
  111972. private _tick;
  111973. }
  111974. /**
  111975. * Represents a physics updraft event
  111976. */
  111977. class PhysicsUpdraftEvent {
  111978. private _scene;
  111979. private _origin;
  111980. private _options;
  111981. private _physicsEngine;
  111982. private _originTop;
  111983. private _originDirection;
  111984. private _tickCallback;
  111985. private _cylinder;
  111986. private _cylinderPosition;
  111987. private _dataFetched;
  111988. /**
  111989. * Initializes the physics updraft event
  111990. * @param _scene BabylonJS scene
  111991. * @param _origin The origin position of the updraft
  111992. * @param _options The options for the updraft event
  111993. */
  111994. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  111995. /**
  111996. * Returns the data related to the updraft event (cylinder).
  111997. * @returns A physics updraft event
  111998. */
  111999. getData(): PhysicsUpdraftEventData;
  112000. /**
  112001. * Enables the updraft.
  112002. */
  112003. enable(): void;
  112004. /**
  112005. * Disables the updraft.
  112006. */
  112007. disable(): void;
  112008. /**
  112009. * Disposes the cylinder.
  112010. * @param force Specifies if the updraft should be disposed by force
  112011. */
  112012. dispose(force?: boolean): void;
  112013. private getImpostorHitData;
  112014. private _tick;
  112015. /*** Helpers ***/
  112016. private _prepareCylinder;
  112017. private _intersectsWithCylinder;
  112018. }
  112019. /**
  112020. * Represents a physics vortex event
  112021. */
  112022. class PhysicsVortexEvent {
  112023. private _scene;
  112024. private _origin;
  112025. private _options;
  112026. private _physicsEngine;
  112027. private _originTop;
  112028. private _tickCallback;
  112029. private _cylinder;
  112030. private _cylinderPosition;
  112031. private _dataFetched;
  112032. /**
  112033. * Initializes the physics vortex event
  112034. * @param _scene The BabylonJS scene
  112035. * @param _origin The origin position of the vortex
  112036. * @param _options The options for the vortex event
  112037. */
  112038. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  112039. /**
  112040. * Returns the data related to the vortex event (cylinder).
  112041. * @returns The physics vortex event data
  112042. */
  112043. getData(): PhysicsVortexEventData;
  112044. /**
  112045. * Enables the vortex.
  112046. */
  112047. enable(): void;
  112048. /**
  112049. * Disables the cortex.
  112050. */
  112051. disable(): void;
  112052. /**
  112053. * Disposes the sphere.
  112054. * @param force
  112055. */
  112056. dispose(force?: boolean): void;
  112057. private getImpostorHitData;
  112058. private _tick;
  112059. /*** Helpers ***/
  112060. private _prepareCylinder;
  112061. private _intersectsWithCylinder;
  112062. }
  112063. /**
  112064. * Options fot the radial explosion event
  112065. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112066. */
  112067. export class PhysicsRadialExplosionEventOptions {
  112068. /**
  112069. * The radius of the sphere for the radial explosion.
  112070. */
  112071. radius: number;
  112072. /**
  112073. * The strenth of the explosion.
  112074. */
  112075. strength: number;
  112076. /**
  112077. * The strenght of the force in correspondence to the distance of the affected object
  112078. */
  112079. falloff: PhysicsRadialImpulseFalloff;
  112080. /**
  112081. * Sphere options for the radial explosion.
  112082. */
  112083. sphere: {
  112084. segments: number;
  112085. diameter: number;
  112086. };
  112087. /**
  112088. * Sphere options for the radial explosion.
  112089. */
  112090. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  112091. }
  112092. /**
  112093. * Options fot the updraft event
  112094. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112095. */
  112096. export class PhysicsUpdraftEventOptions {
  112097. /**
  112098. * The radius of the cylinder for the vortex
  112099. */
  112100. radius: number;
  112101. /**
  112102. * The strenth of the updraft.
  112103. */
  112104. strength: number;
  112105. /**
  112106. * The height of the cylinder for the updraft.
  112107. */
  112108. height: number;
  112109. /**
  112110. * The mode for the the updraft.
  112111. */
  112112. updraftMode: PhysicsUpdraftMode;
  112113. }
  112114. /**
  112115. * Options fot the vortex event
  112116. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112117. */
  112118. export class PhysicsVortexEventOptions {
  112119. /**
  112120. * The radius of the cylinder for the vortex
  112121. */
  112122. radius: number;
  112123. /**
  112124. * The strenth of the vortex.
  112125. */
  112126. strength: number;
  112127. /**
  112128. * The height of the cylinder for the vortex.
  112129. */
  112130. height: number;
  112131. /**
  112132. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  112133. */
  112134. centripetalForceThreshold: number;
  112135. /**
  112136. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  112137. */
  112138. centripetalForceMultiplier: number;
  112139. /**
  112140. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  112141. */
  112142. centrifugalForceMultiplier: number;
  112143. /**
  112144. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  112145. */
  112146. updraftForceMultiplier: number;
  112147. }
  112148. /**
  112149. * The strenght of the force in correspondence to the distance of the affected object
  112150. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112151. */
  112152. export enum PhysicsRadialImpulseFalloff {
  112153. /** Defines that impulse is constant in strength across it's whole radius */
  112154. Constant = 0,
  112155. /** Defines that impulse gets weaker if it's further from the origin */
  112156. Linear = 1
  112157. }
  112158. /**
  112159. * The strength of the force in correspondence to the distance of the affected object
  112160. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112161. */
  112162. export enum PhysicsUpdraftMode {
  112163. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  112164. Center = 0,
  112165. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  112166. Perpendicular = 1
  112167. }
  112168. /**
  112169. * Interface for a physics hit data
  112170. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112171. */
  112172. export interface PhysicsHitData {
  112173. /**
  112174. * The force applied at the contact point
  112175. */
  112176. force: Vector3;
  112177. /**
  112178. * The contact point
  112179. */
  112180. contactPoint: Vector3;
  112181. /**
  112182. * The distance from the origin to the contact point
  112183. */
  112184. distanceFromOrigin: number;
  112185. }
  112186. /**
  112187. * Interface for radial explosion event data
  112188. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112189. */
  112190. export interface PhysicsRadialExplosionEventData {
  112191. /**
  112192. * A sphere used for the radial explosion event
  112193. */
  112194. sphere: Mesh;
  112195. }
  112196. /**
  112197. * Interface for gravitational field event data
  112198. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112199. */
  112200. export interface PhysicsGravitationalFieldEventData {
  112201. /**
  112202. * A sphere mesh used for the gravitational field event
  112203. */
  112204. sphere: Mesh;
  112205. }
  112206. /**
  112207. * Interface for updraft event data
  112208. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112209. */
  112210. export interface PhysicsUpdraftEventData {
  112211. /**
  112212. * A cylinder used for the updraft event
  112213. */
  112214. cylinder: Mesh;
  112215. }
  112216. /**
  112217. * Interface for vortex event data
  112218. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112219. */
  112220. export interface PhysicsVortexEventData {
  112221. /**
  112222. * A cylinder used for the vortex event
  112223. */
  112224. cylinder: Mesh;
  112225. }
  112226. /**
  112227. * Interface for an affected physics impostor
  112228. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112229. */
  112230. export interface PhysicsAffectedImpostorWithData {
  112231. /**
  112232. * The impostor affected by the effect
  112233. */
  112234. impostor: PhysicsImpostor;
  112235. /**
  112236. * The data about the hit/horce from the explosion
  112237. */
  112238. hitData: PhysicsHitData;
  112239. }
  112240. }
  112241. declare module BABYLON {
  112242. /** @hidden */
  112243. export var blackAndWhitePixelShader: {
  112244. name: string;
  112245. shader: string;
  112246. };
  112247. }
  112248. declare module BABYLON {
  112249. /**
  112250. * Post process used to render in black and white
  112251. */
  112252. export class BlackAndWhitePostProcess extends PostProcess {
  112253. /**
  112254. * Linear about to convert he result to black and white (default: 1)
  112255. */
  112256. degree: number;
  112257. /**
  112258. * Creates a black and white post process
  112259. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  112260. * @param name The name of the effect.
  112261. * @param options The required width/height ratio to downsize to before computing the render pass.
  112262. * @param camera The camera to apply the render pass to.
  112263. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112264. * @param engine The engine which the post process will be applied. (default: current engine)
  112265. * @param reusable If the post process can be reused on the same frame. (default: false)
  112266. */
  112267. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  112268. }
  112269. }
  112270. declare module BABYLON {
  112271. /**
  112272. * This represents a set of one or more post processes in Babylon.
  112273. * A post process can be used to apply a shader to a texture after it is rendered.
  112274. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  112275. */
  112276. export class PostProcessRenderEffect {
  112277. private _postProcesses;
  112278. private _getPostProcesses;
  112279. private _singleInstance;
  112280. private _cameras;
  112281. private _indicesForCamera;
  112282. /**
  112283. * Name of the effect
  112284. * @hidden
  112285. */
  112286. _name: string;
  112287. /**
  112288. * Instantiates a post process render effect.
  112289. * A post process can be used to apply a shader to a texture after it is rendered.
  112290. * @param engine The engine the effect is tied to
  112291. * @param name The name of the effect
  112292. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  112293. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  112294. */
  112295. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  112296. /**
  112297. * Checks if all the post processes in the effect are supported.
  112298. */
  112299. readonly isSupported: boolean;
  112300. /**
  112301. * Updates the current state of the effect
  112302. * @hidden
  112303. */
  112304. _update(): void;
  112305. /**
  112306. * Attaches the effect on cameras
  112307. * @param cameras The camera to attach to.
  112308. * @hidden
  112309. */
  112310. _attachCameras(cameras: Camera): void;
  112311. /**
  112312. * Attaches the effect on cameras
  112313. * @param cameras The camera to attach to.
  112314. * @hidden
  112315. */
  112316. _attachCameras(cameras: Camera[]): void;
  112317. /**
  112318. * Detaches the effect on cameras
  112319. * @param cameras The camera to detatch from.
  112320. * @hidden
  112321. */
  112322. _detachCameras(cameras: Camera): void;
  112323. /**
  112324. * Detatches the effect on cameras
  112325. * @param cameras The camera to detatch from.
  112326. * @hidden
  112327. */
  112328. _detachCameras(cameras: Camera[]): void;
  112329. /**
  112330. * Enables the effect on given cameras
  112331. * @param cameras The camera to enable.
  112332. * @hidden
  112333. */
  112334. _enable(cameras: Camera): void;
  112335. /**
  112336. * Enables the effect on given cameras
  112337. * @param cameras The camera to enable.
  112338. * @hidden
  112339. */
  112340. _enable(cameras: Nullable<Camera[]>): void;
  112341. /**
  112342. * Disables the effect on the given cameras
  112343. * @param cameras The camera to disable.
  112344. * @hidden
  112345. */
  112346. _disable(cameras: Camera): void;
  112347. /**
  112348. * Disables the effect on the given cameras
  112349. * @param cameras The camera to disable.
  112350. * @hidden
  112351. */
  112352. _disable(cameras: Nullable<Camera[]>): void;
  112353. /**
  112354. * Gets a list of the post processes contained in the effect.
  112355. * @param camera The camera to get the post processes on.
  112356. * @returns The list of the post processes in the effect.
  112357. */
  112358. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  112359. }
  112360. }
  112361. declare module BABYLON {
  112362. /** @hidden */
  112363. export var extractHighlightsPixelShader: {
  112364. name: string;
  112365. shader: string;
  112366. };
  112367. }
  112368. declare module BABYLON {
  112369. /**
  112370. * 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.
  112371. */
  112372. export class ExtractHighlightsPostProcess extends PostProcess {
  112373. /**
  112374. * The luminance threshold, pixels below this value will be set to black.
  112375. */
  112376. threshold: number;
  112377. /** @hidden */
  112378. _exposure: number;
  112379. /**
  112380. * Post process which has the input texture to be used when performing highlight extraction
  112381. * @hidden
  112382. */
  112383. _inputPostProcess: Nullable<PostProcess>;
  112384. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  112385. }
  112386. }
  112387. declare module BABYLON {
  112388. /** @hidden */
  112389. export var bloomMergePixelShader: {
  112390. name: string;
  112391. shader: string;
  112392. };
  112393. }
  112394. declare module BABYLON {
  112395. /**
  112396. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  112397. */
  112398. export class BloomMergePostProcess extends PostProcess {
  112399. /** Weight of the bloom to be added to the original input. */
  112400. weight: number;
  112401. /**
  112402. * Creates a new instance of @see BloomMergePostProcess
  112403. * @param name The name of the effect.
  112404. * @param originalFromInput Post process which's input will be used for the merge.
  112405. * @param blurred Blurred highlights post process which's output will be used.
  112406. * @param weight Weight of the bloom to be added to the original input.
  112407. * @param options The required width/height ratio to downsize to before computing the render pass.
  112408. * @param camera The camera to apply the render pass to.
  112409. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112410. * @param engine The engine which the post process will be applied. (default: current engine)
  112411. * @param reusable If the post process can be reused on the same frame. (default: false)
  112412. * @param textureType Type of textures used when performing the post process. (default: 0)
  112413. * @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)
  112414. */
  112415. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  112416. /** Weight of the bloom to be added to the original input. */
  112417. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  112418. }
  112419. }
  112420. declare module BABYLON {
  112421. /**
  112422. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  112423. */
  112424. export class BloomEffect extends PostProcessRenderEffect {
  112425. private bloomScale;
  112426. /**
  112427. * @hidden Internal
  112428. */
  112429. _effects: Array<PostProcess>;
  112430. /**
  112431. * @hidden Internal
  112432. */
  112433. _downscale: ExtractHighlightsPostProcess;
  112434. private _blurX;
  112435. private _blurY;
  112436. private _merge;
  112437. /**
  112438. * The luminance threshold to find bright areas of the image to bloom.
  112439. */
  112440. threshold: number;
  112441. /**
  112442. * The strength of the bloom.
  112443. */
  112444. weight: number;
  112445. /**
  112446. * Specifies the size of the bloom blur kernel, relative to the final output size
  112447. */
  112448. kernel: number;
  112449. /**
  112450. * Creates a new instance of @see BloomEffect
  112451. * @param scene The scene the effect belongs to.
  112452. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  112453. * @param bloomKernel The size of the kernel to be used when applying the blur.
  112454. * @param bloomWeight The the strength of bloom.
  112455. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  112456. * @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)
  112457. */
  112458. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  112459. /**
  112460. * Disposes each of the internal effects for a given camera.
  112461. * @param camera The camera to dispose the effect on.
  112462. */
  112463. disposeEffects(camera: Camera): void;
  112464. /**
  112465. * @hidden Internal
  112466. */
  112467. _updateEffects(): void;
  112468. /**
  112469. * Internal
  112470. * @returns if all the contained post processes are ready.
  112471. * @hidden
  112472. */
  112473. _isReady(): boolean;
  112474. }
  112475. }
  112476. declare module BABYLON {
  112477. /** @hidden */
  112478. export var chromaticAberrationPixelShader: {
  112479. name: string;
  112480. shader: string;
  112481. };
  112482. }
  112483. declare module BABYLON {
  112484. /**
  112485. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  112486. */
  112487. export class ChromaticAberrationPostProcess extends PostProcess {
  112488. /**
  112489. * The amount of seperation of rgb channels (default: 30)
  112490. */
  112491. aberrationAmount: number;
  112492. /**
  112493. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  112494. */
  112495. radialIntensity: number;
  112496. /**
  112497. * 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))
  112498. */
  112499. direction: Vector2;
  112500. /**
  112501. * 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))
  112502. */
  112503. centerPosition: Vector2;
  112504. /**
  112505. * Creates a new instance ChromaticAberrationPostProcess
  112506. * @param name The name of the effect.
  112507. * @param screenWidth The width of the screen to apply the effect on.
  112508. * @param screenHeight The height of the screen to apply the effect on.
  112509. * @param options The required width/height ratio to downsize to before computing the render pass.
  112510. * @param camera The camera to apply the render pass to.
  112511. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112512. * @param engine The engine which the post process will be applied. (default: current engine)
  112513. * @param reusable If the post process can be reused on the same frame. (default: false)
  112514. * @param textureType Type of textures used when performing the post process. (default: 0)
  112515. * @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)
  112516. */
  112517. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  112518. }
  112519. }
  112520. declare module BABYLON {
  112521. /** @hidden */
  112522. export var circleOfConfusionPixelShader: {
  112523. name: string;
  112524. shader: string;
  112525. };
  112526. }
  112527. declare module BABYLON {
  112528. /**
  112529. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  112530. */
  112531. export class CircleOfConfusionPostProcess extends PostProcess {
  112532. /**
  112533. * 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.
  112534. */
  112535. lensSize: number;
  112536. /**
  112537. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  112538. */
  112539. fStop: number;
  112540. /**
  112541. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  112542. */
  112543. focusDistance: number;
  112544. /**
  112545. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  112546. */
  112547. focalLength: number;
  112548. private _depthTexture;
  112549. /**
  112550. * Creates a new instance CircleOfConfusionPostProcess
  112551. * @param name The name of the effect.
  112552. * @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.
  112553. * @param options The required width/height ratio to downsize to before computing the render pass.
  112554. * @param camera The camera to apply the render pass to.
  112555. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112556. * @param engine The engine which the post process will be applied. (default: current engine)
  112557. * @param reusable If the post process can be reused on the same frame. (default: false)
  112558. * @param textureType Type of textures used when performing the post process. (default: 0)
  112559. * @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)
  112560. */
  112561. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  112562. /**
  112563. * 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.
  112564. */
  112565. depthTexture: RenderTargetTexture;
  112566. }
  112567. }
  112568. declare module BABYLON {
  112569. /** @hidden */
  112570. export var colorCorrectionPixelShader: {
  112571. name: string;
  112572. shader: string;
  112573. };
  112574. }
  112575. declare module BABYLON {
  112576. /**
  112577. *
  112578. * This post-process allows the modification of rendered colors by using
  112579. * a 'look-up table' (LUT). This effect is also called Color Grading.
  112580. *
  112581. * The object needs to be provided an url to a texture containing the color
  112582. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  112583. * Use an image editing software to tweak the LUT to match your needs.
  112584. *
  112585. * For an example of a color LUT, see here:
  112586. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  112587. * For explanations on color grading, see here:
  112588. * @see http://udn.epicgames.com/Three/ColorGrading.html
  112589. *
  112590. */
  112591. export class ColorCorrectionPostProcess extends PostProcess {
  112592. private _colorTableTexture;
  112593. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  112594. }
  112595. }
  112596. declare module BABYLON {
  112597. /** @hidden */
  112598. export var convolutionPixelShader: {
  112599. name: string;
  112600. shader: string;
  112601. };
  112602. }
  112603. declare module BABYLON {
  112604. /**
  112605. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  112606. * input texture to perform effects such as edge detection or sharpening
  112607. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  112608. */
  112609. export class ConvolutionPostProcess extends PostProcess {
  112610. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  112611. kernel: number[];
  112612. /**
  112613. * Creates a new instance ConvolutionPostProcess
  112614. * @param name The name of the effect.
  112615. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  112616. * @param options The required width/height ratio to downsize to before computing the render pass.
  112617. * @param camera The camera to apply the render pass to.
  112618. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112619. * @param engine The engine which the post process will be applied. (default: current engine)
  112620. * @param reusable If the post process can be reused on the same frame. (default: false)
  112621. * @param textureType Type of textures used when performing the post process. (default: 0)
  112622. */
  112623. constructor(name: string,
  112624. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  112625. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  112626. /**
  112627. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  112628. */
  112629. static EdgeDetect0Kernel: number[];
  112630. /**
  112631. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  112632. */
  112633. static EdgeDetect1Kernel: number[];
  112634. /**
  112635. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  112636. */
  112637. static EdgeDetect2Kernel: number[];
  112638. /**
  112639. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  112640. */
  112641. static SharpenKernel: number[];
  112642. /**
  112643. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  112644. */
  112645. static EmbossKernel: number[];
  112646. /**
  112647. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  112648. */
  112649. static GaussianKernel: number[];
  112650. }
  112651. }
  112652. declare module BABYLON {
  112653. /**
  112654. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  112655. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  112656. * based on samples that have a large difference in distance than the center pixel.
  112657. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  112658. */
  112659. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  112660. direction: Vector2;
  112661. /**
  112662. * Creates a new instance CircleOfConfusionPostProcess
  112663. * @param name The name of the effect.
  112664. * @param scene The scene the effect belongs to.
  112665. * @param direction The direction the blur should be applied.
  112666. * @param kernel The size of the kernel used to blur.
  112667. * @param options The required width/height ratio to downsize to before computing the render pass.
  112668. * @param camera The camera to apply the render pass to.
  112669. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  112670. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  112671. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112672. * @param engine The engine which the post process will be applied. (default: current engine)
  112673. * @param reusable If the post process can be reused on the same frame. (default: false)
  112674. * @param textureType Type of textures used when performing the post process. (default: 0)
  112675. * @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)
  112676. */
  112677. 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);
  112678. }
  112679. }
  112680. declare module BABYLON {
  112681. /** @hidden */
  112682. export var depthOfFieldMergePixelShader: {
  112683. name: string;
  112684. shader: string;
  112685. };
  112686. }
  112687. declare module BABYLON {
  112688. /**
  112689. * Options to be set when merging outputs from the default pipeline.
  112690. */
  112691. export class DepthOfFieldMergePostProcessOptions {
  112692. /**
  112693. * The original image to merge on top of
  112694. */
  112695. originalFromInput: PostProcess;
  112696. /**
  112697. * Parameters to perform the merge of the depth of field effect
  112698. */
  112699. depthOfField?: {
  112700. circleOfConfusion: PostProcess;
  112701. blurSteps: Array<PostProcess>;
  112702. };
  112703. /**
  112704. * Parameters to perform the merge of bloom effect
  112705. */
  112706. bloom?: {
  112707. blurred: PostProcess;
  112708. weight: number;
  112709. };
  112710. }
  112711. /**
  112712. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  112713. */
  112714. export class DepthOfFieldMergePostProcess extends PostProcess {
  112715. private blurSteps;
  112716. /**
  112717. * Creates a new instance of DepthOfFieldMergePostProcess
  112718. * @param name The name of the effect.
  112719. * @param originalFromInput Post process which's input will be used for the merge.
  112720. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  112721. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  112722. * @param options The required width/height ratio to downsize to before computing the render pass.
  112723. * @param camera The camera to apply the render pass to.
  112724. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112725. * @param engine The engine which the post process will be applied. (default: current engine)
  112726. * @param reusable If the post process can be reused on the same frame. (default: false)
  112727. * @param textureType Type of textures used when performing the post process. (default: 0)
  112728. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  112729. */
  112730. constructor(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);
  112731. /**
  112732. * Updates the effect with the current post process compile time values and recompiles the shader.
  112733. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  112734. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  112735. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  112736. * @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
  112737. * @param onCompiled Called when the shader has been compiled.
  112738. * @param onError Called if there is an error when compiling a shader.
  112739. */
  112740. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  112741. }
  112742. }
  112743. declare module BABYLON {
  112744. /**
  112745. * Specifies the level of max blur that should be applied when using the depth of field effect
  112746. */
  112747. export enum DepthOfFieldEffectBlurLevel {
  112748. /**
  112749. * Subtle blur
  112750. */
  112751. Low = 0,
  112752. /**
  112753. * Medium blur
  112754. */
  112755. Medium = 1,
  112756. /**
  112757. * Large blur
  112758. */
  112759. High = 2
  112760. }
  112761. /**
  112762. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  112763. */
  112764. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  112765. private _circleOfConfusion;
  112766. /**
  112767. * @hidden Internal, blurs from high to low
  112768. */
  112769. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  112770. private _depthOfFieldBlurY;
  112771. private _dofMerge;
  112772. /**
  112773. * @hidden Internal post processes in depth of field effect
  112774. */
  112775. _effects: Array<PostProcess>;
  112776. /**
  112777. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  112778. */
  112779. focalLength: number;
  112780. /**
  112781. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  112782. */
  112783. fStop: number;
  112784. /**
  112785. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  112786. */
  112787. focusDistance: number;
  112788. /**
  112789. * 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.
  112790. */
  112791. lensSize: number;
  112792. /**
  112793. * Creates a new instance DepthOfFieldEffect
  112794. * @param scene The scene the effect belongs to.
  112795. * @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.
  112796. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  112797. * @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)
  112798. */
  112799. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  112800. /**
  112801. * Get the current class name of the current effet
  112802. * @returns "DepthOfFieldEffect"
  112803. */
  112804. getClassName(): string;
  112805. /**
  112806. * 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.
  112807. */
  112808. depthTexture: RenderTargetTexture;
  112809. /**
  112810. * Disposes each of the internal effects for a given camera.
  112811. * @param camera The camera to dispose the effect on.
  112812. */
  112813. disposeEffects(camera: Camera): void;
  112814. /**
  112815. * @hidden Internal
  112816. */
  112817. _updateEffects(): void;
  112818. /**
  112819. * Internal
  112820. * @returns if all the contained post processes are ready.
  112821. * @hidden
  112822. */
  112823. _isReady(): boolean;
  112824. }
  112825. }
  112826. declare module BABYLON {
  112827. /** @hidden */
  112828. export var displayPassPixelShader: {
  112829. name: string;
  112830. shader: string;
  112831. };
  112832. }
  112833. declare module BABYLON {
  112834. /**
  112835. * DisplayPassPostProcess which produces an output the same as it's input
  112836. */
  112837. export class DisplayPassPostProcess extends PostProcess {
  112838. /**
  112839. * Creates the DisplayPassPostProcess
  112840. * @param name The name of the effect.
  112841. * @param options The required width/height ratio to downsize to before computing the render pass.
  112842. * @param camera The camera to apply the render pass to.
  112843. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112844. * @param engine The engine which the post process will be applied. (default: current engine)
  112845. * @param reusable If the post process can be reused on the same frame. (default: false)
  112846. */
  112847. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  112848. }
  112849. }
  112850. declare module BABYLON {
  112851. /** @hidden */
  112852. export var filterPixelShader: {
  112853. name: string;
  112854. shader: string;
  112855. };
  112856. }
  112857. declare module BABYLON {
  112858. /**
  112859. * Applies a kernel filter to the image
  112860. */
  112861. export class FilterPostProcess extends PostProcess {
  112862. /** The matrix to be applied to the image */
  112863. kernelMatrix: Matrix;
  112864. /**
  112865. *
  112866. * @param name The name of the effect.
  112867. * @param kernelMatrix The matrix to be applied to the image
  112868. * @param options The required width/height ratio to downsize to before computing the render pass.
  112869. * @param camera The camera to apply the render pass to.
  112870. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112871. * @param engine The engine which the post process will be applied. (default: current engine)
  112872. * @param reusable If the post process can be reused on the same frame. (default: false)
  112873. */
  112874. constructor(name: string,
  112875. /** The matrix to be applied to the image */
  112876. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  112877. }
  112878. }
  112879. declare module BABYLON {
  112880. /** @hidden */
  112881. export var fxaaPixelShader: {
  112882. name: string;
  112883. shader: string;
  112884. };
  112885. }
  112886. declare module BABYLON {
  112887. /** @hidden */
  112888. export var fxaaVertexShader: {
  112889. name: string;
  112890. shader: string;
  112891. };
  112892. }
  112893. declare module BABYLON {
  112894. /**
  112895. * Fxaa post process
  112896. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  112897. */
  112898. export class FxaaPostProcess extends PostProcess {
  112899. /** @hidden */
  112900. texelWidth: number;
  112901. /** @hidden */
  112902. texelHeight: number;
  112903. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  112904. private _getDefines;
  112905. }
  112906. }
  112907. declare module BABYLON {
  112908. /** @hidden */
  112909. export var grainPixelShader: {
  112910. name: string;
  112911. shader: string;
  112912. };
  112913. }
  112914. declare module BABYLON {
  112915. /**
  112916. * The GrainPostProcess adds noise to the image at mid luminance levels
  112917. */
  112918. export class GrainPostProcess extends PostProcess {
  112919. /**
  112920. * The intensity of the grain added (default: 30)
  112921. */
  112922. intensity: number;
  112923. /**
  112924. * If the grain should be randomized on every frame
  112925. */
  112926. animated: boolean;
  112927. /**
  112928. * Creates a new instance of @see GrainPostProcess
  112929. * @param name The name of the effect.
  112930. * @param options The required width/height ratio to downsize to before computing the render pass.
  112931. * @param camera The camera to apply the render pass to.
  112932. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112933. * @param engine The engine which the post process will be applied. (default: current engine)
  112934. * @param reusable If the post process can be reused on the same frame. (default: false)
  112935. * @param textureType Type of textures used when performing the post process. (default: 0)
  112936. * @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)
  112937. */
  112938. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  112939. }
  112940. }
  112941. declare module BABYLON {
  112942. /** @hidden */
  112943. export var highlightsPixelShader: {
  112944. name: string;
  112945. shader: string;
  112946. };
  112947. }
  112948. declare module BABYLON {
  112949. /**
  112950. * Extracts highlights from the image
  112951. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  112952. */
  112953. export class HighlightsPostProcess extends PostProcess {
  112954. /**
  112955. * Extracts highlights from the image
  112956. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  112957. * @param name The name of the effect.
  112958. * @param options The required width/height ratio to downsize to before computing the render pass.
  112959. * @param camera The camera to apply the render pass to.
  112960. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112961. * @param engine The engine which the post process will be applied. (default: current engine)
  112962. * @param reusable If the post process can be reused on the same frame. (default: false)
  112963. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  112964. */
  112965. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  112966. }
  112967. }
  112968. declare module BABYLON {
  112969. /** @hidden */
  112970. export var mrtFragmentDeclaration: {
  112971. name: string;
  112972. shader: string;
  112973. };
  112974. }
  112975. declare module BABYLON {
  112976. /** @hidden */
  112977. export var geometryPixelShader: {
  112978. name: string;
  112979. shader: string;
  112980. };
  112981. }
  112982. declare module BABYLON {
  112983. /** @hidden */
  112984. export var geometryVertexShader: {
  112985. name: string;
  112986. shader: string;
  112987. };
  112988. }
  112989. declare module BABYLON {
  112990. /** @hidden */
  112991. interface ISavedTransformationMatrix {
  112992. world: Matrix;
  112993. viewProjection: Matrix;
  112994. }
  112995. /**
  112996. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  112997. */
  112998. export class GeometryBufferRenderer {
  112999. /**
  113000. * Constant used to retrieve the position texture index in the G-Buffer textures array
  113001. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  113002. */
  113003. static readonly POSITION_TEXTURE_TYPE: number;
  113004. /**
  113005. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  113006. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  113007. */
  113008. static readonly VELOCITY_TEXTURE_TYPE: number;
  113009. /**
  113010. * Dictionary used to store the previous transformation matrices of each rendered mesh
  113011. * in order to compute objects velocities when enableVelocity is set to "true"
  113012. * @hidden
  113013. */
  113014. _previousTransformationMatrices: {
  113015. [index: number]: ISavedTransformationMatrix;
  113016. };
  113017. /**
  113018. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  113019. * in order to compute objects velocities when enableVelocity is set to "true"
  113020. * @hidden
  113021. */
  113022. _previousBonesTransformationMatrices: {
  113023. [index: number]: Float32Array;
  113024. };
  113025. /**
  113026. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  113027. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  113028. */
  113029. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  113030. private _scene;
  113031. private _multiRenderTarget;
  113032. private _ratio;
  113033. private _enablePosition;
  113034. private _enableVelocity;
  113035. private _positionIndex;
  113036. private _velocityIndex;
  113037. protected _effect: Effect;
  113038. protected _cachedDefines: string;
  113039. /**
  113040. * Set the render list (meshes to be rendered) used in the G buffer.
  113041. */
  113042. renderList: Mesh[];
  113043. /**
  113044. * Gets wether or not G buffer are supported by the running hardware.
  113045. * This requires draw buffer supports
  113046. */
  113047. readonly isSupported: boolean;
  113048. /**
  113049. * Returns the index of the given texture type in the G-Buffer textures array
  113050. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  113051. * @returns the index of the given texture type in the G-Buffer textures array
  113052. */
  113053. getTextureIndex(textureType: number): number;
  113054. /**
  113055. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  113056. */
  113057. /**
  113058. * Sets whether or not objects positions are enabled for the G buffer.
  113059. */
  113060. enablePosition: boolean;
  113061. /**
  113062. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  113063. */
  113064. /**
  113065. * Sets wether or not objects velocities are enabled for the G buffer.
  113066. */
  113067. enableVelocity: boolean;
  113068. /**
  113069. * Gets the scene associated with the buffer.
  113070. */
  113071. readonly scene: Scene;
  113072. /**
  113073. * Gets the ratio used by the buffer during its creation.
  113074. * How big is the buffer related to the main canvas.
  113075. */
  113076. readonly ratio: number;
  113077. /** @hidden */
  113078. static _SceneComponentInitialization: (scene: Scene) => void;
  113079. /**
  113080. * Creates a new G Buffer for the scene
  113081. * @param scene The scene the buffer belongs to
  113082. * @param ratio How big is the buffer related to the main canvas.
  113083. */
  113084. constructor(scene: Scene, ratio?: number);
  113085. /**
  113086. * Checks wether everything is ready to render a submesh to the G buffer.
  113087. * @param subMesh the submesh to check readiness for
  113088. * @param useInstances is the mesh drawn using instance or not
  113089. * @returns true if ready otherwise false
  113090. */
  113091. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  113092. /**
  113093. * Gets the current underlying G Buffer.
  113094. * @returns the buffer
  113095. */
  113096. getGBuffer(): MultiRenderTarget;
  113097. /**
  113098. * Gets the number of samples used to render the buffer (anti aliasing).
  113099. */
  113100. /**
  113101. * Sets the number of samples used to render the buffer (anti aliasing).
  113102. */
  113103. samples: number;
  113104. /**
  113105. * Disposes the renderer and frees up associated resources.
  113106. */
  113107. dispose(): void;
  113108. protected _createRenderTargets(): void;
  113109. private _copyBonesTransformationMatrices;
  113110. }
  113111. }
  113112. declare module BABYLON {
  113113. interface Scene {
  113114. /** @hidden (Backing field) */
  113115. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  113116. /**
  113117. * Gets or Sets the current geometry buffer associated to the scene.
  113118. */
  113119. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  113120. /**
  113121. * Enables a GeometryBufferRender and associates it with the scene
  113122. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  113123. * @returns the GeometryBufferRenderer
  113124. */
  113125. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  113126. /**
  113127. * Disables the GeometryBufferRender associated with the scene
  113128. */
  113129. disableGeometryBufferRenderer(): void;
  113130. }
  113131. /**
  113132. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  113133. * in several rendering techniques.
  113134. */
  113135. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  113136. /**
  113137. * The component name helpful to identify the component in the list of scene components.
  113138. */
  113139. readonly name: string;
  113140. /**
  113141. * The scene the component belongs to.
  113142. */
  113143. scene: Scene;
  113144. /**
  113145. * Creates a new instance of the component for the given scene
  113146. * @param scene Defines the scene to register the component in
  113147. */
  113148. constructor(scene: Scene);
  113149. /**
  113150. * Registers the component in a given scene
  113151. */
  113152. register(): void;
  113153. /**
  113154. * Rebuilds the elements related to this component in case of
  113155. * context lost for instance.
  113156. */
  113157. rebuild(): void;
  113158. /**
  113159. * Disposes the component and the associated ressources
  113160. */
  113161. dispose(): void;
  113162. private _gatherRenderTargets;
  113163. }
  113164. }
  113165. declare module BABYLON {
  113166. /** @hidden */
  113167. export var motionBlurPixelShader: {
  113168. name: string;
  113169. shader: string;
  113170. };
  113171. }
  113172. declare module BABYLON {
  113173. /**
  113174. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  113175. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  113176. * As an example, all you have to do is to create the post-process:
  113177. * var mb = new BABYLON.MotionBlurPostProcess(
  113178. * 'mb', // The name of the effect.
  113179. * scene, // The scene containing the objects to blur according to their velocity.
  113180. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  113181. * camera // The camera to apply the render pass to.
  113182. * );
  113183. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  113184. */
  113185. export class MotionBlurPostProcess extends PostProcess {
  113186. /**
  113187. * Defines how much the image is blurred by the movement. Default value is equal to 1
  113188. */
  113189. motionStrength: number;
  113190. /**
  113191. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  113192. */
  113193. /**
  113194. * Sets the number of iterations to be used for motion blur quality
  113195. */
  113196. motionBlurSamples: number;
  113197. private _motionBlurSamples;
  113198. private _geometryBufferRenderer;
  113199. /**
  113200. * Creates a new instance MotionBlurPostProcess
  113201. * @param name The name of the effect.
  113202. * @param scene The scene containing the objects to blur according to their velocity.
  113203. * @param options The required width/height ratio to downsize to before computing the render pass.
  113204. * @param camera The camera to apply the render pass to.
  113205. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  113206. * @param engine The engine which the post process will be applied. (default: current engine)
  113207. * @param reusable If the post process can be reused on the same frame. (default: false)
  113208. * @param textureType Type of textures used when performing the post process. (default: 0)
  113209. * @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)
  113210. */
  113211. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  113212. /**
  113213. * Excludes the given skinned mesh from computing bones velocities.
  113214. * Computing bones velocities can have a cost and that cost. The cost can be saved by calling this function and by passing the skinned mesh reference to ignore.
  113215. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  113216. */
  113217. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  113218. /**
  113219. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  113220. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  113221. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  113222. */
  113223. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  113224. /**
  113225. * Disposes the post process.
  113226. * @param camera The camera to dispose the post process on.
  113227. */
  113228. dispose(camera?: Camera): void;
  113229. }
  113230. }
  113231. declare module BABYLON {
  113232. /** @hidden */
  113233. export var refractionPixelShader: {
  113234. name: string;
  113235. shader: string;
  113236. };
  113237. }
  113238. declare module BABYLON {
  113239. /**
  113240. * Post process which applies a refractin texture
  113241. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  113242. */
  113243. export class RefractionPostProcess extends PostProcess {
  113244. /** the base color of the refraction (used to taint the rendering) */
  113245. color: Color3;
  113246. /** simulated refraction depth */
  113247. depth: number;
  113248. /** the coefficient of the base color (0 to remove base color tainting) */
  113249. colorLevel: number;
  113250. private _refTexture;
  113251. private _ownRefractionTexture;
  113252. /**
  113253. * Gets or sets the refraction texture
  113254. * Please note that you are responsible for disposing the texture if you set it manually
  113255. */
  113256. refractionTexture: Texture;
  113257. /**
  113258. * Initializes the RefractionPostProcess
  113259. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  113260. * @param name The name of the effect.
  113261. * @param refractionTextureUrl Url of the refraction texture to use
  113262. * @param color the base color of the refraction (used to taint the rendering)
  113263. * @param depth simulated refraction depth
  113264. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  113265. * @param camera The camera to apply the render pass to.
  113266. * @param options The required width/height ratio to downsize to before computing the render pass.
  113267. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  113268. * @param engine The engine which the post process will be applied. (default: current engine)
  113269. * @param reusable If the post process can be reused on the same frame. (default: false)
  113270. */
  113271. constructor(name: string, refractionTextureUrl: string,
  113272. /** the base color of the refraction (used to taint the rendering) */
  113273. color: Color3,
  113274. /** simulated refraction depth */
  113275. depth: number,
  113276. /** the coefficient of the base color (0 to remove base color tainting) */
  113277. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  113278. /**
  113279. * Disposes of the post process
  113280. * @param camera Camera to dispose post process on
  113281. */
  113282. dispose(camera: Camera): void;
  113283. }
  113284. }
  113285. declare module BABYLON {
  113286. /** @hidden */
  113287. export var sharpenPixelShader: {
  113288. name: string;
  113289. shader: string;
  113290. };
  113291. }
  113292. declare module BABYLON {
  113293. /**
  113294. * The SharpenPostProcess applies a sharpen kernel to every pixel
  113295. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  113296. */
  113297. export class SharpenPostProcess extends PostProcess {
  113298. /**
  113299. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  113300. */
  113301. colorAmount: number;
  113302. /**
  113303. * How much sharpness should be applied (default: 0.3)
  113304. */
  113305. edgeAmount: number;
  113306. /**
  113307. * Creates a new instance ConvolutionPostProcess
  113308. * @param name The name of the effect.
  113309. * @param options The required width/height ratio to downsize to before computing the render pass.
  113310. * @param camera The camera to apply the render pass to.
  113311. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  113312. * @param engine The engine which the post process will be applied. (default: current engine)
  113313. * @param reusable If the post process can be reused on the same frame. (default: false)
  113314. * @param textureType Type of textures used when performing the post process. (default: 0)
  113315. * @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)
  113316. */
  113317. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  113318. }
  113319. }
  113320. declare module BABYLON {
  113321. /**
  113322. * PostProcessRenderPipeline
  113323. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  113324. */
  113325. export class PostProcessRenderPipeline {
  113326. private engine;
  113327. private _renderEffects;
  113328. private _renderEffectsForIsolatedPass;
  113329. /**
  113330. * List of inspectable custom properties (used by the Inspector)
  113331. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  113332. */
  113333. inspectableCustomProperties: IInspectable[];
  113334. /**
  113335. * @hidden
  113336. */
  113337. protected _cameras: Camera[];
  113338. /** @hidden */
  113339. _name: string;
  113340. /**
  113341. * Gets pipeline name
  113342. */
  113343. readonly name: string;
  113344. /**
  113345. * Initializes a PostProcessRenderPipeline
  113346. * @param engine engine to add the pipeline to
  113347. * @param name name of the pipeline
  113348. */
  113349. constructor(engine: Engine, name: string);
  113350. /**
  113351. * Gets the class name
  113352. * @returns "PostProcessRenderPipeline"
  113353. */
  113354. getClassName(): string;
  113355. /**
  113356. * If all the render effects in the pipeline are supported
  113357. */
  113358. readonly isSupported: boolean;
  113359. /**
  113360. * Adds an effect to the pipeline
  113361. * @param renderEffect the effect to add
  113362. */
  113363. addEffect(renderEffect: PostProcessRenderEffect): void;
  113364. /** @hidden */
  113365. _rebuild(): void;
  113366. /** @hidden */
  113367. _enableEffect(renderEffectName: string, cameras: Camera): void;
  113368. /** @hidden */
  113369. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  113370. /** @hidden */
  113371. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  113372. /** @hidden */
  113373. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  113374. /** @hidden */
  113375. _attachCameras(cameras: Camera, unique: boolean): void;
  113376. /** @hidden */
  113377. _attachCameras(cameras: Camera[], unique: boolean): void;
  113378. /** @hidden */
  113379. _detachCameras(cameras: Camera): void;
  113380. /** @hidden */
  113381. _detachCameras(cameras: Nullable<Camera[]>): void;
  113382. /** @hidden */
  113383. _update(): void;
  113384. /** @hidden */
  113385. _reset(): void;
  113386. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  113387. /**
  113388. * Disposes of the pipeline
  113389. */
  113390. dispose(): void;
  113391. }
  113392. }
  113393. declare module BABYLON {
  113394. /**
  113395. * PostProcessRenderPipelineManager class
  113396. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  113397. */
  113398. export class PostProcessRenderPipelineManager {
  113399. private _renderPipelines;
  113400. /**
  113401. * Initializes a PostProcessRenderPipelineManager
  113402. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  113403. */
  113404. constructor();
  113405. /**
  113406. * Gets the list of supported render pipelines
  113407. */
  113408. readonly supportedPipelines: PostProcessRenderPipeline[];
  113409. /**
  113410. * Adds a pipeline to the manager
  113411. * @param renderPipeline The pipeline to add
  113412. */
  113413. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  113414. /**
  113415. * Attaches a camera to the pipeline
  113416. * @param renderPipelineName The name of the pipeline to attach to
  113417. * @param cameras the camera to attach
  113418. * @param unique if the camera can be attached multiple times to the pipeline
  113419. */
  113420. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  113421. /**
  113422. * Detaches a camera from the pipeline
  113423. * @param renderPipelineName The name of the pipeline to detach from
  113424. * @param cameras the camera to detach
  113425. */
  113426. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  113427. /**
  113428. * Enables an effect by name on a pipeline
  113429. * @param renderPipelineName the name of the pipeline to enable the effect in
  113430. * @param renderEffectName the name of the effect to enable
  113431. * @param cameras the cameras that the effect should be enabled on
  113432. */
  113433. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  113434. /**
  113435. * Disables an effect by name on a pipeline
  113436. * @param renderPipelineName the name of the pipeline to disable the effect in
  113437. * @param renderEffectName the name of the effect to disable
  113438. * @param cameras the cameras that the effect should be disabled on
  113439. */
  113440. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  113441. /**
  113442. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  113443. */
  113444. update(): void;
  113445. /** @hidden */
  113446. _rebuild(): void;
  113447. /**
  113448. * Disposes of the manager and pipelines
  113449. */
  113450. dispose(): void;
  113451. }
  113452. }
  113453. declare module BABYLON {
  113454. interface Scene {
  113455. /** @hidden (Backing field) */
  113456. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  113457. /**
  113458. * Gets the postprocess render pipeline manager
  113459. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  113460. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  113461. */
  113462. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  113463. }
  113464. /**
  113465. * Defines the Render Pipeline scene component responsible to rendering pipelines
  113466. */
  113467. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  113468. /**
  113469. * The component name helpfull to identify the component in the list of scene components.
  113470. */
  113471. readonly name: string;
  113472. /**
  113473. * The scene the component belongs to.
  113474. */
  113475. scene: Scene;
  113476. /**
  113477. * Creates a new instance of the component for the given scene
  113478. * @param scene Defines the scene to register the component in
  113479. */
  113480. constructor(scene: Scene);
  113481. /**
  113482. * Registers the component in a given scene
  113483. */
  113484. register(): void;
  113485. /**
  113486. * Rebuilds the elements related to this component in case of
  113487. * context lost for instance.
  113488. */
  113489. rebuild(): void;
  113490. /**
  113491. * Disposes the component and the associated ressources
  113492. */
  113493. dispose(): void;
  113494. private _gatherRenderTargets;
  113495. }
  113496. }
  113497. declare module BABYLON {
  113498. /**
  113499. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  113500. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  113501. */
  113502. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  113503. private _scene;
  113504. private _camerasToBeAttached;
  113505. /**
  113506. * ID of the sharpen post process,
  113507. */
  113508. private readonly SharpenPostProcessId;
  113509. /**
  113510. * @ignore
  113511. * ID of the image processing post process;
  113512. */
  113513. readonly ImageProcessingPostProcessId: string;
  113514. /**
  113515. * @ignore
  113516. * ID of the Fast Approximate Anti-Aliasing post process;
  113517. */
  113518. readonly FxaaPostProcessId: string;
  113519. /**
  113520. * ID of the chromatic aberration post process,
  113521. */
  113522. private readonly ChromaticAberrationPostProcessId;
  113523. /**
  113524. * ID of the grain post process
  113525. */
  113526. private readonly GrainPostProcessId;
  113527. /**
  113528. * Sharpen post process which will apply a sharpen convolution to enhance edges
  113529. */
  113530. sharpen: SharpenPostProcess;
  113531. private _sharpenEffect;
  113532. private bloom;
  113533. /**
  113534. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  113535. */
  113536. depthOfField: DepthOfFieldEffect;
  113537. /**
  113538. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  113539. */
  113540. fxaa: FxaaPostProcess;
  113541. /**
  113542. * Image post processing pass used to perform operations such as tone mapping or color grading.
  113543. */
  113544. imageProcessing: ImageProcessingPostProcess;
  113545. /**
  113546. * Chromatic aberration post process which will shift rgb colors in the image
  113547. */
  113548. chromaticAberration: ChromaticAberrationPostProcess;
  113549. private _chromaticAberrationEffect;
  113550. /**
  113551. * Grain post process which add noise to the image
  113552. */
  113553. grain: GrainPostProcess;
  113554. private _grainEffect;
  113555. /**
  113556. * Glow post process which adds a glow to emissive areas of the image
  113557. */
  113558. private _glowLayer;
  113559. /**
  113560. * Animations which can be used to tweak settings over a period of time
  113561. */
  113562. animations: Animation[];
  113563. private _imageProcessingConfigurationObserver;
  113564. private _sharpenEnabled;
  113565. private _bloomEnabled;
  113566. private _depthOfFieldEnabled;
  113567. private _depthOfFieldBlurLevel;
  113568. private _fxaaEnabled;
  113569. private _imageProcessingEnabled;
  113570. private _defaultPipelineTextureType;
  113571. private _bloomScale;
  113572. private _chromaticAberrationEnabled;
  113573. private _grainEnabled;
  113574. private _buildAllowed;
  113575. /**
  113576. * Gets active scene
  113577. */
  113578. readonly scene: Scene;
  113579. /**
  113580. * Enable or disable the sharpen process from the pipeline
  113581. */
  113582. sharpenEnabled: boolean;
  113583. private _resizeObserver;
  113584. private _hardwareScaleLevel;
  113585. private _bloomKernel;
  113586. /**
  113587. * Specifies the size of the bloom blur kernel, relative to the final output size
  113588. */
  113589. bloomKernel: number;
  113590. /**
  113591. * Specifies the weight of the bloom in the final rendering
  113592. */
  113593. private _bloomWeight;
  113594. /**
  113595. * Specifies the luma threshold for the area that will be blurred by the bloom
  113596. */
  113597. private _bloomThreshold;
  113598. private _hdr;
  113599. /**
  113600. * The strength of the bloom.
  113601. */
  113602. bloomWeight: number;
  113603. /**
  113604. * The strength of the bloom.
  113605. */
  113606. bloomThreshold: number;
  113607. /**
  113608. * The scale of the bloom, lower value will provide better performance.
  113609. */
  113610. bloomScale: number;
  113611. /**
  113612. * Enable or disable the bloom from the pipeline
  113613. */
  113614. bloomEnabled: boolean;
  113615. private _rebuildBloom;
  113616. /**
  113617. * If the depth of field is enabled.
  113618. */
  113619. depthOfFieldEnabled: boolean;
  113620. /**
  113621. * Blur level of the depth of field effect. (Higher blur will effect performance)
  113622. */
  113623. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  113624. /**
  113625. * If the anti aliasing is enabled.
  113626. */
  113627. fxaaEnabled: boolean;
  113628. private _samples;
  113629. /**
  113630. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  113631. */
  113632. samples: number;
  113633. /**
  113634. * If image processing is enabled.
  113635. */
  113636. imageProcessingEnabled: boolean;
  113637. /**
  113638. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  113639. */
  113640. glowLayerEnabled: boolean;
  113641. /**
  113642. * Gets the glow layer (or null if not defined)
  113643. */
  113644. readonly glowLayer: Nullable<GlowLayer>;
  113645. /**
  113646. * Enable or disable the chromaticAberration process from the pipeline
  113647. */
  113648. chromaticAberrationEnabled: boolean;
  113649. /**
  113650. * Enable or disable the grain process from the pipeline
  113651. */
  113652. grainEnabled: boolean;
  113653. /**
  113654. * @constructor
  113655. * @param name - The rendering pipeline name (default: "")
  113656. * @param hdr - If high dynamic range textures should be used (default: true)
  113657. * @param scene - The scene linked to this pipeline (default: the last created scene)
  113658. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  113659. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  113660. */
  113661. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  113662. /**
  113663. * Get the class name
  113664. * @returns "DefaultRenderingPipeline"
  113665. */
  113666. getClassName(): string;
  113667. /**
  113668. * Force the compilation of the entire pipeline.
  113669. */
  113670. prepare(): void;
  113671. private _hasCleared;
  113672. private _prevPostProcess;
  113673. private _prevPrevPostProcess;
  113674. private _setAutoClearAndTextureSharing;
  113675. private _depthOfFieldSceneObserver;
  113676. private _buildPipeline;
  113677. private _disposePostProcesses;
  113678. /**
  113679. * Adds a camera to the pipeline
  113680. * @param camera the camera to be added
  113681. */
  113682. addCamera(camera: Camera): void;
  113683. /**
  113684. * Removes a camera from the pipeline
  113685. * @param camera the camera to remove
  113686. */
  113687. removeCamera(camera: Camera): void;
  113688. /**
  113689. * Dispose of the pipeline and stop all post processes
  113690. */
  113691. dispose(): void;
  113692. /**
  113693. * Serialize the rendering pipeline (Used when exporting)
  113694. * @returns the serialized object
  113695. */
  113696. serialize(): any;
  113697. /**
  113698. * Parse the serialized pipeline
  113699. * @param source Source pipeline.
  113700. * @param scene The scene to load the pipeline to.
  113701. * @param rootUrl The URL of the serialized pipeline.
  113702. * @returns An instantiated pipeline from the serialized object.
  113703. */
  113704. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  113705. }
  113706. }
  113707. declare module BABYLON {
  113708. /** @hidden */
  113709. export var lensHighlightsPixelShader: {
  113710. name: string;
  113711. shader: string;
  113712. };
  113713. }
  113714. declare module BABYLON {
  113715. /** @hidden */
  113716. export var depthOfFieldPixelShader: {
  113717. name: string;
  113718. shader: string;
  113719. };
  113720. }
  113721. declare module BABYLON {
  113722. /**
  113723. * BABYLON.JS Chromatic Aberration GLSL Shader
  113724. * Author: Olivier Guyot
  113725. * Separates very slightly R, G and B colors on the edges of the screen
  113726. * Inspired by Francois Tarlier & Martins Upitis
  113727. */
  113728. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  113729. /**
  113730. * @ignore
  113731. * The chromatic aberration PostProcess id in the pipeline
  113732. */
  113733. LensChromaticAberrationEffect: string;
  113734. /**
  113735. * @ignore
  113736. * The highlights enhancing PostProcess id in the pipeline
  113737. */
  113738. HighlightsEnhancingEffect: string;
  113739. /**
  113740. * @ignore
  113741. * The depth-of-field PostProcess id in the pipeline
  113742. */
  113743. LensDepthOfFieldEffect: string;
  113744. private _scene;
  113745. private _depthTexture;
  113746. private _grainTexture;
  113747. private _chromaticAberrationPostProcess;
  113748. private _highlightsPostProcess;
  113749. private _depthOfFieldPostProcess;
  113750. private _edgeBlur;
  113751. private _grainAmount;
  113752. private _chromaticAberration;
  113753. private _distortion;
  113754. private _highlightsGain;
  113755. private _highlightsThreshold;
  113756. private _dofDistance;
  113757. private _dofAperture;
  113758. private _dofDarken;
  113759. private _dofPentagon;
  113760. private _blurNoise;
  113761. /**
  113762. * @constructor
  113763. *
  113764. * Effect parameters are as follow:
  113765. * {
  113766. * chromatic_aberration: number; // from 0 to x (1 for realism)
  113767. * edge_blur: number; // from 0 to x (1 for realism)
  113768. * distortion: number; // from 0 to x (1 for realism)
  113769. * grain_amount: number; // from 0 to 1
  113770. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  113771. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  113772. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  113773. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  113774. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  113775. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  113776. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  113777. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  113778. * }
  113779. * Note: if an effect parameter is unset, effect is disabled
  113780. *
  113781. * @param name The rendering pipeline name
  113782. * @param parameters - An object containing all parameters (see above)
  113783. * @param scene The scene linked to this pipeline
  113784. * @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)
  113785. * @param cameras The array of cameras that the rendering pipeline will be attached to
  113786. */
  113787. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  113788. /**
  113789. * Get the class name
  113790. * @returns "LensRenderingPipeline"
  113791. */
  113792. getClassName(): string;
  113793. /**
  113794. * Gets associated scene
  113795. */
  113796. readonly scene: Scene;
  113797. /**
  113798. * Gets or sets the edge blur
  113799. */
  113800. edgeBlur: number;
  113801. /**
  113802. * Gets or sets the grain amount
  113803. */
  113804. grainAmount: number;
  113805. /**
  113806. * Gets or sets the chromatic aberration amount
  113807. */
  113808. chromaticAberration: number;
  113809. /**
  113810. * Gets or sets the depth of field aperture
  113811. */
  113812. dofAperture: number;
  113813. /**
  113814. * Gets or sets the edge distortion
  113815. */
  113816. edgeDistortion: number;
  113817. /**
  113818. * Gets or sets the depth of field distortion
  113819. */
  113820. dofDistortion: number;
  113821. /**
  113822. * Gets or sets the darken out of focus amount
  113823. */
  113824. darkenOutOfFocus: number;
  113825. /**
  113826. * Gets or sets a boolean indicating if blur noise is enabled
  113827. */
  113828. blurNoise: boolean;
  113829. /**
  113830. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  113831. */
  113832. pentagonBokeh: boolean;
  113833. /**
  113834. * Gets or sets the highlight grain amount
  113835. */
  113836. highlightsGain: number;
  113837. /**
  113838. * Gets or sets the highlight threshold
  113839. */
  113840. highlightsThreshold: number;
  113841. /**
  113842. * Sets the amount of blur at the edges
  113843. * @param amount blur amount
  113844. */
  113845. setEdgeBlur(amount: number): void;
  113846. /**
  113847. * Sets edge blur to 0
  113848. */
  113849. disableEdgeBlur(): void;
  113850. /**
  113851. * Sets the amout of grain
  113852. * @param amount Amount of grain
  113853. */
  113854. setGrainAmount(amount: number): void;
  113855. /**
  113856. * Set grain amount to 0
  113857. */
  113858. disableGrain(): void;
  113859. /**
  113860. * Sets the chromatic aberration amount
  113861. * @param amount amount of chromatic aberration
  113862. */
  113863. setChromaticAberration(amount: number): void;
  113864. /**
  113865. * Sets chromatic aberration amount to 0
  113866. */
  113867. disableChromaticAberration(): void;
  113868. /**
  113869. * Sets the EdgeDistortion amount
  113870. * @param amount amount of EdgeDistortion
  113871. */
  113872. setEdgeDistortion(amount: number): void;
  113873. /**
  113874. * Sets edge distortion to 0
  113875. */
  113876. disableEdgeDistortion(): void;
  113877. /**
  113878. * Sets the FocusDistance amount
  113879. * @param amount amount of FocusDistance
  113880. */
  113881. setFocusDistance(amount: number): void;
  113882. /**
  113883. * Disables depth of field
  113884. */
  113885. disableDepthOfField(): void;
  113886. /**
  113887. * Sets the Aperture amount
  113888. * @param amount amount of Aperture
  113889. */
  113890. setAperture(amount: number): void;
  113891. /**
  113892. * Sets the DarkenOutOfFocus amount
  113893. * @param amount amount of DarkenOutOfFocus
  113894. */
  113895. setDarkenOutOfFocus(amount: number): void;
  113896. private _pentagonBokehIsEnabled;
  113897. /**
  113898. * Creates a pentagon bokeh effect
  113899. */
  113900. enablePentagonBokeh(): void;
  113901. /**
  113902. * Disables the pentagon bokeh effect
  113903. */
  113904. disablePentagonBokeh(): void;
  113905. /**
  113906. * Enables noise blur
  113907. */
  113908. enableNoiseBlur(): void;
  113909. /**
  113910. * Disables noise blur
  113911. */
  113912. disableNoiseBlur(): void;
  113913. /**
  113914. * Sets the HighlightsGain amount
  113915. * @param amount amount of HighlightsGain
  113916. */
  113917. setHighlightsGain(amount: number): void;
  113918. /**
  113919. * Sets the HighlightsThreshold amount
  113920. * @param amount amount of HighlightsThreshold
  113921. */
  113922. setHighlightsThreshold(amount: number): void;
  113923. /**
  113924. * Disables highlights
  113925. */
  113926. disableHighlights(): void;
  113927. /**
  113928. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  113929. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  113930. */
  113931. dispose(disableDepthRender?: boolean): void;
  113932. private _createChromaticAberrationPostProcess;
  113933. private _createHighlightsPostProcess;
  113934. private _createDepthOfFieldPostProcess;
  113935. private _createGrainTexture;
  113936. }
  113937. }
  113938. declare module BABYLON {
  113939. /** @hidden */
  113940. export var ssao2PixelShader: {
  113941. name: string;
  113942. shader: string;
  113943. };
  113944. }
  113945. declare module BABYLON {
  113946. /** @hidden */
  113947. export var ssaoCombinePixelShader: {
  113948. name: string;
  113949. shader: string;
  113950. };
  113951. }
  113952. declare module BABYLON {
  113953. /**
  113954. * Render pipeline to produce ssao effect
  113955. */
  113956. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  113957. /**
  113958. * @ignore
  113959. * The PassPostProcess id in the pipeline that contains the original scene color
  113960. */
  113961. SSAOOriginalSceneColorEffect: string;
  113962. /**
  113963. * @ignore
  113964. * The SSAO PostProcess id in the pipeline
  113965. */
  113966. SSAORenderEffect: string;
  113967. /**
  113968. * @ignore
  113969. * The horizontal blur PostProcess id in the pipeline
  113970. */
  113971. SSAOBlurHRenderEffect: string;
  113972. /**
  113973. * @ignore
  113974. * The vertical blur PostProcess id in the pipeline
  113975. */
  113976. SSAOBlurVRenderEffect: string;
  113977. /**
  113978. * @ignore
  113979. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  113980. */
  113981. SSAOCombineRenderEffect: string;
  113982. /**
  113983. * The output strength of the SSAO post-process. Default value is 1.0.
  113984. */
  113985. totalStrength: number;
  113986. /**
  113987. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  113988. */
  113989. maxZ: number;
  113990. /**
  113991. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  113992. */
  113993. minZAspect: number;
  113994. private _samples;
  113995. /**
  113996. * Number of samples used for the SSAO calculations. Default value is 8
  113997. */
  113998. samples: number;
  113999. private _textureSamples;
  114000. /**
  114001. * Number of samples to use for antialiasing
  114002. */
  114003. textureSamples: number;
  114004. /**
  114005. * Ratio object used for SSAO ratio and blur ratio
  114006. */
  114007. private _ratio;
  114008. /**
  114009. * Dynamically generated sphere sampler.
  114010. */
  114011. private _sampleSphere;
  114012. /**
  114013. * Blur filter offsets
  114014. */
  114015. private _samplerOffsets;
  114016. private _expensiveBlur;
  114017. /**
  114018. * If bilateral blur should be used
  114019. */
  114020. expensiveBlur: boolean;
  114021. /**
  114022. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  114023. */
  114024. radius: number;
  114025. /**
  114026. * The base color of the SSAO post-process
  114027. * The final result is "base + ssao" between [0, 1]
  114028. */
  114029. base: number;
  114030. /**
  114031. * Support test.
  114032. */
  114033. static readonly IsSupported: boolean;
  114034. private _scene;
  114035. private _depthTexture;
  114036. private _normalTexture;
  114037. private _randomTexture;
  114038. private _originalColorPostProcess;
  114039. private _ssaoPostProcess;
  114040. private _blurHPostProcess;
  114041. private _blurVPostProcess;
  114042. private _ssaoCombinePostProcess;
  114043. private _firstUpdate;
  114044. /**
  114045. * Gets active scene
  114046. */
  114047. readonly scene: Scene;
  114048. /**
  114049. * @constructor
  114050. * @param name The rendering pipeline name
  114051. * @param scene The scene linked to this pipeline
  114052. * @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 }
  114053. * @param cameras The array of cameras that the rendering pipeline will be attached to
  114054. */
  114055. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  114056. /**
  114057. * Get the class name
  114058. * @returns "SSAO2RenderingPipeline"
  114059. */
  114060. getClassName(): string;
  114061. /**
  114062. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  114063. */
  114064. dispose(disableGeometryBufferRenderer?: boolean): void;
  114065. private _createBlurPostProcess;
  114066. /** @hidden */
  114067. _rebuild(): void;
  114068. private _bits;
  114069. private _radicalInverse_VdC;
  114070. private _hammersley;
  114071. private _hemisphereSample_uniform;
  114072. private _generateHemisphere;
  114073. private _createSSAOPostProcess;
  114074. private _createSSAOCombinePostProcess;
  114075. private _createRandomTexture;
  114076. /**
  114077. * Serialize the rendering pipeline (Used when exporting)
  114078. * @returns the serialized object
  114079. */
  114080. serialize(): any;
  114081. /**
  114082. * Parse the serialized pipeline
  114083. * @param source Source pipeline.
  114084. * @param scene The scene to load the pipeline to.
  114085. * @param rootUrl The URL of the serialized pipeline.
  114086. * @returns An instantiated pipeline from the serialized object.
  114087. */
  114088. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  114089. }
  114090. }
  114091. declare module BABYLON {
  114092. /** @hidden */
  114093. export var ssaoPixelShader: {
  114094. name: string;
  114095. shader: string;
  114096. };
  114097. }
  114098. declare module BABYLON {
  114099. /**
  114100. * Render pipeline to produce ssao effect
  114101. */
  114102. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  114103. /**
  114104. * @ignore
  114105. * The PassPostProcess id in the pipeline that contains the original scene color
  114106. */
  114107. SSAOOriginalSceneColorEffect: string;
  114108. /**
  114109. * @ignore
  114110. * The SSAO PostProcess id in the pipeline
  114111. */
  114112. SSAORenderEffect: string;
  114113. /**
  114114. * @ignore
  114115. * The horizontal blur PostProcess id in the pipeline
  114116. */
  114117. SSAOBlurHRenderEffect: string;
  114118. /**
  114119. * @ignore
  114120. * The vertical blur PostProcess id in the pipeline
  114121. */
  114122. SSAOBlurVRenderEffect: string;
  114123. /**
  114124. * @ignore
  114125. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  114126. */
  114127. SSAOCombineRenderEffect: string;
  114128. /**
  114129. * The output strength of the SSAO post-process. Default value is 1.0.
  114130. */
  114131. totalStrength: number;
  114132. /**
  114133. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  114134. */
  114135. radius: number;
  114136. /**
  114137. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  114138. * Must not be equal to fallOff and superior to fallOff.
  114139. * Default value is 0.0075
  114140. */
  114141. area: number;
  114142. /**
  114143. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  114144. * Must not be equal to area and inferior to area.
  114145. * Default value is 0.000001
  114146. */
  114147. fallOff: number;
  114148. /**
  114149. * The base color of the SSAO post-process
  114150. * The final result is "base + ssao" between [0, 1]
  114151. */
  114152. base: number;
  114153. private _scene;
  114154. private _depthTexture;
  114155. private _randomTexture;
  114156. private _originalColorPostProcess;
  114157. private _ssaoPostProcess;
  114158. private _blurHPostProcess;
  114159. private _blurVPostProcess;
  114160. private _ssaoCombinePostProcess;
  114161. private _firstUpdate;
  114162. /**
  114163. * Gets active scene
  114164. */
  114165. readonly scene: Scene;
  114166. /**
  114167. * @constructor
  114168. * @param name - The rendering pipeline name
  114169. * @param scene - The scene linked to this pipeline
  114170. * @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 }
  114171. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  114172. */
  114173. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  114174. /**
  114175. * Get the class name
  114176. * @returns "SSAORenderingPipeline"
  114177. */
  114178. getClassName(): string;
  114179. /**
  114180. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  114181. */
  114182. dispose(disableDepthRender?: boolean): void;
  114183. private _createBlurPostProcess;
  114184. /** @hidden */
  114185. _rebuild(): void;
  114186. private _createSSAOPostProcess;
  114187. private _createSSAOCombinePostProcess;
  114188. private _createRandomTexture;
  114189. }
  114190. }
  114191. declare module BABYLON {
  114192. /** @hidden */
  114193. export var standardPixelShader: {
  114194. name: string;
  114195. shader: string;
  114196. };
  114197. }
  114198. declare module BABYLON {
  114199. /**
  114200. * Standard rendering pipeline
  114201. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  114202. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  114203. */
  114204. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  114205. /**
  114206. * Public members
  114207. */
  114208. /**
  114209. * Post-process which contains the original scene color before the pipeline applies all the effects
  114210. */
  114211. originalPostProcess: Nullable<PostProcess>;
  114212. /**
  114213. * Post-process used to down scale an image x4
  114214. */
  114215. downSampleX4PostProcess: Nullable<PostProcess>;
  114216. /**
  114217. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  114218. */
  114219. brightPassPostProcess: Nullable<PostProcess>;
  114220. /**
  114221. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  114222. */
  114223. blurHPostProcesses: PostProcess[];
  114224. /**
  114225. * Post-process array storing all the vertical blur post-processes used by the pipeline
  114226. */
  114227. blurVPostProcesses: PostProcess[];
  114228. /**
  114229. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  114230. */
  114231. textureAdderPostProcess: Nullable<PostProcess>;
  114232. /**
  114233. * Post-process used to create volumetric lighting effect
  114234. */
  114235. volumetricLightPostProcess: Nullable<PostProcess>;
  114236. /**
  114237. * Post-process used to smooth the previous volumetric light post-process on the X axis
  114238. */
  114239. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  114240. /**
  114241. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  114242. */
  114243. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  114244. /**
  114245. * Post-process used to merge the volumetric light effect and the real scene color
  114246. */
  114247. volumetricLightMergePostProces: Nullable<PostProcess>;
  114248. /**
  114249. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  114250. */
  114251. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  114252. /**
  114253. * Base post-process used to calculate the average luminance of the final image for HDR
  114254. */
  114255. luminancePostProcess: Nullable<PostProcess>;
  114256. /**
  114257. * Post-processes used to create down sample post-processes in order to get
  114258. * the average luminance of the final image for HDR
  114259. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  114260. */
  114261. luminanceDownSamplePostProcesses: PostProcess[];
  114262. /**
  114263. * Post-process used to create a HDR effect (light adaptation)
  114264. */
  114265. hdrPostProcess: Nullable<PostProcess>;
  114266. /**
  114267. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  114268. */
  114269. textureAdderFinalPostProcess: Nullable<PostProcess>;
  114270. /**
  114271. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  114272. */
  114273. lensFlareFinalPostProcess: Nullable<PostProcess>;
  114274. /**
  114275. * Post-process used to merge the final HDR post-process and the real scene color
  114276. */
  114277. hdrFinalPostProcess: Nullable<PostProcess>;
  114278. /**
  114279. * Post-process used to create a lens flare effect
  114280. */
  114281. lensFlarePostProcess: Nullable<PostProcess>;
  114282. /**
  114283. * Post-process that merges the result of the lens flare post-process and the real scene color
  114284. */
  114285. lensFlareComposePostProcess: Nullable<PostProcess>;
  114286. /**
  114287. * Post-process used to create a motion blur effect
  114288. */
  114289. motionBlurPostProcess: Nullable<PostProcess>;
  114290. /**
  114291. * Post-process used to create a depth of field effect
  114292. */
  114293. depthOfFieldPostProcess: Nullable<PostProcess>;
  114294. /**
  114295. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  114296. */
  114297. fxaaPostProcess: Nullable<FxaaPostProcess>;
  114298. /**
  114299. * Represents the brightness threshold in order to configure the illuminated surfaces
  114300. */
  114301. brightThreshold: number;
  114302. /**
  114303. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  114304. */
  114305. blurWidth: number;
  114306. /**
  114307. * Sets if the blur for highlighted surfaces must be only horizontal
  114308. */
  114309. horizontalBlur: boolean;
  114310. /**
  114311. * Gets the overall exposure used by the pipeline
  114312. */
  114313. /**
  114314. * Sets the overall exposure used by the pipeline
  114315. */
  114316. exposure: number;
  114317. /**
  114318. * Texture used typically to simulate "dirty" on camera lens
  114319. */
  114320. lensTexture: Nullable<Texture>;
  114321. /**
  114322. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  114323. */
  114324. volumetricLightCoefficient: number;
  114325. /**
  114326. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  114327. */
  114328. volumetricLightPower: number;
  114329. /**
  114330. * Used the set the blur intensity to smooth the volumetric lights
  114331. */
  114332. volumetricLightBlurScale: number;
  114333. /**
  114334. * Light (spot or directional) used to generate the volumetric lights rays
  114335. * The source light must have a shadow generate so the pipeline can get its
  114336. * depth map
  114337. */
  114338. sourceLight: Nullable<SpotLight | DirectionalLight>;
  114339. /**
  114340. * For eye adaptation, represents the minimum luminance the eye can see
  114341. */
  114342. hdrMinimumLuminance: number;
  114343. /**
  114344. * For eye adaptation, represents the decrease luminance speed
  114345. */
  114346. hdrDecreaseRate: number;
  114347. /**
  114348. * For eye adaptation, represents the increase luminance speed
  114349. */
  114350. hdrIncreaseRate: number;
  114351. /**
  114352. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  114353. */
  114354. /**
  114355. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  114356. */
  114357. hdrAutoExposure: boolean;
  114358. /**
  114359. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  114360. */
  114361. lensColorTexture: Nullable<Texture>;
  114362. /**
  114363. * The overall strengh for the lens flare effect
  114364. */
  114365. lensFlareStrength: number;
  114366. /**
  114367. * Dispersion coefficient for lens flare ghosts
  114368. */
  114369. lensFlareGhostDispersal: number;
  114370. /**
  114371. * Main lens flare halo width
  114372. */
  114373. lensFlareHaloWidth: number;
  114374. /**
  114375. * Based on the lens distortion effect, defines how much the lens flare result
  114376. * is distorted
  114377. */
  114378. lensFlareDistortionStrength: number;
  114379. /**
  114380. * Lens star texture must be used to simulate rays on the flares and is available
  114381. * in the documentation
  114382. */
  114383. lensStarTexture: Nullable<Texture>;
  114384. /**
  114385. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  114386. * flare effect by taking account of the dirt texture
  114387. */
  114388. lensFlareDirtTexture: Nullable<Texture>;
  114389. /**
  114390. * Represents the focal length for the depth of field effect
  114391. */
  114392. depthOfFieldDistance: number;
  114393. /**
  114394. * Represents the blur intensity for the blurred part of the depth of field effect
  114395. */
  114396. depthOfFieldBlurWidth: number;
  114397. /**
  114398. * For motion blur, defines how much the image is blurred by the movement
  114399. */
  114400. motionStrength: number;
  114401. /**
  114402. * List of animations for the pipeline (IAnimatable implementation)
  114403. */
  114404. animations: Animation[];
  114405. /**
  114406. * Private members
  114407. */
  114408. private _scene;
  114409. private _currentDepthOfFieldSource;
  114410. private _basePostProcess;
  114411. private _fixedExposure;
  114412. private _currentExposure;
  114413. private _hdrAutoExposure;
  114414. private _hdrCurrentLuminance;
  114415. private _floatTextureType;
  114416. private _ratio;
  114417. private _bloomEnabled;
  114418. private _depthOfFieldEnabled;
  114419. private _vlsEnabled;
  114420. private _lensFlareEnabled;
  114421. private _hdrEnabled;
  114422. private _motionBlurEnabled;
  114423. private _fxaaEnabled;
  114424. private _motionBlurSamples;
  114425. private _volumetricLightStepsCount;
  114426. private _samples;
  114427. /**
  114428. * @ignore
  114429. * Specifies if the bloom pipeline is enabled
  114430. */
  114431. BloomEnabled: boolean;
  114432. /**
  114433. * @ignore
  114434. * Specifies if the depth of field pipeline is enabed
  114435. */
  114436. DepthOfFieldEnabled: boolean;
  114437. /**
  114438. * @ignore
  114439. * Specifies if the lens flare pipeline is enabed
  114440. */
  114441. LensFlareEnabled: boolean;
  114442. /**
  114443. * @ignore
  114444. * Specifies if the HDR pipeline is enabled
  114445. */
  114446. HDREnabled: boolean;
  114447. /**
  114448. * @ignore
  114449. * Specifies if the volumetric lights scattering effect is enabled
  114450. */
  114451. VLSEnabled: boolean;
  114452. /**
  114453. * @ignore
  114454. * Specifies if the motion blur effect is enabled
  114455. */
  114456. MotionBlurEnabled: boolean;
  114457. /**
  114458. * Specifies if anti-aliasing is enabled
  114459. */
  114460. fxaaEnabled: boolean;
  114461. /**
  114462. * Specifies the number of steps used to calculate the volumetric lights
  114463. * Typically in interval [50, 200]
  114464. */
  114465. volumetricLightStepsCount: number;
  114466. /**
  114467. * Specifies the number of samples used for the motion blur effect
  114468. * Typically in interval [16, 64]
  114469. */
  114470. motionBlurSamples: number;
  114471. /**
  114472. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  114473. */
  114474. samples: number;
  114475. /**
  114476. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  114477. * @constructor
  114478. * @param name The rendering pipeline name
  114479. * @param scene The scene linked to this pipeline
  114480. * @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)
  114481. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  114482. * @param cameras The array of cameras that the rendering pipeline will be attached to
  114483. */
  114484. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  114485. private _buildPipeline;
  114486. private _createDownSampleX4PostProcess;
  114487. private _createBrightPassPostProcess;
  114488. private _createBlurPostProcesses;
  114489. private _createTextureAdderPostProcess;
  114490. private _createVolumetricLightPostProcess;
  114491. private _createLuminancePostProcesses;
  114492. private _createHdrPostProcess;
  114493. private _createLensFlarePostProcess;
  114494. private _createDepthOfFieldPostProcess;
  114495. private _createMotionBlurPostProcess;
  114496. private _getDepthTexture;
  114497. private _disposePostProcesses;
  114498. /**
  114499. * Dispose of the pipeline and stop all post processes
  114500. */
  114501. dispose(): void;
  114502. /**
  114503. * Serialize the rendering pipeline (Used when exporting)
  114504. * @returns the serialized object
  114505. */
  114506. serialize(): any;
  114507. /**
  114508. * Parse the serialized pipeline
  114509. * @param source Source pipeline.
  114510. * @param scene The scene to load the pipeline to.
  114511. * @param rootUrl The URL of the serialized pipeline.
  114512. * @returns An instantiated pipeline from the serialized object.
  114513. */
  114514. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  114515. /**
  114516. * Luminance steps
  114517. */
  114518. static LuminanceSteps: number;
  114519. }
  114520. }
  114521. declare module BABYLON {
  114522. /** @hidden */
  114523. export var tonemapPixelShader: {
  114524. name: string;
  114525. shader: string;
  114526. };
  114527. }
  114528. declare module BABYLON {
  114529. /** Defines operator used for tonemapping */
  114530. export enum TonemappingOperator {
  114531. /** Hable */
  114532. Hable = 0,
  114533. /** Reinhard */
  114534. Reinhard = 1,
  114535. /** HejiDawson */
  114536. HejiDawson = 2,
  114537. /** Photographic */
  114538. Photographic = 3
  114539. }
  114540. /**
  114541. * Defines a post process to apply tone mapping
  114542. */
  114543. export class TonemapPostProcess extends PostProcess {
  114544. private _operator;
  114545. /** Defines the required exposure adjustement */
  114546. exposureAdjustment: number;
  114547. /**
  114548. * Creates a new TonemapPostProcess
  114549. * @param name defines the name of the postprocess
  114550. * @param _operator defines the operator to use
  114551. * @param exposureAdjustment defines the required exposure adjustement
  114552. * @param camera defines the camera to use (can be null)
  114553. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  114554. * @param engine defines the hosting engine (can be ignore if camera is set)
  114555. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  114556. */
  114557. constructor(name: string, _operator: TonemappingOperator,
  114558. /** Defines the required exposure adjustement */
  114559. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  114560. }
  114561. }
  114562. declare module BABYLON {
  114563. /** @hidden */
  114564. export var depthVertexShader: {
  114565. name: string;
  114566. shader: string;
  114567. };
  114568. }
  114569. declare module BABYLON {
  114570. /** @hidden */
  114571. export var volumetricLightScatteringPixelShader: {
  114572. name: string;
  114573. shader: string;
  114574. };
  114575. }
  114576. declare module BABYLON {
  114577. /** @hidden */
  114578. export var volumetricLightScatteringPassPixelShader: {
  114579. name: string;
  114580. shader: string;
  114581. };
  114582. }
  114583. declare module BABYLON {
  114584. /**
  114585. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  114586. */
  114587. export class VolumetricLightScatteringPostProcess extends PostProcess {
  114588. private _volumetricLightScatteringPass;
  114589. private _volumetricLightScatteringRTT;
  114590. private _viewPort;
  114591. private _screenCoordinates;
  114592. private _cachedDefines;
  114593. /**
  114594. * If not undefined, the mesh position is computed from the attached node position
  114595. */
  114596. attachedNode: {
  114597. position: Vector3;
  114598. };
  114599. /**
  114600. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  114601. */
  114602. customMeshPosition: Vector3;
  114603. /**
  114604. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  114605. */
  114606. useCustomMeshPosition: boolean;
  114607. /**
  114608. * If the post-process should inverse the light scattering direction
  114609. */
  114610. invert: boolean;
  114611. /**
  114612. * The internal mesh used by the post-process
  114613. */
  114614. mesh: Mesh;
  114615. /**
  114616. * @hidden
  114617. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  114618. */
  114619. useDiffuseColor: boolean;
  114620. /**
  114621. * Array containing the excluded meshes not rendered in the internal pass
  114622. */
  114623. excludedMeshes: AbstractMesh[];
  114624. /**
  114625. * Controls the overall intensity of the post-process
  114626. */
  114627. exposure: number;
  114628. /**
  114629. * Dissipates each sample's contribution in range [0, 1]
  114630. */
  114631. decay: number;
  114632. /**
  114633. * Controls the overall intensity of each sample
  114634. */
  114635. weight: number;
  114636. /**
  114637. * Controls the density of each sample
  114638. */
  114639. density: number;
  114640. /**
  114641. * @constructor
  114642. * @param name The post-process name
  114643. * @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)
  114644. * @param camera The camera that the post-process will be attached to
  114645. * @param mesh The mesh used to create the light scattering
  114646. * @param samples The post-process quality, default 100
  114647. * @param samplingModeThe post-process filtering mode
  114648. * @param engine The babylon engine
  114649. * @param reusable If the post-process is reusable
  114650. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  114651. */
  114652. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  114653. /**
  114654. * Returns the string "VolumetricLightScatteringPostProcess"
  114655. * @returns "VolumetricLightScatteringPostProcess"
  114656. */
  114657. getClassName(): string;
  114658. private _isReady;
  114659. /**
  114660. * Sets the new light position for light scattering effect
  114661. * @param position The new custom light position
  114662. */
  114663. setCustomMeshPosition(position: Vector3): void;
  114664. /**
  114665. * Returns the light position for light scattering effect
  114666. * @return Vector3 The custom light position
  114667. */
  114668. getCustomMeshPosition(): Vector3;
  114669. /**
  114670. * Disposes the internal assets and detaches the post-process from the camera
  114671. */
  114672. dispose(camera: Camera): void;
  114673. /**
  114674. * Returns the render target texture used by the post-process
  114675. * @return the render target texture used by the post-process
  114676. */
  114677. getPass(): RenderTargetTexture;
  114678. private _meshExcluded;
  114679. private _createPass;
  114680. private _updateMeshScreenCoordinates;
  114681. /**
  114682. * Creates a default mesh for the Volumeric Light Scattering post-process
  114683. * @param name The mesh name
  114684. * @param scene The scene where to create the mesh
  114685. * @return the default mesh
  114686. */
  114687. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  114688. }
  114689. }
  114690. declare module BABYLON {
  114691. interface Scene {
  114692. /** @hidden (Backing field) */
  114693. _boundingBoxRenderer: BoundingBoxRenderer;
  114694. /** @hidden (Backing field) */
  114695. _forceShowBoundingBoxes: boolean;
  114696. /**
  114697. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  114698. */
  114699. forceShowBoundingBoxes: boolean;
  114700. /**
  114701. * Gets the bounding box renderer associated with the scene
  114702. * @returns a BoundingBoxRenderer
  114703. */
  114704. getBoundingBoxRenderer(): BoundingBoxRenderer;
  114705. }
  114706. interface AbstractMesh {
  114707. /** @hidden (Backing field) */
  114708. _showBoundingBox: boolean;
  114709. /**
  114710. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  114711. */
  114712. showBoundingBox: boolean;
  114713. }
  114714. /**
  114715. * Component responsible of rendering the bounding box of the meshes in a scene.
  114716. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  114717. */
  114718. export class BoundingBoxRenderer implements ISceneComponent {
  114719. /**
  114720. * The component name helpfull to identify the component in the list of scene components.
  114721. */
  114722. readonly name: string;
  114723. /**
  114724. * The scene the component belongs to.
  114725. */
  114726. scene: Scene;
  114727. /**
  114728. * Color of the bounding box lines placed in front of an object
  114729. */
  114730. frontColor: Color3;
  114731. /**
  114732. * Color of the bounding box lines placed behind an object
  114733. */
  114734. backColor: Color3;
  114735. /**
  114736. * Defines if the renderer should show the back lines or not
  114737. */
  114738. showBackLines: boolean;
  114739. /**
  114740. * @hidden
  114741. */
  114742. renderList: SmartArray<BoundingBox>;
  114743. private _colorShader;
  114744. private _vertexBuffers;
  114745. private _indexBuffer;
  114746. /**
  114747. * Instantiates a new bounding box renderer in a scene.
  114748. * @param scene the scene the renderer renders in
  114749. */
  114750. constructor(scene: Scene);
  114751. /**
  114752. * Registers the component in a given scene
  114753. */
  114754. register(): void;
  114755. private _evaluateSubMesh;
  114756. private _activeMesh;
  114757. private _prepareRessources;
  114758. private _createIndexBuffer;
  114759. /**
  114760. * Rebuilds the elements related to this component in case of
  114761. * context lost for instance.
  114762. */
  114763. rebuild(): void;
  114764. /**
  114765. * @hidden
  114766. */
  114767. reset(): void;
  114768. /**
  114769. * Render the bounding boxes of a specific rendering group
  114770. * @param renderingGroupId defines the rendering group to render
  114771. */
  114772. render(renderingGroupId: number): void;
  114773. /**
  114774. * In case of occlusion queries, we can render the occlusion bounding box through this method
  114775. * @param mesh Define the mesh to render the occlusion bounding box for
  114776. */
  114777. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  114778. /**
  114779. * Dispose and release the resources attached to this renderer.
  114780. */
  114781. dispose(): void;
  114782. }
  114783. }
  114784. declare module BABYLON {
  114785. /** @hidden */
  114786. export var depthPixelShader: {
  114787. name: string;
  114788. shader: string;
  114789. };
  114790. }
  114791. declare module BABYLON {
  114792. /**
  114793. * This represents a depth renderer in Babylon.
  114794. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  114795. */
  114796. export class DepthRenderer {
  114797. private _scene;
  114798. private _depthMap;
  114799. private _effect;
  114800. private _cachedDefines;
  114801. private _camera;
  114802. /**
  114803. * Specifiess that the depth renderer will only be used within
  114804. * the camera it is created for.
  114805. * This can help forcing its rendering during the camera processing.
  114806. */
  114807. useOnlyInActiveCamera: boolean;
  114808. /** @hidden */
  114809. static _SceneComponentInitialization: (scene: Scene) => void;
  114810. /**
  114811. * Instantiates a depth renderer
  114812. * @param scene The scene the renderer belongs to
  114813. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  114814. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  114815. */
  114816. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  114817. /**
  114818. * Creates the depth rendering effect and checks if the effect is ready.
  114819. * @param subMesh The submesh to be used to render the depth map of
  114820. * @param useInstances If multiple world instances should be used
  114821. * @returns if the depth renderer is ready to render the depth map
  114822. */
  114823. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  114824. /**
  114825. * Gets the texture which the depth map will be written to.
  114826. * @returns The depth map texture
  114827. */
  114828. getDepthMap(): RenderTargetTexture;
  114829. /**
  114830. * Disposes of the depth renderer.
  114831. */
  114832. dispose(): void;
  114833. }
  114834. }
  114835. declare module BABYLON {
  114836. interface Scene {
  114837. /** @hidden (Backing field) */
  114838. _depthRenderer: {
  114839. [id: string]: DepthRenderer;
  114840. };
  114841. /**
  114842. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  114843. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  114844. * @returns the created depth renderer
  114845. */
  114846. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  114847. /**
  114848. * Disables a depth renderer for a given camera
  114849. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  114850. */
  114851. disableDepthRenderer(camera?: Nullable<Camera>): void;
  114852. }
  114853. /**
  114854. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  114855. * in several rendering techniques.
  114856. */
  114857. export class DepthRendererSceneComponent implements ISceneComponent {
  114858. /**
  114859. * The component name helpfull to identify the component in the list of scene components.
  114860. */
  114861. readonly name: string;
  114862. /**
  114863. * The scene the component belongs to.
  114864. */
  114865. scene: Scene;
  114866. /**
  114867. * Creates a new instance of the component for the given scene
  114868. * @param scene Defines the scene to register the component in
  114869. */
  114870. constructor(scene: Scene);
  114871. /**
  114872. * Registers the component in a given scene
  114873. */
  114874. register(): void;
  114875. /**
  114876. * Rebuilds the elements related to this component in case of
  114877. * context lost for instance.
  114878. */
  114879. rebuild(): void;
  114880. /**
  114881. * Disposes the component and the associated ressources
  114882. */
  114883. dispose(): void;
  114884. private _gatherRenderTargets;
  114885. private _gatherActiveCameraRenderTargets;
  114886. }
  114887. }
  114888. declare module BABYLON {
  114889. /** @hidden */
  114890. export var outlinePixelShader: {
  114891. name: string;
  114892. shader: string;
  114893. };
  114894. }
  114895. declare module BABYLON {
  114896. /** @hidden */
  114897. export var outlineVertexShader: {
  114898. name: string;
  114899. shader: string;
  114900. };
  114901. }
  114902. declare module BABYLON {
  114903. interface Scene {
  114904. /** @hidden */
  114905. _outlineRenderer: OutlineRenderer;
  114906. /**
  114907. * Gets the outline renderer associated with the scene
  114908. * @returns a OutlineRenderer
  114909. */
  114910. getOutlineRenderer(): OutlineRenderer;
  114911. }
  114912. interface AbstractMesh {
  114913. /** @hidden (Backing field) */
  114914. _renderOutline: boolean;
  114915. /**
  114916. * Gets or sets a boolean indicating if the outline must be rendered as well
  114917. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  114918. */
  114919. renderOutline: boolean;
  114920. /** @hidden (Backing field) */
  114921. _renderOverlay: boolean;
  114922. /**
  114923. * Gets or sets a boolean indicating if the overlay must be rendered as well
  114924. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  114925. */
  114926. renderOverlay: boolean;
  114927. }
  114928. /**
  114929. * This class is responsible to draw bothe outline/overlay of meshes.
  114930. * It should not be used directly but through the available method on mesh.
  114931. */
  114932. export class OutlineRenderer implements ISceneComponent {
  114933. /**
  114934. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  114935. */
  114936. private static _StencilReference;
  114937. /**
  114938. * The name of the component. Each component must have a unique name.
  114939. */
  114940. name: string;
  114941. /**
  114942. * The scene the component belongs to.
  114943. */
  114944. scene: Scene;
  114945. /**
  114946. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  114947. */
  114948. zOffset: number;
  114949. private _engine;
  114950. private _effect;
  114951. private _cachedDefines;
  114952. private _savedDepthWrite;
  114953. /**
  114954. * Instantiates a new outline renderer. (There could be only one per scene).
  114955. * @param scene Defines the scene it belongs to
  114956. */
  114957. constructor(scene: Scene);
  114958. /**
  114959. * Register the component to one instance of a scene.
  114960. */
  114961. register(): void;
  114962. /**
  114963. * Rebuilds the elements related to this component in case of
  114964. * context lost for instance.
  114965. */
  114966. rebuild(): void;
  114967. /**
  114968. * Disposes the component and the associated ressources.
  114969. */
  114970. dispose(): void;
  114971. /**
  114972. * Renders the outline in the canvas.
  114973. * @param subMesh Defines the sumesh to render
  114974. * @param batch Defines the batch of meshes in case of instances
  114975. * @param useOverlay Defines if the rendering is for the overlay or the outline
  114976. */
  114977. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  114978. /**
  114979. * Returns whether or not the outline renderer is ready for a given submesh.
  114980. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  114981. * @param subMesh Defines the submesh to check readyness for
  114982. * @param useInstances Defines wheter wee are trying to render instances or not
  114983. * @returns true if ready otherwise false
  114984. */
  114985. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  114986. private _beforeRenderingMesh;
  114987. private _afterRenderingMesh;
  114988. }
  114989. }
  114990. declare module BABYLON {
  114991. /**
  114992. * Defines the list of states available for a task inside a AssetsManager
  114993. */
  114994. export enum AssetTaskState {
  114995. /**
  114996. * Initialization
  114997. */
  114998. INIT = 0,
  114999. /**
  115000. * Running
  115001. */
  115002. RUNNING = 1,
  115003. /**
  115004. * Done
  115005. */
  115006. DONE = 2,
  115007. /**
  115008. * Error
  115009. */
  115010. ERROR = 3
  115011. }
  115012. /**
  115013. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  115014. */
  115015. export abstract class AbstractAssetTask {
  115016. /**
  115017. * Task name
  115018. */ name: string;
  115019. /**
  115020. * Callback called when the task is successful
  115021. */
  115022. onSuccess: (task: any) => void;
  115023. /**
  115024. * Callback called when the task is not successful
  115025. */
  115026. onError: (task: any, message?: string, exception?: any) => void;
  115027. /**
  115028. * Creates a new AssetsManager
  115029. * @param name defines the name of the task
  115030. */
  115031. constructor(
  115032. /**
  115033. * Task name
  115034. */ name: string);
  115035. private _isCompleted;
  115036. private _taskState;
  115037. private _errorObject;
  115038. /**
  115039. * Get if the task is completed
  115040. */
  115041. readonly isCompleted: boolean;
  115042. /**
  115043. * Gets the current state of the task
  115044. */
  115045. readonly taskState: AssetTaskState;
  115046. /**
  115047. * Gets the current error object (if task is in error)
  115048. */
  115049. readonly errorObject: {
  115050. message?: string;
  115051. exception?: any;
  115052. };
  115053. /**
  115054. * Internal only
  115055. * @hidden
  115056. */
  115057. _setErrorObject(message?: string, exception?: any): void;
  115058. /**
  115059. * Execute the current task
  115060. * @param scene defines the scene where you want your assets to be loaded
  115061. * @param onSuccess is a callback called when the task is successfully executed
  115062. * @param onError is a callback called if an error occurs
  115063. */
  115064. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  115065. /**
  115066. * Execute the current task
  115067. * @param scene defines the scene where you want your assets to be loaded
  115068. * @param onSuccess is a callback called when the task is successfully executed
  115069. * @param onError is a callback called if an error occurs
  115070. */
  115071. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  115072. /**
  115073. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  115074. * This can be used with failed tasks that have the reason for failure fixed.
  115075. */
  115076. reset(): void;
  115077. private onErrorCallback;
  115078. private onDoneCallback;
  115079. }
  115080. /**
  115081. * Define the interface used by progress events raised during assets loading
  115082. */
  115083. export interface IAssetsProgressEvent {
  115084. /**
  115085. * Defines the number of remaining tasks to process
  115086. */
  115087. remainingCount: number;
  115088. /**
  115089. * Defines the total number of tasks
  115090. */
  115091. totalCount: number;
  115092. /**
  115093. * Defines the task that was just processed
  115094. */
  115095. task: AbstractAssetTask;
  115096. }
  115097. /**
  115098. * Class used to share progress information about assets loading
  115099. */
  115100. export class AssetsProgressEvent implements IAssetsProgressEvent {
  115101. /**
  115102. * Defines the number of remaining tasks to process
  115103. */
  115104. remainingCount: number;
  115105. /**
  115106. * Defines the total number of tasks
  115107. */
  115108. totalCount: number;
  115109. /**
  115110. * Defines the task that was just processed
  115111. */
  115112. task: AbstractAssetTask;
  115113. /**
  115114. * Creates a AssetsProgressEvent
  115115. * @param remainingCount defines the number of remaining tasks to process
  115116. * @param totalCount defines the total number of tasks
  115117. * @param task defines the task that was just processed
  115118. */
  115119. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  115120. }
  115121. /**
  115122. * Define a task used by AssetsManager to load meshes
  115123. */
  115124. export class MeshAssetTask extends AbstractAssetTask {
  115125. /**
  115126. * Defines the name of the task
  115127. */
  115128. name: string;
  115129. /**
  115130. * Defines the list of mesh's names you want to load
  115131. */
  115132. meshesNames: any;
  115133. /**
  115134. * Defines the root url to use as a base to load your meshes and associated resources
  115135. */
  115136. rootUrl: string;
  115137. /**
  115138. * Defines the filename of the scene to load from
  115139. */
  115140. sceneFilename: string;
  115141. /**
  115142. * Gets the list of loaded meshes
  115143. */
  115144. loadedMeshes: Array<AbstractMesh>;
  115145. /**
  115146. * Gets the list of loaded particle systems
  115147. */
  115148. loadedParticleSystems: Array<IParticleSystem>;
  115149. /**
  115150. * Gets the list of loaded skeletons
  115151. */
  115152. loadedSkeletons: Array<Skeleton>;
  115153. /**
  115154. * Gets the list of loaded animation groups
  115155. */
  115156. loadedAnimationGroups: Array<AnimationGroup>;
  115157. /**
  115158. * Callback called when the task is successful
  115159. */
  115160. onSuccess: (task: MeshAssetTask) => void;
  115161. /**
  115162. * Callback called when the task is successful
  115163. */
  115164. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  115165. /**
  115166. * Creates a new MeshAssetTask
  115167. * @param name defines the name of the task
  115168. * @param meshesNames defines the list of mesh's names you want to load
  115169. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  115170. * @param sceneFilename defines the filename of the scene to load from
  115171. */
  115172. constructor(
  115173. /**
  115174. * Defines the name of the task
  115175. */
  115176. name: string,
  115177. /**
  115178. * Defines the list of mesh's names you want to load
  115179. */
  115180. meshesNames: any,
  115181. /**
  115182. * Defines the root url to use as a base to load your meshes and associated resources
  115183. */
  115184. rootUrl: string,
  115185. /**
  115186. * Defines the filename of the scene to load from
  115187. */
  115188. sceneFilename: string);
  115189. /**
  115190. * Execute the current task
  115191. * @param scene defines the scene where you want your assets to be loaded
  115192. * @param onSuccess is a callback called when the task is successfully executed
  115193. * @param onError is a callback called if an error occurs
  115194. */
  115195. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  115196. }
  115197. /**
  115198. * Define a task used by AssetsManager to load text content
  115199. */
  115200. export class TextFileAssetTask extends AbstractAssetTask {
  115201. /**
  115202. * Defines the name of the task
  115203. */
  115204. name: string;
  115205. /**
  115206. * Defines the location of the file to load
  115207. */
  115208. url: string;
  115209. /**
  115210. * Gets the loaded text string
  115211. */
  115212. text: string;
  115213. /**
  115214. * Callback called when the task is successful
  115215. */
  115216. onSuccess: (task: TextFileAssetTask) => void;
  115217. /**
  115218. * Callback called when the task is successful
  115219. */
  115220. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  115221. /**
  115222. * Creates a new TextFileAssetTask object
  115223. * @param name defines the name of the task
  115224. * @param url defines the location of the file to load
  115225. */
  115226. constructor(
  115227. /**
  115228. * Defines the name of the task
  115229. */
  115230. name: string,
  115231. /**
  115232. * Defines the location of the file to load
  115233. */
  115234. url: string);
  115235. /**
  115236. * Execute the current task
  115237. * @param scene defines the scene where you want your assets to be loaded
  115238. * @param onSuccess is a callback called when the task is successfully executed
  115239. * @param onError is a callback called if an error occurs
  115240. */
  115241. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  115242. }
  115243. /**
  115244. * Define a task used by AssetsManager to load binary data
  115245. */
  115246. export class BinaryFileAssetTask extends AbstractAssetTask {
  115247. /**
  115248. * Defines the name of the task
  115249. */
  115250. name: string;
  115251. /**
  115252. * Defines the location of the file to load
  115253. */
  115254. url: string;
  115255. /**
  115256. * Gets the lodaded data (as an array buffer)
  115257. */
  115258. data: ArrayBuffer;
  115259. /**
  115260. * Callback called when the task is successful
  115261. */
  115262. onSuccess: (task: BinaryFileAssetTask) => void;
  115263. /**
  115264. * Callback called when the task is successful
  115265. */
  115266. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  115267. /**
  115268. * Creates a new BinaryFileAssetTask object
  115269. * @param name defines the name of the new task
  115270. * @param url defines the location of the file to load
  115271. */
  115272. constructor(
  115273. /**
  115274. * Defines the name of the task
  115275. */
  115276. name: string,
  115277. /**
  115278. * Defines the location of the file to load
  115279. */
  115280. url: string);
  115281. /**
  115282. * Execute the current task
  115283. * @param scene defines the scene where you want your assets to be loaded
  115284. * @param onSuccess is a callback called when the task is successfully executed
  115285. * @param onError is a callback called if an error occurs
  115286. */
  115287. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  115288. }
  115289. /**
  115290. * Define a task used by AssetsManager to load images
  115291. */
  115292. export class ImageAssetTask extends AbstractAssetTask {
  115293. /**
  115294. * Defines the name of the task
  115295. */
  115296. name: string;
  115297. /**
  115298. * Defines the location of the image to load
  115299. */
  115300. url: string;
  115301. /**
  115302. * Gets the loaded images
  115303. */
  115304. image: HTMLImageElement;
  115305. /**
  115306. * Callback called when the task is successful
  115307. */
  115308. onSuccess: (task: ImageAssetTask) => void;
  115309. /**
  115310. * Callback called when the task is successful
  115311. */
  115312. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  115313. /**
  115314. * Creates a new ImageAssetTask
  115315. * @param name defines the name of the task
  115316. * @param url defines the location of the image to load
  115317. */
  115318. constructor(
  115319. /**
  115320. * Defines the name of the task
  115321. */
  115322. name: string,
  115323. /**
  115324. * Defines the location of the image to load
  115325. */
  115326. url: string);
  115327. /**
  115328. * Execute the current task
  115329. * @param scene defines the scene where you want your assets to be loaded
  115330. * @param onSuccess is a callback called when the task is successfully executed
  115331. * @param onError is a callback called if an error occurs
  115332. */
  115333. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  115334. }
  115335. /**
  115336. * Defines the interface used by texture loading tasks
  115337. */
  115338. export interface ITextureAssetTask<TEX extends BaseTexture> {
  115339. /**
  115340. * Gets the loaded texture
  115341. */
  115342. texture: TEX;
  115343. }
  115344. /**
  115345. * Define a task used by AssetsManager to load 2D textures
  115346. */
  115347. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  115348. /**
  115349. * Defines the name of the task
  115350. */
  115351. name: string;
  115352. /**
  115353. * Defines the location of the file to load
  115354. */
  115355. url: string;
  115356. /**
  115357. * Defines if mipmap should not be generated (default is false)
  115358. */
  115359. noMipmap?: boolean | undefined;
  115360. /**
  115361. * Defines if texture must be inverted on Y axis (default is false)
  115362. */
  115363. invertY?: boolean | undefined;
  115364. /**
  115365. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  115366. */
  115367. samplingMode: number;
  115368. /**
  115369. * Gets the loaded texture
  115370. */
  115371. texture: Texture;
  115372. /**
  115373. * Callback called when the task is successful
  115374. */
  115375. onSuccess: (task: TextureAssetTask) => void;
  115376. /**
  115377. * Callback called when the task is successful
  115378. */
  115379. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  115380. /**
  115381. * Creates a new TextureAssetTask object
  115382. * @param name defines the name of the task
  115383. * @param url defines the location of the file to load
  115384. * @param noMipmap defines if mipmap should not be generated (default is false)
  115385. * @param invertY defines if texture must be inverted on Y axis (default is false)
  115386. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  115387. */
  115388. constructor(
  115389. /**
  115390. * Defines the name of the task
  115391. */
  115392. name: string,
  115393. /**
  115394. * Defines the location of the file to load
  115395. */
  115396. url: string,
  115397. /**
  115398. * Defines if mipmap should not be generated (default is false)
  115399. */
  115400. noMipmap?: boolean | undefined,
  115401. /**
  115402. * Defines if texture must be inverted on Y axis (default is false)
  115403. */
  115404. invertY?: boolean | undefined,
  115405. /**
  115406. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  115407. */
  115408. samplingMode?: number);
  115409. /**
  115410. * Execute the current task
  115411. * @param scene defines the scene where you want your assets to be loaded
  115412. * @param onSuccess is a callback called when the task is successfully executed
  115413. * @param onError is a callback called if an error occurs
  115414. */
  115415. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  115416. }
  115417. /**
  115418. * Define a task used by AssetsManager to load cube textures
  115419. */
  115420. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  115421. /**
  115422. * Defines the name of the task
  115423. */
  115424. name: string;
  115425. /**
  115426. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  115427. */
  115428. url: string;
  115429. /**
  115430. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  115431. */
  115432. extensions?: string[] | undefined;
  115433. /**
  115434. * Defines if mipmaps should not be generated (default is false)
  115435. */
  115436. noMipmap?: boolean | undefined;
  115437. /**
  115438. * Defines the explicit list of files (undefined by default)
  115439. */
  115440. files?: string[] | undefined;
  115441. /**
  115442. * Gets the loaded texture
  115443. */
  115444. texture: CubeTexture;
  115445. /**
  115446. * Callback called when the task is successful
  115447. */
  115448. onSuccess: (task: CubeTextureAssetTask) => void;
  115449. /**
  115450. * Callback called when the task is successful
  115451. */
  115452. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  115453. /**
  115454. * Creates a new CubeTextureAssetTask
  115455. * @param name defines the name of the task
  115456. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  115457. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  115458. * @param noMipmap defines if mipmaps should not be generated (default is false)
  115459. * @param files defines the explicit list of files (undefined by default)
  115460. */
  115461. constructor(
  115462. /**
  115463. * Defines the name of the task
  115464. */
  115465. name: string,
  115466. /**
  115467. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  115468. */
  115469. url: string,
  115470. /**
  115471. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  115472. */
  115473. extensions?: string[] | undefined,
  115474. /**
  115475. * Defines if mipmaps should not be generated (default is false)
  115476. */
  115477. noMipmap?: boolean | undefined,
  115478. /**
  115479. * Defines the explicit list of files (undefined by default)
  115480. */
  115481. files?: string[] | undefined);
  115482. /**
  115483. * Execute the current task
  115484. * @param scene defines the scene where you want your assets to be loaded
  115485. * @param onSuccess is a callback called when the task is successfully executed
  115486. * @param onError is a callback called if an error occurs
  115487. */
  115488. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  115489. }
  115490. /**
  115491. * Define a task used by AssetsManager to load HDR cube textures
  115492. */
  115493. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  115494. /**
  115495. * Defines the name of the task
  115496. */
  115497. name: string;
  115498. /**
  115499. * Defines the location of the file to load
  115500. */
  115501. url: string;
  115502. /**
  115503. * Defines the desired size (the more it increases the longer the generation will be)
  115504. */
  115505. size: number;
  115506. /**
  115507. * Defines if mipmaps should not be generated (default is false)
  115508. */
  115509. noMipmap: boolean;
  115510. /**
  115511. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  115512. */
  115513. generateHarmonics: boolean;
  115514. /**
  115515. * 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)
  115516. */
  115517. gammaSpace: boolean;
  115518. /**
  115519. * Internal Use Only
  115520. */
  115521. reserved: boolean;
  115522. /**
  115523. * Gets the loaded texture
  115524. */
  115525. texture: HDRCubeTexture;
  115526. /**
  115527. * Callback called when the task is successful
  115528. */
  115529. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  115530. /**
  115531. * Callback called when the task is successful
  115532. */
  115533. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  115534. /**
  115535. * Creates a new HDRCubeTextureAssetTask object
  115536. * @param name defines the name of the task
  115537. * @param url defines the location of the file to load
  115538. * @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.
  115539. * @param noMipmap defines if mipmaps should not be generated (default is false)
  115540. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  115541. * @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)
  115542. * @param reserved Internal use only
  115543. */
  115544. constructor(
  115545. /**
  115546. * Defines the name of the task
  115547. */
  115548. name: string,
  115549. /**
  115550. * Defines the location of the file to load
  115551. */
  115552. url: string,
  115553. /**
  115554. * Defines the desired size (the more it increases the longer the generation will be)
  115555. */
  115556. size: number,
  115557. /**
  115558. * Defines if mipmaps should not be generated (default is false)
  115559. */
  115560. noMipmap?: boolean,
  115561. /**
  115562. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  115563. */
  115564. generateHarmonics?: boolean,
  115565. /**
  115566. * 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)
  115567. */
  115568. gammaSpace?: boolean,
  115569. /**
  115570. * Internal Use Only
  115571. */
  115572. reserved?: boolean);
  115573. /**
  115574. * Execute the current task
  115575. * @param scene defines the scene where you want your assets to be loaded
  115576. * @param onSuccess is a callback called when the task is successfully executed
  115577. * @param onError is a callback called if an error occurs
  115578. */
  115579. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  115580. }
  115581. /**
  115582. * Define a task used by AssetsManager to load Equirectangular cube textures
  115583. */
  115584. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  115585. /**
  115586. * Defines the name of the task
  115587. */
  115588. name: string;
  115589. /**
  115590. * Defines the location of the file to load
  115591. */
  115592. url: string;
  115593. /**
  115594. * Defines the desired size (the more it increases the longer the generation will be)
  115595. */
  115596. size: number;
  115597. /**
  115598. * Defines if mipmaps should not be generated (default is false)
  115599. */
  115600. noMipmap: boolean;
  115601. /**
  115602. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  115603. * but the standard material would require them in Gamma space) (default is true)
  115604. */
  115605. gammaSpace: boolean;
  115606. /**
  115607. * Gets the loaded texture
  115608. */
  115609. texture: EquiRectangularCubeTexture;
  115610. /**
  115611. * Callback called when the task is successful
  115612. */
  115613. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  115614. /**
  115615. * Callback called when the task is successful
  115616. */
  115617. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  115618. /**
  115619. * Creates a new EquiRectangularCubeTextureAssetTask object
  115620. * @param name defines the name of the task
  115621. * @param url defines the location of the file to load
  115622. * @param size defines the desired size (the more it increases the longer the generation will be)
  115623. * If the size is omitted this implies you are using a preprocessed cubemap.
  115624. * @param noMipmap defines if mipmaps should not be generated (default is false)
  115625. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  115626. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  115627. * (default is true)
  115628. */
  115629. constructor(
  115630. /**
  115631. * Defines the name of the task
  115632. */
  115633. name: string,
  115634. /**
  115635. * Defines the location of the file to load
  115636. */
  115637. url: string,
  115638. /**
  115639. * Defines the desired size (the more it increases the longer the generation will be)
  115640. */
  115641. size: number,
  115642. /**
  115643. * Defines if mipmaps should not be generated (default is false)
  115644. */
  115645. noMipmap?: boolean,
  115646. /**
  115647. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  115648. * but the standard material would require them in Gamma space) (default is true)
  115649. */
  115650. gammaSpace?: boolean);
  115651. /**
  115652. * Execute the current task
  115653. * @param scene defines the scene where you want your assets to be loaded
  115654. * @param onSuccess is a callback called when the task is successfully executed
  115655. * @param onError is a callback called if an error occurs
  115656. */
  115657. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  115658. }
  115659. /**
  115660. * This class can be used to easily import assets into a scene
  115661. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  115662. */
  115663. export class AssetsManager {
  115664. private _scene;
  115665. private _isLoading;
  115666. protected _tasks: AbstractAssetTask[];
  115667. protected _waitingTasksCount: number;
  115668. protected _totalTasksCount: number;
  115669. /**
  115670. * Callback called when all tasks are processed
  115671. */
  115672. onFinish: (tasks: AbstractAssetTask[]) => void;
  115673. /**
  115674. * Callback called when a task is successful
  115675. */
  115676. onTaskSuccess: (task: AbstractAssetTask) => void;
  115677. /**
  115678. * Callback called when a task had an error
  115679. */
  115680. onTaskError: (task: AbstractAssetTask) => void;
  115681. /**
  115682. * Callback called when a task is done (whatever the result is)
  115683. */
  115684. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  115685. /**
  115686. * Observable called when all tasks are processed
  115687. */
  115688. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  115689. /**
  115690. * Observable called when a task had an error
  115691. */
  115692. onTaskErrorObservable: Observable<AbstractAssetTask>;
  115693. /**
  115694. * Observable called when all tasks were executed
  115695. */
  115696. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  115697. /**
  115698. * Observable called when a task is done (whatever the result is)
  115699. */
  115700. onProgressObservable: Observable<IAssetsProgressEvent>;
  115701. /**
  115702. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  115703. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  115704. */
  115705. useDefaultLoadingScreen: boolean;
  115706. /**
  115707. * Creates a new AssetsManager
  115708. * @param scene defines the scene to work on
  115709. */
  115710. constructor(scene: Scene);
  115711. /**
  115712. * Add a MeshAssetTask to the list of active tasks
  115713. * @param taskName defines the name of the new task
  115714. * @param meshesNames defines the name of meshes to load
  115715. * @param rootUrl defines the root url to use to locate files
  115716. * @param sceneFilename defines the filename of the scene file
  115717. * @returns a new MeshAssetTask object
  115718. */
  115719. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  115720. /**
  115721. * Add a TextFileAssetTask to the list of active tasks
  115722. * @param taskName defines the name of the new task
  115723. * @param url defines the url of the file to load
  115724. * @returns a new TextFileAssetTask object
  115725. */
  115726. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  115727. /**
  115728. * Add a BinaryFileAssetTask to the list of active tasks
  115729. * @param taskName defines the name of the new task
  115730. * @param url defines the url of the file to load
  115731. * @returns a new BinaryFileAssetTask object
  115732. */
  115733. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  115734. /**
  115735. * Add a ImageAssetTask to the list of active tasks
  115736. * @param taskName defines the name of the new task
  115737. * @param url defines the url of the file to load
  115738. * @returns a new ImageAssetTask object
  115739. */
  115740. addImageTask(taskName: string, url: string): ImageAssetTask;
  115741. /**
  115742. * Add a TextureAssetTask to the list of active tasks
  115743. * @param taskName defines the name of the new task
  115744. * @param url defines the url of the file to load
  115745. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  115746. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  115747. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  115748. * @returns a new TextureAssetTask object
  115749. */
  115750. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  115751. /**
  115752. * Add a CubeTextureAssetTask to the list of active tasks
  115753. * @param taskName defines the name of the new task
  115754. * @param url defines the url of the file to load
  115755. * @param extensions defines the extension to use to load the cube map (can be null)
  115756. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  115757. * @param files defines the list of files to load (can be null)
  115758. * @returns a new CubeTextureAssetTask object
  115759. */
  115760. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  115761. /**
  115762. *
  115763. * Add a HDRCubeTextureAssetTask to the list of active tasks
  115764. * @param taskName defines the name of the new task
  115765. * @param url defines the url of the file to load
  115766. * @param size defines the size you want for the cubemap (can be null)
  115767. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  115768. * @param generateHarmonics defines if you want to automatically generate (true by default)
  115769. * @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)
  115770. * @param reserved Internal use only
  115771. * @returns a new HDRCubeTextureAssetTask object
  115772. */
  115773. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  115774. /**
  115775. *
  115776. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  115777. * @param taskName defines the name of the new task
  115778. * @param url defines the url of the file to load
  115779. * @param size defines the size you want for the cubemap (can be null)
  115780. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  115781. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  115782. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  115783. * @returns a new EquiRectangularCubeTextureAssetTask object
  115784. */
  115785. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  115786. /**
  115787. * Remove a task from the assets manager.
  115788. * @param task the task to remove
  115789. */
  115790. removeTask(task: AbstractAssetTask): void;
  115791. private _decreaseWaitingTasksCount;
  115792. private _runTask;
  115793. /**
  115794. * Reset the AssetsManager and remove all tasks
  115795. * @return the current instance of the AssetsManager
  115796. */
  115797. reset(): AssetsManager;
  115798. /**
  115799. * Start the loading process
  115800. * @return the current instance of the AssetsManager
  115801. */
  115802. load(): AssetsManager;
  115803. /**
  115804. * Start the loading process as an async operation
  115805. * @return a promise returning the list of failed tasks
  115806. */
  115807. loadAsync(): Promise<void>;
  115808. }
  115809. }
  115810. declare module BABYLON {
  115811. /**
  115812. * Wrapper class for promise with external resolve and reject.
  115813. */
  115814. export class Deferred<T> {
  115815. /**
  115816. * The promise associated with this deferred object.
  115817. */
  115818. readonly promise: Promise<T>;
  115819. private _resolve;
  115820. private _reject;
  115821. /**
  115822. * The resolve method of the promise associated with this deferred object.
  115823. */
  115824. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  115825. /**
  115826. * The reject method of the promise associated with this deferred object.
  115827. */
  115828. readonly reject: (reason?: any) => void;
  115829. /**
  115830. * Constructor for this deferred object.
  115831. */
  115832. constructor();
  115833. }
  115834. }
  115835. declare module BABYLON {
  115836. /**
  115837. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  115838. */
  115839. export class MeshExploder {
  115840. private _centerMesh;
  115841. private _meshes;
  115842. private _meshesOrigins;
  115843. private _toCenterVectors;
  115844. private _scaledDirection;
  115845. private _newPosition;
  115846. private _centerPosition;
  115847. /**
  115848. * Explodes meshes from a center mesh.
  115849. * @param meshes The meshes to explode.
  115850. * @param centerMesh The mesh to be center of explosion.
  115851. */
  115852. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  115853. private _setCenterMesh;
  115854. /**
  115855. * Get class name
  115856. * @returns "MeshExploder"
  115857. */
  115858. getClassName(): string;
  115859. /**
  115860. * "Exploded meshes"
  115861. * @returns Array of meshes with the centerMesh at index 0.
  115862. */
  115863. getMeshes(): Array<Mesh>;
  115864. /**
  115865. * Explodes meshes giving a specific direction
  115866. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  115867. */
  115868. explode(direction?: number): void;
  115869. }
  115870. }
  115871. declare module BABYLON {
  115872. /**
  115873. * Class used to help managing file picking and drag'n'drop
  115874. */
  115875. export class FilesInput {
  115876. /**
  115877. * List of files ready to be loaded
  115878. */
  115879. static readonly FilesToLoad: {
  115880. [key: string]: File;
  115881. };
  115882. /**
  115883. * Callback called when a file is processed
  115884. */
  115885. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  115886. private _engine;
  115887. private _currentScene;
  115888. private _sceneLoadedCallback;
  115889. private _progressCallback;
  115890. private _additionalRenderLoopLogicCallback;
  115891. private _textureLoadingCallback;
  115892. private _startingProcessingFilesCallback;
  115893. private _onReloadCallback;
  115894. private _errorCallback;
  115895. private _elementToMonitor;
  115896. private _sceneFileToLoad;
  115897. private _filesToLoad;
  115898. /**
  115899. * Creates a new FilesInput
  115900. * @param engine defines the rendering engine
  115901. * @param scene defines the hosting scene
  115902. * @param sceneLoadedCallback callback called when scene is loaded
  115903. * @param progressCallback callback called to track progress
  115904. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  115905. * @param textureLoadingCallback callback called when a texture is loading
  115906. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  115907. * @param onReloadCallback callback called when a reload is requested
  115908. * @param errorCallback callback call if an error occurs
  115909. */
  115910. 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);
  115911. private _dragEnterHandler;
  115912. private _dragOverHandler;
  115913. private _dropHandler;
  115914. /**
  115915. * Calls this function to listen to drag'n'drop events on a specific DOM element
  115916. * @param elementToMonitor defines the DOM element to track
  115917. */
  115918. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  115919. /**
  115920. * Release all associated resources
  115921. */
  115922. dispose(): void;
  115923. private renderFunction;
  115924. private drag;
  115925. private drop;
  115926. private _traverseFolder;
  115927. private _processFiles;
  115928. /**
  115929. * Load files from a drop event
  115930. * @param event defines the drop event to use as source
  115931. */
  115932. loadFiles(event: any): void;
  115933. private _processReload;
  115934. /**
  115935. * Reload the current scene from the loaded files
  115936. */
  115937. reload(): void;
  115938. }
  115939. }
  115940. declare module BABYLON {
  115941. /**
  115942. * Defines the root class used to create scene optimization to use with SceneOptimizer
  115943. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115944. */
  115945. export class SceneOptimization {
  115946. /**
  115947. * Defines the priority of this optimization (0 by default which means first in the list)
  115948. */
  115949. priority: number;
  115950. /**
  115951. * Gets a string describing the action executed by the current optimization
  115952. * @returns description string
  115953. */
  115954. getDescription(): string;
  115955. /**
  115956. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  115957. * @param scene defines the current scene where to apply this optimization
  115958. * @param optimizer defines the current optimizer
  115959. * @returns true if everything that can be done was applied
  115960. */
  115961. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  115962. /**
  115963. * Creates the SceneOptimization object
  115964. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  115965. * @param desc defines the description associated with the optimization
  115966. */
  115967. constructor(
  115968. /**
  115969. * Defines the priority of this optimization (0 by default which means first in the list)
  115970. */
  115971. priority?: number);
  115972. }
  115973. /**
  115974. * Defines an optimization used to reduce the size of render target textures
  115975. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115976. */
  115977. export class TextureOptimization extends SceneOptimization {
  115978. /**
  115979. * Defines the priority of this optimization (0 by default which means first in the list)
  115980. */
  115981. priority: number;
  115982. /**
  115983. * 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
  115984. */
  115985. maximumSize: number;
  115986. /**
  115987. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  115988. */
  115989. step: number;
  115990. /**
  115991. * Gets a string describing the action executed by the current optimization
  115992. * @returns description string
  115993. */
  115994. getDescription(): string;
  115995. /**
  115996. * Creates the TextureOptimization object
  115997. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  115998. * @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
  115999. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  116000. */
  116001. constructor(
  116002. /**
  116003. * Defines the priority of this optimization (0 by default which means first in the list)
  116004. */
  116005. priority?: number,
  116006. /**
  116007. * 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
  116008. */
  116009. maximumSize?: number,
  116010. /**
  116011. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  116012. */
  116013. step?: number);
  116014. /**
  116015. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  116016. * @param scene defines the current scene where to apply this optimization
  116017. * @param optimizer defines the current optimizer
  116018. * @returns true if everything that can be done was applied
  116019. */
  116020. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  116021. }
  116022. /**
  116023. * Defines an optimization used to increase or decrease the rendering resolution
  116024. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  116025. */
  116026. export class HardwareScalingOptimization extends SceneOptimization {
  116027. /**
  116028. * Defines the priority of this optimization (0 by default which means first in the list)
  116029. */
  116030. priority: number;
  116031. /**
  116032. * Defines the maximum scale to use (2 by default)
  116033. */
  116034. maximumScale: number;
  116035. /**
  116036. * Defines the step to use between two passes (0.5 by default)
  116037. */
  116038. step: number;
  116039. private _currentScale;
  116040. private _directionOffset;
  116041. /**
  116042. * Gets a string describing the action executed by the current optimization
  116043. * @return description string
  116044. */
  116045. getDescription(): string;
  116046. /**
  116047. * Creates the HardwareScalingOptimization object
  116048. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  116049. * @param maximumScale defines the maximum scale to use (2 by default)
  116050. * @param step defines the step to use between two passes (0.5 by default)
  116051. */
  116052. constructor(
  116053. /**
  116054. * Defines the priority of this optimization (0 by default which means first in the list)
  116055. */
  116056. priority?: number,
  116057. /**
  116058. * Defines the maximum scale to use (2 by default)
  116059. */
  116060. maximumScale?: number,
  116061. /**
  116062. * Defines the step to use between two passes (0.5 by default)
  116063. */
  116064. step?: number);
  116065. /**
  116066. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  116067. * @param scene defines the current scene where to apply this optimization
  116068. * @param optimizer defines the current optimizer
  116069. * @returns true if everything that can be done was applied
  116070. */
  116071. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  116072. }
  116073. /**
  116074. * Defines an optimization used to remove shadows
  116075. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  116076. */
  116077. export class ShadowsOptimization extends SceneOptimization {
  116078. /**
  116079. * Gets a string describing the action executed by the current optimization
  116080. * @return description string
  116081. */
  116082. getDescription(): string;
  116083. /**
  116084. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  116085. * @param scene defines the current scene where to apply this optimization
  116086. * @param optimizer defines the current optimizer
  116087. * @returns true if everything that can be done was applied
  116088. */
  116089. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  116090. }
  116091. /**
  116092. * Defines an optimization used to turn post-processes off
  116093. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  116094. */
  116095. export class PostProcessesOptimization extends SceneOptimization {
  116096. /**
  116097. * Gets a string describing the action executed by the current optimization
  116098. * @return description string
  116099. */
  116100. getDescription(): string;
  116101. /**
  116102. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  116103. * @param scene defines the current scene where to apply this optimization
  116104. * @param optimizer defines the current optimizer
  116105. * @returns true if everything that can be done was applied
  116106. */
  116107. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  116108. }
  116109. /**
  116110. * Defines an optimization used to turn lens flares off
  116111. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  116112. */
  116113. export class LensFlaresOptimization extends SceneOptimization {
  116114. /**
  116115. * Gets a string describing the action executed by the current optimization
  116116. * @return description string
  116117. */
  116118. getDescription(): string;
  116119. /**
  116120. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  116121. * @param scene defines the current scene where to apply this optimization
  116122. * @param optimizer defines the current optimizer
  116123. * @returns true if everything that can be done was applied
  116124. */
  116125. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  116126. }
  116127. /**
  116128. * Defines an optimization based on user defined callback.
  116129. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  116130. */
  116131. export class CustomOptimization extends SceneOptimization {
  116132. /**
  116133. * Callback called to apply the custom optimization.
  116134. */
  116135. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  116136. /**
  116137. * Callback called to get custom description
  116138. */
  116139. onGetDescription: () => string;
  116140. /**
  116141. * Gets a string describing the action executed by the current optimization
  116142. * @returns description string
  116143. */
  116144. getDescription(): string;
  116145. /**
  116146. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  116147. * @param scene defines the current scene where to apply this optimization
  116148. * @param optimizer defines the current optimizer
  116149. * @returns true if everything that can be done was applied
  116150. */
  116151. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  116152. }
  116153. /**
  116154. * Defines an optimization used to turn particles off
  116155. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  116156. */
  116157. export class ParticlesOptimization extends SceneOptimization {
  116158. /**
  116159. * Gets a string describing the action executed by the current optimization
  116160. * @return description string
  116161. */
  116162. getDescription(): string;
  116163. /**
  116164. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  116165. * @param scene defines the current scene where to apply this optimization
  116166. * @param optimizer defines the current optimizer
  116167. * @returns true if everything that can be done was applied
  116168. */
  116169. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  116170. }
  116171. /**
  116172. * Defines an optimization used to turn render targets off
  116173. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  116174. */
  116175. export class RenderTargetsOptimization extends SceneOptimization {
  116176. /**
  116177. * Gets a string describing the action executed by the current optimization
  116178. * @return description string
  116179. */
  116180. getDescription(): string;
  116181. /**
  116182. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  116183. * @param scene defines the current scene where to apply this optimization
  116184. * @param optimizer defines the current optimizer
  116185. * @returns true if everything that can be done was applied
  116186. */
  116187. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  116188. }
  116189. /**
  116190. * Defines an optimization used to merge meshes with compatible materials
  116191. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  116192. */
  116193. export class MergeMeshesOptimization extends SceneOptimization {
  116194. private static _UpdateSelectionTree;
  116195. /**
  116196. * Gets or sets a boolean which defines if optimization octree has to be updated
  116197. */
  116198. /**
  116199. * Gets or sets a boolean which defines if optimization octree has to be updated
  116200. */
  116201. static UpdateSelectionTree: boolean;
  116202. /**
  116203. * Gets a string describing the action executed by the current optimization
  116204. * @return description string
  116205. */
  116206. getDescription(): string;
  116207. private _canBeMerged;
  116208. /**
  116209. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  116210. * @param scene defines the current scene where to apply this optimization
  116211. * @param optimizer defines the current optimizer
  116212. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  116213. * @returns true if everything that can be done was applied
  116214. */
  116215. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  116216. }
  116217. /**
  116218. * Defines a list of options used by SceneOptimizer
  116219. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  116220. */
  116221. export class SceneOptimizerOptions {
  116222. /**
  116223. * Defines the target frame rate to reach (60 by default)
  116224. */
  116225. targetFrameRate: number;
  116226. /**
  116227. * Defines the interval between two checkes (2000ms by default)
  116228. */
  116229. trackerDuration: number;
  116230. /**
  116231. * Gets the list of optimizations to apply
  116232. */
  116233. optimizations: SceneOptimization[];
  116234. /**
  116235. * Creates a new list of options used by SceneOptimizer
  116236. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  116237. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  116238. */
  116239. constructor(
  116240. /**
  116241. * Defines the target frame rate to reach (60 by default)
  116242. */
  116243. targetFrameRate?: number,
  116244. /**
  116245. * Defines the interval between two checkes (2000ms by default)
  116246. */
  116247. trackerDuration?: number);
  116248. /**
  116249. * Add a new optimization
  116250. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  116251. * @returns the current SceneOptimizerOptions
  116252. */
  116253. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  116254. /**
  116255. * Add a new custom optimization
  116256. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  116257. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  116258. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  116259. * @returns the current SceneOptimizerOptions
  116260. */
  116261. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  116262. /**
  116263. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  116264. * @param targetFrameRate defines the target frame rate (60 by default)
  116265. * @returns a SceneOptimizerOptions object
  116266. */
  116267. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  116268. /**
  116269. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  116270. * @param targetFrameRate defines the target frame rate (60 by default)
  116271. * @returns a SceneOptimizerOptions object
  116272. */
  116273. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  116274. /**
  116275. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  116276. * @param targetFrameRate defines the target frame rate (60 by default)
  116277. * @returns a SceneOptimizerOptions object
  116278. */
  116279. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  116280. }
  116281. /**
  116282. * Class used to run optimizations in order to reach a target frame rate
  116283. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  116284. */
  116285. export class SceneOptimizer implements IDisposable {
  116286. private _isRunning;
  116287. private _options;
  116288. private _scene;
  116289. private _currentPriorityLevel;
  116290. private _targetFrameRate;
  116291. private _trackerDuration;
  116292. private _currentFrameRate;
  116293. private _sceneDisposeObserver;
  116294. private _improvementMode;
  116295. /**
  116296. * Defines an observable called when the optimizer reaches the target frame rate
  116297. */
  116298. onSuccessObservable: Observable<SceneOptimizer>;
  116299. /**
  116300. * Defines an observable called when the optimizer enables an optimization
  116301. */
  116302. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  116303. /**
  116304. * Defines an observable called when the optimizer is not able to reach the target frame rate
  116305. */
  116306. onFailureObservable: Observable<SceneOptimizer>;
  116307. /**
  116308. * Gets a boolean indicating if the optimizer is in improvement mode
  116309. */
  116310. readonly isInImprovementMode: boolean;
  116311. /**
  116312. * Gets the current priority level (0 at start)
  116313. */
  116314. readonly currentPriorityLevel: number;
  116315. /**
  116316. * Gets the current frame rate checked by the SceneOptimizer
  116317. */
  116318. readonly currentFrameRate: number;
  116319. /**
  116320. * Gets or sets the current target frame rate (60 by default)
  116321. */
  116322. /**
  116323. * Gets or sets the current target frame rate (60 by default)
  116324. */
  116325. targetFrameRate: number;
  116326. /**
  116327. * Gets or sets the current interval between two checks (every 2000ms by default)
  116328. */
  116329. /**
  116330. * Gets or sets the current interval between two checks (every 2000ms by default)
  116331. */
  116332. trackerDuration: number;
  116333. /**
  116334. * Gets the list of active optimizations
  116335. */
  116336. readonly optimizations: SceneOptimization[];
  116337. /**
  116338. * Creates a new SceneOptimizer
  116339. * @param scene defines the scene to work on
  116340. * @param options defines the options to use with the SceneOptimizer
  116341. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  116342. * @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)
  116343. */
  116344. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  116345. /**
  116346. * Stops the current optimizer
  116347. */
  116348. stop(): void;
  116349. /**
  116350. * Reset the optimizer to initial step (current priority level = 0)
  116351. */
  116352. reset(): void;
  116353. /**
  116354. * Start the optimizer. By default it will try to reach a specific framerate
  116355. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  116356. */
  116357. start(): void;
  116358. private _checkCurrentState;
  116359. /**
  116360. * Release all resources
  116361. */
  116362. dispose(): void;
  116363. /**
  116364. * Helper function to create a SceneOptimizer with one single line of code
  116365. * @param scene defines the scene to work on
  116366. * @param options defines the options to use with the SceneOptimizer
  116367. * @param onSuccess defines a callback to call on success
  116368. * @param onFailure defines a callback to call on failure
  116369. * @returns the new SceneOptimizer object
  116370. */
  116371. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  116372. }
  116373. }
  116374. declare module BABYLON {
  116375. /**
  116376. * Class used to serialize a scene into a string
  116377. */
  116378. export class SceneSerializer {
  116379. /**
  116380. * Clear cache used by a previous serialization
  116381. */
  116382. static ClearCache(): void;
  116383. /**
  116384. * Serialize a scene into a JSON compatible object
  116385. * @param scene defines the scene to serialize
  116386. * @returns a JSON compatible object
  116387. */
  116388. static Serialize(scene: Scene): any;
  116389. /**
  116390. * Serialize a mesh into a JSON compatible object
  116391. * @param toSerialize defines the mesh to serialize
  116392. * @param withParents defines if parents must be serialized as well
  116393. * @param withChildren defines if children must be serialized as well
  116394. * @returns a JSON compatible object
  116395. */
  116396. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  116397. }
  116398. }
  116399. declare module BABYLON {
  116400. /**
  116401. * Class used to host texture specific utilities
  116402. */
  116403. export class TextureTools {
  116404. /**
  116405. * Uses the GPU to create a copy texture rescaled at a given size
  116406. * @param texture Texture to copy from
  116407. * @param width defines the desired width
  116408. * @param height defines the desired height
  116409. * @param useBilinearMode defines if bilinear mode has to be used
  116410. * @return the generated texture
  116411. */
  116412. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  116413. }
  116414. }
  116415. declare module BABYLON {
  116416. /**
  116417. * This represents the different options avilable for the video capture.
  116418. */
  116419. export interface VideoRecorderOptions {
  116420. /** Defines the mime type of the video */
  116421. mimeType: string;
  116422. /** Defines the video the video should be recorded at */
  116423. fps: number;
  116424. /** Defines the chunk size for the recording data */
  116425. recordChunckSize: number;
  116426. /** The audio tracks to attach to the record */
  116427. audioTracks?: MediaStreamTrack[];
  116428. }
  116429. /**
  116430. * This can helps recording videos from BabylonJS.
  116431. * This is based on the available WebRTC functionalities of the browser.
  116432. *
  116433. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  116434. */
  116435. export class VideoRecorder {
  116436. private static readonly _defaultOptions;
  116437. /**
  116438. * Returns wehther or not the VideoRecorder is available in your browser.
  116439. * @param engine Defines the Babylon Engine to check the support for
  116440. * @returns true if supported otherwise false
  116441. */
  116442. static IsSupported(engine: Engine): boolean;
  116443. private readonly _options;
  116444. private _canvas;
  116445. private _mediaRecorder;
  116446. private _recordedChunks;
  116447. private _fileName;
  116448. private _resolve;
  116449. private _reject;
  116450. /**
  116451. * True wether a recording is already in progress.
  116452. */
  116453. readonly isRecording: boolean;
  116454. /**
  116455. * Create a new VideoCapture object which can help converting what you see in Babylon to
  116456. * a video file.
  116457. * @param engine Defines the BabylonJS Engine you wish to record
  116458. * @param options Defines options that can be used to customized the capture
  116459. */
  116460. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  116461. /**
  116462. * Stops the current recording before the default capture timeout passed in the startRecording
  116463. * functions.
  116464. */
  116465. stopRecording(): void;
  116466. /**
  116467. * Starts recording the canvas for a max duration specified in parameters.
  116468. * @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.
  116469. * @param maxDuration Defines the maximum recording time in seconds.
  116470. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  116471. * @return a promise callback at the end of the recording with the video data in Blob.
  116472. */
  116473. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  116474. /**
  116475. * Releases internal resources used during the recording.
  116476. */
  116477. dispose(): void;
  116478. private _handleDataAvailable;
  116479. private _handleError;
  116480. private _handleStop;
  116481. }
  116482. }
  116483. declare module BABYLON {
  116484. /**
  116485. * Class containing a set of static utilities functions for screenshots
  116486. */
  116487. export class ScreenshotTools {
  116488. /**
  116489. * Captures a screenshot of the current rendering
  116490. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  116491. * @param engine defines the rendering engine
  116492. * @param camera defines the source camera
  116493. * @param size This parameter can be set to a single number or to an object with the
  116494. * following (optional) properties: precision, width, height. If a single number is passed,
  116495. * it will be used for both width and height. If an object is passed, the screenshot size
  116496. * will be derived from the parameters. The precision property is a multiplier allowing
  116497. * rendering at a higher or lower resolution
  116498. * @param successCallback defines the callback receives a single parameter which contains the
  116499. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  116500. * src parameter of an <img> to display it
  116501. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  116502. * Check your browser for supported MIME types
  116503. */
  116504. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  116505. /**
  116506. * Generates an image screenshot from the specified camera.
  116507. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  116508. * @param engine The engine to use for rendering
  116509. * @param camera The camera to use for rendering
  116510. * @param size This parameter can be set to a single number or to an object with the
  116511. * following (optional) properties: precision, width, height. If a single number is passed,
  116512. * it will be used for both width and height. If an object is passed, the screenshot size
  116513. * will be derived from the parameters. The precision property is a multiplier allowing
  116514. * rendering at a higher or lower resolution
  116515. * @param successCallback The callback receives a single parameter which contains the
  116516. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  116517. * src parameter of an <img> to display it
  116518. * @param mimeType The MIME type of the screenshot image (default: image/png).
  116519. * Check your browser for supported MIME types
  116520. * @param samples Texture samples (default: 1)
  116521. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  116522. * @param fileName A name for for the downloaded file.
  116523. */
  116524. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  116525. }
  116526. }
  116527. declare module BABYLON {
  116528. /**
  116529. * A cursor which tracks a point on a path
  116530. */
  116531. export class PathCursor {
  116532. private path;
  116533. /**
  116534. * Stores path cursor callbacks for when an onchange event is triggered
  116535. */
  116536. private _onchange;
  116537. /**
  116538. * The value of the path cursor
  116539. */
  116540. value: number;
  116541. /**
  116542. * The animation array of the path cursor
  116543. */
  116544. animations: Animation[];
  116545. /**
  116546. * Initializes the path cursor
  116547. * @param path The path to track
  116548. */
  116549. constructor(path: Path2);
  116550. /**
  116551. * Gets the cursor point on the path
  116552. * @returns A point on the path cursor at the cursor location
  116553. */
  116554. getPoint(): Vector3;
  116555. /**
  116556. * Moves the cursor ahead by the step amount
  116557. * @param step The amount to move the cursor forward
  116558. * @returns This path cursor
  116559. */
  116560. moveAhead(step?: number): PathCursor;
  116561. /**
  116562. * Moves the cursor behind by the step amount
  116563. * @param step The amount to move the cursor back
  116564. * @returns This path cursor
  116565. */
  116566. moveBack(step?: number): PathCursor;
  116567. /**
  116568. * Moves the cursor by the step amount
  116569. * If the step amount is greater than one, an exception is thrown
  116570. * @param step The amount to move the cursor
  116571. * @returns This path cursor
  116572. */
  116573. move(step: number): PathCursor;
  116574. /**
  116575. * Ensures that the value is limited between zero and one
  116576. * @returns This path cursor
  116577. */
  116578. private ensureLimits;
  116579. /**
  116580. * Runs onchange callbacks on change (used by the animation engine)
  116581. * @returns This path cursor
  116582. */
  116583. private raiseOnChange;
  116584. /**
  116585. * Executes a function on change
  116586. * @param f A path cursor onchange callback
  116587. * @returns This path cursor
  116588. */
  116589. onchange(f: (cursor: PathCursor) => void): PathCursor;
  116590. }
  116591. }
  116592. declare module BABYLON {
  116593. /** @hidden */
  116594. export var blurPixelShader: {
  116595. name: string;
  116596. shader: string;
  116597. };
  116598. }
  116599. declare module BABYLON {
  116600. /** @hidden */
  116601. export var bones300Declaration: {
  116602. name: string;
  116603. shader: string;
  116604. };
  116605. }
  116606. declare module BABYLON {
  116607. /** @hidden */
  116608. export var instances300Declaration: {
  116609. name: string;
  116610. shader: string;
  116611. };
  116612. }
  116613. declare module BABYLON {
  116614. /** @hidden */
  116615. export var pointCloudVertexDeclaration: {
  116616. name: string;
  116617. shader: string;
  116618. };
  116619. }
  116620. // Mixins
  116621. interface Window {
  116622. mozIndexedDB: IDBFactory;
  116623. webkitIndexedDB: IDBFactory;
  116624. msIndexedDB: IDBFactory;
  116625. webkitURL: typeof URL;
  116626. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  116627. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  116628. WebGLRenderingContext: WebGLRenderingContext;
  116629. MSGesture: MSGesture;
  116630. CANNON: any;
  116631. AudioContext: AudioContext;
  116632. webkitAudioContext: AudioContext;
  116633. PointerEvent: any;
  116634. Math: Math;
  116635. Uint8Array: Uint8ArrayConstructor;
  116636. Float32Array: Float32ArrayConstructor;
  116637. mozURL: typeof URL;
  116638. msURL: typeof URL;
  116639. VRFrameData: any; // WebVR, from specs 1.1
  116640. DracoDecoderModule: any;
  116641. setImmediate(handler: (...args: any[]) => void): number;
  116642. }
  116643. interface HTMLCanvasElement {
  116644. requestPointerLock(): void;
  116645. msRequestPointerLock?(): void;
  116646. mozRequestPointerLock?(): void;
  116647. webkitRequestPointerLock?(): void;
  116648. /** Track wether a record is in progress */
  116649. isRecording: boolean;
  116650. /** Capture Stream method defined by some browsers */
  116651. captureStream(fps?: number): MediaStream;
  116652. }
  116653. interface CanvasRenderingContext2D {
  116654. msImageSmoothingEnabled: boolean;
  116655. }
  116656. interface MouseEvent {
  116657. mozMovementX: number;
  116658. mozMovementY: number;
  116659. webkitMovementX: number;
  116660. webkitMovementY: number;
  116661. msMovementX: number;
  116662. msMovementY: number;
  116663. }
  116664. interface Navigator {
  116665. mozGetVRDevices: (any: any) => any;
  116666. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  116667. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  116668. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  116669. webkitGetGamepads(): Gamepad[];
  116670. msGetGamepads(): Gamepad[];
  116671. webkitGamepads(): Gamepad[];
  116672. }
  116673. interface HTMLVideoElement {
  116674. mozSrcObject: any;
  116675. }
  116676. interface Math {
  116677. fround(x: number): number;
  116678. imul(a: number, b: number): number;
  116679. }
  116680. interface WebGLRenderingContext {
  116681. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  116682. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  116683. vertexAttribDivisor(index: number, divisor: number): void;
  116684. createVertexArray(): any;
  116685. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  116686. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  116687. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  116688. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  116689. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  116690. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  116691. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  116692. // Queries
  116693. createQuery(): WebGLQuery;
  116694. deleteQuery(query: WebGLQuery): void;
  116695. beginQuery(target: number, query: WebGLQuery): void;
  116696. endQuery(target: number): void;
  116697. getQueryParameter(query: WebGLQuery, pname: number): any;
  116698. getQuery(target: number, pname: number): any;
  116699. MAX_SAMPLES: number;
  116700. RGBA8: number;
  116701. READ_FRAMEBUFFER: number;
  116702. DRAW_FRAMEBUFFER: number;
  116703. UNIFORM_BUFFER: number;
  116704. HALF_FLOAT_OES: number;
  116705. RGBA16F: number;
  116706. RGBA32F: number;
  116707. R32F: number;
  116708. RG32F: number;
  116709. RGB32F: number;
  116710. R16F: number;
  116711. RG16F: number;
  116712. RGB16F: number;
  116713. RED: number;
  116714. RG: number;
  116715. R8: number;
  116716. RG8: number;
  116717. UNSIGNED_INT_24_8: number;
  116718. DEPTH24_STENCIL8: number;
  116719. /* Multiple Render Targets */
  116720. drawBuffers(buffers: number[]): void;
  116721. readBuffer(src: number): void;
  116722. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  116723. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  116724. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  116725. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  116726. // Occlusion Query
  116727. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  116728. ANY_SAMPLES_PASSED: number;
  116729. QUERY_RESULT_AVAILABLE: number;
  116730. QUERY_RESULT: number;
  116731. }
  116732. interface WebGLProgram {
  116733. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  116734. }
  116735. interface EXT_disjoint_timer_query {
  116736. QUERY_COUNTER_BITS_EXT: number;
  116737. TIME_ELAPSED_EXT: number;
  116738. TIMESTAMP_EXT: number;
  116739. GPU_DISJOINT_EXT: number;
  116740. QUERY_RESULT_EXT: number;
  116741. QUERY_RESULT_AVAILABLE_EXT: number;
  116742. queryCounterEXT(query: WebGLQuery, target: number): void;
  116743. createQueryEXT(): WebGLQuery;
  116744. beginQueryEXT(target: number, query: WebGLQuery): void;
  116745. endQueryEXT(target: number): void;
  116746. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  116747. deleteQueryEXT(query: WebGLQuery): void;
  116748. }
  116749. interface WebGLUniformLocation {
  116750. _currentState: any;
  116751. }
  116752. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  116753. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  116754. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  116755. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  116756. interface WebGLRenderingContext {
  116757. readonly RASTERIZER_DISCARD: number;
  116758. readonly DEPTH_COMPONENT24: number;
  116759. readonly TEXTURE_3D: number;
  116760. readonly TEXTURE_2D_ARRAY: number;
  116761. readonly TEXTURE_COMPARE_FUNC: number;
  116762. readonly TEXTURE_COMPARE_MODE: number;
  116763. readonly COMPARE_REF_TO_TEXTURE: number;
  116764. readonly TEXTURE_WRAP_R: number;
  116765. readonly HALF_FLOAT: number;
  116766. readonly RGB8: number;
  116767. readonly RED_INTEGER: number;
  116768. readonly RG_INTEGER: number;
  116769. readonly RGB_INTEGER: number;
  116770. readonly RGBA_INTEGER: number;
  116771. readonly R8_SNORM: number;
  116772. readonly RG8_SNORM: number;
  116773. readonly RGB8_SNORM: number;
  116774. readonly RGBA8_SNORM: number;
  116775. readonly R8I: number;
  116776. readonly RG8I: number;
  116777. readonly RGB8I: number;
  116778. readonly RGBA8I: number;
  116779. readonly R8UI: number;
  116780. readonly RG8UI: number;
  116781. readonly RGB8UI: number;
  116782. readonly RGBA8UI: number;
  116783. readonly R16I: number;
  116784. readonly RG16I: number;
  116785. readonly RGB16I: number;
  116786. readonly RGBA16I: number;
  116787. readonly R16UI: number;
  116788. readonly RG16UI: number;
  116789. readonly RGB16UI: number;
  116790. readonly RGBA16UI: number;
  116791. readonly R32I: number;
  116792. readonly RG32I: number;
  116793. readonly RGB32I: number;
  116794. readonly RGBA32I: number;
  116795. readonly R32UI: number;
  116796. readonly RG32UI: number;
  116797. readonly RGB32UI: number;
  116798. readonly RGBA32UI: number;
  116799. readonly RGB10_A2UI: number;
  116800. readonly R11F_G11F_B10F: number;
  116801. readonly RGB9_E5: number;
  116802. readonly RGB10_A2: number;
  116803. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  116804. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  116805. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  116806. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  116807. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  116808. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  116809. 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;
  116810. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  116811. readonly TRANSFORM_FEEDBACK: number;
  116812. readonly INTERLEAVED_ATTRIBS: number;
  116813. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  116814. createTransformFeedback(): WebGLTransformFeedback;
  116815. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  116816. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  116817. beginTransformFeedback(primitiveMode: number): void;
  116818. endTransformFeedback(): void;
  116819. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  116820. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  116821. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  116822. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  116823. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  116824. }
  116825. interface ImageBitmap {
  116826. readonly width: number;
  116827. readonly height: number;
  116828. close(): void;
  116829. }
  116830. interface WebGLQuery extends WebGLObject {
  116831. }
  116832. declare var WebGLQuery: {
  116833. prototype: WebGLQuery;
  116834. new(): WebGLQuery;
  116835. };
  116836. interface WebGLSampler extends WebGLObject {
  116837. }
  116838. declare var WebGLSampler: {
  116839. prototype: WebGLSampler;
  116840. new(): WebGLSampler;
  116841. };
  116842. interface WebGLSync extends WebGLObject {
  116843. }
  116844. declare var WebGLSync: {
  116845. prototype: WebGLSync;
  116846. new(): WebGLSync;
  116847. };
  116848. interface WebGLTransformFeedback extends WebGLObject {
  116849. }
  116850. declare var WebGLTransformFeedback: {
  116851. prototype: WebGLTransformFeedback;
  116852. new(): WebGLTransformFeedback;
  116853. };
  116854. interface WebGLVertexArrayObject extends WebGLObject {
  116855. }
  116856. declare var WebGLVertexArrayObject: {
  116857. prototype: WebGLVertexArrayObject;
  116858. new(): WebGLVertexArrayObject;
  116859. };
  116860. // Type definitions for WebVR API
  116861. // Project: https://w3c.github.io/webvr/
  116862. // Definitions by: six a <https://github.com/lostfictions>
  116863. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  116864. interface VRDisplay extends EventTarget {
  116865. /**
  116866. * Dictionary of capabilities describing the VRDisplay.
  116867. */
  116868. readonly capabilities: VRDisplayCapabilities;
  116869. /**
  116870. * z-depth defining the far plane of the eye view frustum
  116871. * enables mapping of values in the render target depth
  116872. * attachment to scene coordinates. Initially set to 10000.0.
  116873. */
  116874. depthFar: number;
  116875. /**
  116876. * z-depth defining the near plane of the eye view frustum
  116877. * enables mapping of values in the render target depth
  116878. * attachment to scene coordinates. Initially set to 0.01.
  116879. */
  116880. depthNear: number;
  116881. /**
  116882. * An identifier for this distinct VRDisplay. Used as an
  116883. * association point in the Gamepad API.
  116884. */
  116885. readonly displayId: number;
  116886. /**
  116887. * A display name, a user-readable name identifying it.
  116888. */
  116889. readonly displayName: string;
  116890. readonly isConnected: boolean;
  116891. readonly isPresenting: boolean;
  116892. /**
  116893. * If this VRDisplay supports room-scale experiences, the optional
  116894. * stage attribute contains details on the room-scale parameters.
  116895. */
  116896. readonly stageParameters: VRStageParameters | null;
  116897. /**
  116898. * Passing the value returned by `requestAnimationFrame` to
  116899. * `cancelAnimationFrame` will unregister the callback.
  116900. * @param handle Define the hanle of the request to cancel
  116901. */
  116902. cancelAnimationFrame(handle: number): void;
  116903. /**
  116904. * Stops presenting to the VRDisplay.
  116905. * @returns a promise to know when it stopped
  116906. */
  116907. exitPresent(): Promise<void>;
  116908. /**
  116909. * Return the current VREyeParameters for the given eye.
  116910. * @param whichEye Define the eye we want the parameter for
  116911. * @returns the eye parameters
  116912. */
  116913. getEyeParameters(whichEye: string): VREyeParameters;
  116914. /**
  116915. * Populates the passed VRFrameData with the information required to render
  116916. * the current frame.
  116917. * @param frameData Define the data structure to populate
  116918. * @returns true if ok otherwise false
  116919. */
  116920. getFrameData(frameData: VRFrameData): boolean;
  116921. /**
  116922. * Get the layers currently being presented.
  116923. * @returns the list of VR layers
  116924. */
  116925. getLayers(): VRLayer[];
  116926. /**
  116927. * Return a VRPose containing the future predicted pose of the VRDisplay
  116928. * when the current frame will be presented. The value returned will not
  116929. * change until JavaScript has returned control to the browser.
  116930. *
  116931. * The VRPose will contain the position, orientation, velocity,
  116932. * and acceleration of each of these properties.
  116933. * @returns the pose object
  116934. */
  116935. getPose(): VRPose;
  116936. /**
  116937. * Return the current instantaneous pose of the VRDisplay, with no
  116938. * prediction applied.
  116939. * @returns the current instantaneous pose
  116940. */
  116941. getImmediatePose(): VRPose;
  116942. /**
  116943. * The callback passed to `requestAnimationFrame` will be called
  116944. * any time a new frame should be rendered. When the VRDisplay is
  116945. * presenting the callback will be called at the native refresh
  116946. * rate of the HMD. When not presenting this function acts
  116947. * identically to how window.requestAnimationFrame acts. Content should
  116948. * make no assumptions of frame rate or vsync behavior as the HMD runs
  116949. * asynchronously from other displays and at differing refresh rates.
  116950. * @param callback Define the eaction to run next frame
  116951. * @returns the request handle it
  116952. */
  116953. requestAnimationFrame(callback: FrameRequestCallback): number;
  116954. /**
  116955. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  116956. * Repeat calls while already presenting will update the VRLayers being displayed.
  116957. * @param layers Define the list of layer to present
  116958. * @returns a promise to know when the request has been fulfilled
  116959. */
  116960. requestPresent(layers: VRLayer[]): Promise<void>;
  116961. /**
  116962. * Reset the pose for this display, treating its current position and
  116963. * orientation as the "origin/zero" values. VRPose.position,
  116964. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  116965. * updated when calling resetPose(). This should be called in only
  116966. * sitting-space experiences.
  116967. */
  116968. resetPose(): void;
  116969. /**
  116970. * The VRLayer provided to the VRDisplay will be captured and presented
  116971. * in the HMD. Calling this function has the same effect on the source
  116972. * canvas as any other operation that uses its source image, and canvases
  116973. * created without preserveDrawingBuffer set to true will be cleared.
  116974. * @param pose Define the pose to submit
  116975. */
  116976. submitFrame(pose?: VRPose): void;
  116977. }
  116978. declare var VRDisplay: {
  116979. prototype: VRDisplay;
  116980. new(): VRDisplay;
  116981. };
  116982. interface VRLayer {
  116983. leftBounds?: number[] | Float32Array | null;
  116984. rightBounds?: number[] | Float32Array | null;
  116985. source?: HTMLCanvasElement | null;
  116986. }
  116987. interface VRDisplayCapabilities {
  116988. readonly canPresent: boolean;
  116989. readonly hasExternalDisplay: boolean;
  116990. readonly hasOrientation: boolean;
  116991. readonly hasPosition: boolean;
  116992. readonly maxLayers: number;
  116993. }
  116994. interface VREyeParameters {
  116995. /** @deprecated */
  116996. readonly fieldOfView: VRFieldOfView;
  116997. readonly offset: Float32Array;
  116998. readonly renderHeight: number;
  116999. readonly renderWidth: number;
  117000. }
  117001. interface VRFieldOfView {
  117002. readonly downDegrees: number;
  117003. readonly leftDegrees: number;
  117004. readonly rightDegrees: number;
  117005. readonly upDegrees: number;
  117006. }
  117007. interface VRFrameData {
  117008. readonly leftProjectionMatrix: Float32Array;
  117009. readonly leftViewMatrix: Float32Array;
  117010. readonly pose: VRPose;
  117011. readonly rightProjectionMatrix: Float32Array;
  117012. readonly rightViewMatrix: Float32Array;
  117013. readonly timestamp: number;
  117014. }
  117015. interface VRPose {
  117016. readonly angularAcceleration: Float32Array | null;
  117017. readonly angularVelocity: Float32Array | null;
  117018. readonly linearAcceleration: Float32Array | null;
  117019. readonly linearVelocity: Float32Array | null;
  117020. readonly orientation: Float32Array | null;
  117021. readonly position: Float32Array | null;
  117022. readonly timestamp: number;
  117023. }
  117024. interface VRStageParameters {
  117025. sittingToStandingTransform?: Float32Array;
  117026. sizeX?: number;
  117027. sizeY?: number;
  117028. }
  117029. interface Navigator {
  117030. getVRDisplays(): Promise<VRDisplay[]>;
  117031. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  117032. }
  117033. interface Window {
  117034. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  117035. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  117036. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  117037. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  117038. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  117039. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  117040. }
  117041. interface Gamepad {
  117042. readonly displayId: number;
  117043. }
  117044. interface XRDevice {
  117045. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  117046. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  117047. }
  117048. interface XRSession {
  117049. getInputSources(): Array<any>;
  117050. baseLayer: XRWebGLLayer;
  117051. requestFrameOfReference(type: string): Promise<void>;
  117052. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  117053. end(): Promise<void>;
  117054. requestAnimationFrame: Function;
  117055. addEventListener: Function;
  117056. }
  117057. interface XRSessionCreationOptions {
  117058. outputContext?: WebGLRenderingContext | null;
  117059. immersive?: boolean;
  117060. environmentIntegration?: boolean;
  117061. }
  117062. interface XRLayer {
  117063. getViewport: Function;
  117064. framebufferWidth: number;
  117065. framebufferHeight: number;
  117066. }
  117067. interface XRView {
  117068. projectionMatrix: Float32Array;
  117069. }
  117070. interface XRFrame {
  117071. getDevicePose: Function;
  117072. getInputPose: Function;
  117073. views: Array<XRView>;
  117074. baseLayer: XRLayer;
  117075. }
  117076. interface XRFrameOfReference {
  117077. }
  117078. interface XRWebGLLayer extends XRLayer {
  117079. framebuffer: WebGLFramebuffer;
  117080. }
  117081. declare var XRWebGLLayer: {
  117082. prototype: XRWebGLLayer;
  117083. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  117084. };